Extract single chromosome reads from Bam file
1
0
Entering edit mode
10 months ago
marco.barr ▴ 160

I'm trying to extract the reads relating to chrM from an aligned BAM file but without success. These are my commands:

samtools view -h Linfo_mt6394_aligned_sorted.bam chrM > Linfo_mt6394_chrM_aligned.sorted.sam 
samtools view -bS Linfo_mt6394_chrM_aligned.sorted.sam > Linfo_mt6394_chrM_aligned.sorted.bam

when I check with samtools idxstats results all chromosome. Why? Are there alternative ways to extract single chromosome reads from a BAM file?

Thanks

bam reads extract samtools • 349 views
ADD COMMENT
1
Entering edit mode
10 months ago
ATpoint 86k

You see that all chromosomes are still in the header, but only chrM will have reads. The header is not updated. Note that the sam/bam conversion is unnecessary.

samtools view -h -o Linfo_mt6394_chrM_aligned.sorted.bam Linfo_mt6394_aligned_sorted.bam chrM 

That command is the same without unnecessary conversion.

ADD COMMENT

Login before adding your answer.

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