Hi all,
I want to remove all mitochondrial reads from my BAM files, but after doing so the number of mapped reads increased. Here's what I did after indexing:
samtools idxstats .bam | cut -f 1 | grep -v chrM | xargs samtools view -b .bam > clean.bam
However comparing with wc -l says:
samtools view -F 0x904 -c clean.bam
19452291
samtools view -F 0x904 -c .bam
18328474
The second number matches the summary output by tophat2 (fr-frstrand)
any suggestions?
I am using the exact same command, except that I put chrM in quotation marks. Also, don't forget the -h flag in the last
view
, as many tools need the BAM header to work properly (or work at all).He's outputting to BAM (-b) so it will always have a header. It's only SAM where it's optional for some reason.