This is a test version of Biostars. For the public version, visit https://www.biostars.org.
samtools filter proper paired alignment

I want get proper paired alignment here is my scripts

$ samtools view  test1.v2.4.reordered.bam -f 2 -bS - 1> test1.uniq.prop.pair.bam

Next using flagstat check result bam

samtools flagstat test1.uniq.prop.pair.bam 

33117 + 0 in total (QC-passed reads + QC-failed reads)
0 + 0 secondary
0 + 0 supplementary
0 + 0 duplicates
33117 + 0 mapped (100.00% : N/A)
33117 + 0 paired in sequencing
16526 + 0 read1
16591 + 0 read2
33117 + 0 properly paired (100.00% : N/A)
33117 + 0 with itself and mate mapped
0 + 0 singletons (0.00% : N/A)
0 + 0 with mate mapped to a different chr
0 + 0 with mate mapped to a different chr (mapQ>=5)

I am confused why the count of read1 is not equal to read2? does anybody explain that ? thank you!

alignment

However It is stilled confused that "proper paired (filtered by flag -f 2)" bam file have different count of read1 and read2 ?

Did you read the part about supplementary alignments?

thank you, i got it. I mistook about supplement alignment and second alignment. your post is very useful.

1 answer

BWA mem alignments? If so see get identical number of read1 and read2 aligned

Yes, I got this bam by BWA mem. I want to get propered alignment, using fixmate to filter, is that right? samtools fixmate test1.uniq.prop.pair.bam a.bam

33117 + 0 in total (QC-passed reads + QC-failed reads)
0 + 0 secondary
0 + 0 supplementary
0 + 0 duplicates
33117 + 0 mapped (100.00% : N/A)
31044 + 0 paired in sequencing
15522 + 0 read1
15522 + 0 read2
31044 + 0 properly paired (100.00% : N/A)
31044 + 0 with itself and mate mapped
0 + 0 singletons (0.00% : N/A)
0 + 0 with mate mapped to a different chr
0 + 0 with mate mapped to a different chr (mapQ>=5)

Log in to answer this question.