Question: Change Notation Of Chromosome In Bam File
gravatar for hellbio
7.2 years ago by
hellbio420 wrote:

Hi all,

I have a bam file with chromosomal notation 1,2.... and i need it to be as chr1,chr2.....

For this i have tried, samtools view -H sample.bam > header.sam

Then edited the header.sam file with required chromosomal notation and tried samtools reheader header.sam sample.bam > out.bam

when in tried to view out.bam using samtools it says "Segemntation fault".

I also tried with PICARD, java -Xmx4g -jar ReplaceSamHeader.jar INPUT=sample.bam HEADER=header.sam OUTPUT=out.bam CREATE_INDEX=TRUE

It reports the same error with samtools i.e. segmenation fault.

Could anyone help me to fix this?

bam samtools • 4.8k views
ADD COMMENTlink modified 6.5 years ago by • written 7.2 years ago by hellbio420

This question has been answered elsewhere: A: Bam File: Change Chromosome Notation (see my script there). I think segmentation fault means your computer ran out of memory.



ADD REPLYlink written 5.5 years ago by petervangalen60
gravatar for Zev.Kronenberg
7.2 years ago by
United States
Zev.Kronenberg11k wrote:

The reads need to have the same @SQ tags for the seqid.

samtools view your.bam | perl -lane 'if($_ =~ /\@/){print $_}else{$F[2] = "chr$F[2]" if $F[2] !~ /\*/; print join "\t", @F}' | bgzip or gzip

Of coure you will need to edit your header so the @SQ tags are correct.

ADD COMMENTlink modified 7.2 years ago • written 7.2 years ago by Zev.Kronenberg11k
gravatar for
6.5 years ago by
European Union wrote:

Hi, I had the same task with my chomosome notation. Bam Header Edit helped me.

About the crash, beware of samtools version. Someone experimented crashes before version 0.1.19

ADD COMMENTlink written 6.5 years ago by
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1110 users visited in the last hour