This is a test version of Biostars. For the public version, visit https://www.biostars.org.
mapped reads and unmapped reads not equal total number of reads

To remove mitochondria , align with mitochondria reference and reads. After that I collect mapped reads and unmapped reads. But mapped reads + unmapped != total number of reads, Why?

alignment

Could you please share the commands used to calculate mapped & unmapped. And also the aligner used with parameters given.

Align: bwa mem -t 8 -R '@RG\tID:1\tLB:1\tPL:ILLUMINA\tSM:1' mt.fasta read1.fq read2.fq >aln-mt.sam

Unmapped read: samtools view -@ 12 -b -S -f 12 aln-mt.sam > unmapped.bam

Mapped read: samtools view -@ 12 -b -S -F 12 aln-mt.sam > mapped.bam

Could you please check if counting by reads rather than by pairs is working fine. i.e. Please use flag -F 260 instead of 12 to get mapped count.Also -f 4 instead of 12 to get unmapped. Please add the above two and see if it totals correctly with input count. example

samtools view -bhS  aln-mt.sam >aln-mt.bam

samtools view -c -F 260 aln-mt.bam 

samtools view -c -f 4 aln-mt.bam

zcat read1.fq read2.fq  | wc -l (output  divide by 4)

1 answer

They can not always be equal. Why do you think so ? One probable reason is that count of mapped reads includes multi-mapped reads too. A read mapping , say twice (at 2 different loci) , will be counted twice !

Log in to answer this question.