Change Notation Of Chromosome In Bam File
2
1
Entering edit mode
9.6 years ago
hellbio ▴ 490

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 • 6.8k views
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode
9.6 years ago

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 COMMENT
0
Entering edit mode
8.9 years ago
ff.cc.cc ★ 1.3k

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 COMMENT

Login before adding your answer.

Traffic: 3026 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6