This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Differentiate Between Mate Pair And Paired End Reads Based On Sam Flag

Hi All

Just wondering how can i find out given a sam/bam file how many read pairs are mate pairs ie facing outwards (<--- --->) and how many of them are paired end i.e (----> <-----).

__________________ = Reference

<--------      --------->                                  = Mate Pairs


-------->     <----------                                  = Paired Ends

I can visually see the difference on a browser but if I want to numerically find out based on sam flag I am not able to come up with a right combination.

next-gen sequencing paired

1 answer

The magic binary flags for good paired reads are 83,99,147 and 163. Those are properly paired, with one read forwrad, one read reverse.

If the software that you are using to make your sam files won't count mate pairs as properly paired, then you are looking for 81,97,145, and 161. Those will be reads where one is forward, and one is reverse, but where the software for some reason thinks that the pair isn't right, which could be a mate pair.

If mate pairs are being counted as properly paired, then you want pairs where the forward facing one points out, therefore, is ahead of the reverse one.

So in a normally paired run, all the read with binary flags of 147 have negative isizes. So a positive size should mean mate pair. Likewise, if the flag is 99, a positive isize means paired end, a negative isize means mate pair.

If the flag is 83, a positive isize means mate pair, negative means paired end.

If the flag is 163, a negative isize means mate pair, positive means paired end.

Do you happen to know which aligners count mate pairs as properly paired, which do not? Thanks!

@swbarnes2 : thanks for your comments. I did not mention but in case the read 1/2 alignments are done separately and manual pariring is done then we wont have the insert size rather insert needs to be calculated. Can anything be applied in that case. The kind of data that I have doesnt go well with the default pairing algo eg. BWA. Also could you say what is the significance of negative isize

Log in to answer this question.