I am trying to find thoroughfull documentation of samtools flagstat for every row for file Un.bam
samtools flagstat Un.bam
8444 + 0 in total (QC-passed reads + QC-failed reads)
0 + 0 duplicates
8154 + 0 mapped (96.57%:nan%)
8444 + 0 paired in sequencing
4383 + 0 read1
4061 + 0 read2
5973 + 0 properly paired (70.74%:nan%)
7793 + 0 with itself and mate mapped
361 + 0 singletons (4.28%:nan%)
1428 + 0 with mate mapped to a different chr
337 + 0 with mate mapped to a different chr (mapQ>=5)
samtools view -F 4 -q 1 -f 2 -b Un.bam >filtered.bam
samtools flagstat filtered.bam
4613 + 0 in total (QC-passed reads + QC-failed reads)
0 + 0 duplicates
4613 + 0 mapped (100.00%:nan%)
4613 + 0 paired in sequencing
2330 + 0 read1
2283 + 0 read2
4613 + 0 properly paired (100.00%:nan%)
4613 + 0 with itself and mate mapped
0 + 0 singletons (0.00%:nan%)
61 + 0 with mate mapped to a different chr
53 + 0 with mate mapped to a different chr (mapQ>=5)
EDIT: without demanding mapQ>1
samtools view -F 4 -f 2 -b Un.bam >filtered.bam
[mqm5775@hammer22 bam]$ samtools flagstat filtered.bam
5973 + 0 in total (QC-passed reads + QC-failed reads)
0 + 0 duplicates
5973 + 0 mapped (100.00%:nan%)
5973 + 0 paired in sequencing
3010 + 0 read1
2963 + 0 read2
5973 + 0 properly paired (100.00%:nan%)
5973 + 0 with itself and mate mapped
0 + 0 singletons (0.00%:nan%)
207 + 0 with mate mapped to a different chr
53 + 0 with mate mapped to a different chr (mapQ>=5)
Since I asked for reads mapped in proper pair I would expect read1 and read2 numbers to be the same, but maybe I am just misunderstanding what these rows mean. Could someone please point me to the documentation or explain this issue? Thanks a lot.
I rerun flagstat without demand for mapq >=1 and values still differ. Should I assume that something is already wrong with my Un.bam file? If yes, can you guess what it could be? :)
Could you give us more details about how the BAM file has been generated.
I was bwa mem with paired-end reads with -M option (Mark shorter split hits as secondary (for Picard compatibility).)