How to modify chr naming in bam file: chr -> just number
1
0
Entering edit mode
6.0 years ago
jonessara770 ▴ 240

Hi,

I have a bam file that chromosome names are like chr1, chr2 etc. I want to convert it to the form where chromosome naming is just numbered e.g. 1,2,3. I don't know how to change the below code for removing chr instead of adding it?

samtools view -h $B | \
sed -e '/^@SQ/s/SN\:/SN\:chr/' -e '/^[^@]/s/\t/\tchr/2' | \
samtools view -bS - > temp.bam

Thanks Sara

RNA-Seq • 5.1k views
ADD COMMENT
0
Entering edit mode
6.0 years ago

Try :

samtools view -h $B |  sed -e '/^@SQ/s/SN\:chr/SN\:/' -e '/^[^@]/s/\tchr/\t/2' |  samtools view -bS - > temp.bam
ADD COMMENT
0
Entering edit mode

your solution doesn't work with the supplementary alignments and the mate data.

ADD REPLY

Login before adding your answer.

Traffic: 2117 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