2.1 years ago by
What we have in SAM spec:
- 256 for secondary alignment
- 4 for unmapped
- Multiple mapping :One of these alignments is considered primary. All
the other alignments have the secondary alignment flag set in
the SAM records that represent them.
- NH i Number of reported alignments that contains the query in the
Keeping the above in mind, if the aligned bam file is from tophat or STAR (unmapped not included)
samtools view -F 256 should keep out secondary giving primary aligned only.
On the other hand if the bam is from bowtie2 or bwa or so (having unmapped included in the same bam)
We need to use flag 4 as well (256 + 4 ->260).Hence
samtools view -F 260 would be useful in that case
Now as asked, there should indeed be a connection between primary and uniquely aligned owing to the fact that, uniquely aligned reads will have one primary alignment only and no secondary alignments. But, I doubt there is any FLAG per se that could fetch the uniquely aligned directly.
Instead we have to rather rely on mapping quality and NH tag but there is indeed a problem here,
Though the specification gives a MAPQ field, it do not specify any particular value for uniquely mapped.In other words, the quality value for uniquely mapped is dependent on the aligner used. For example, STAR specifies a 255 value for uniquely mapped.
Another option is the NH field specification mentioned at the top from SAM spec. Accordingly NH:i:1 should indicate a uniquely mapped.
But in the certain cases where the quality value used for unique alignments is not clearly specified and the NH field also is not used, the flawless indicator of unique mapping is something I am searching for months and yet to get an answer.
I look forward to better answers (and corrections if any) touching the supplementary alignment flag as well if relevant.