v40.02. There's actually two (possibly related) issues here:
I typically use bbmap on amplicon libraries so I expect only properly paired alignments (reads nearby on opposite strands). Accordingly I almost always use killbadpairs to prevent discordant paired alignments and pairedonly to ensure singletons are rendered unmapped. I also always set deterministic and averagepairdistance. Typically I also set ambig=toss.
Issue 1 (bug):
When I set ambig=random I get multiple split alignments, with reads mapped to different chromosomes. This should never occur with killbadpairs, reads mapping to different chromosomes is the same as reads mapping to the same strand or with the wrong insert size.
Issue 2 (not really a bug, more like an algorithm flaw):
When I set ambig=toss I only get alignments with mapqs ≥11. When I set ambig=best I also get ambiguous alignments with mapq=2 and mapq=3 (not sure why these aren't mapq=0 which is how most other aligners set mapq for multiple equally good alignments, but ok). But I also get more alignments for every mapq ≥11, because one read maps ambiguously but the other does not, so in "toss" mode with kbp po they're both discarded, but in "best" mode they're both kept, e.g. one with mapq=2 and the other with mapq ≥11.
To me, considering only the uniqueness of each read individually defeats much of the value of aligning paired reads; if I just want bbmap's best guess for each read's optimal alignment regardless of pairing I would just align in single-end mode. Rather, the uniqueness of the pair should be considered, with the aligner striving to keep reads together in a concordant alignment rather than separating them (which it should only do if no concordant alignment can be found). In this example case, they should not be discarded in "toss" mode because one of the reads aligned uniquely and the other read can be placed nearby. Only in cases where there are multiple concordant paired alignments should "toss" discard the pair (or if there are zero, then consider each read individually, but in this case kbp po should eliminate them).
This relates to Issue 1 because with ambig=random, bbmap should assign the pair to a random location with a concordant alignment if possible, rather than separating them (and if a concordant alignment is not possible, then kbp should unmap the worse read and po should unmap the other). If one read in a pair aligns to several locations and the other only aligns to one, then "random" should always align the pair to the one unique location.
v40.02. There's actually two (possibly related) issues here:
I typically use bbmap on amplicon libraries so I expect only properly paired alignments (reads nearby on opposite strands). Accordingly I almost always use
killbadpairsto prevent discordant paired alignments andpairedonlyto ensure singletons are rendered unmapped. I also always setdeterministicandaveragepairdistance. Typically I also setambig=toss.Issue 1 (bug):
When I set
ambig=randomI get multiple split alignments, with reads mapped to different chromosomes. This should never occur withkillbadpairs, reads mapping to different chromosomes is the same as reads mapping to the same strand or with the wrong insert size.Issue 2 (not really a bug, more like an algorithm flaw):
When I set
ambig=tossI only get alignments with mapqs ≥11. When I setambig=bestI also get ambiguous alignments with mapq=2 and mapq=3 (not sure why these aren't mapq=0 which is how most other aligners set mapq for multiple equally good alignments, but ok). But I also get more alignments for every mapq ≥11, because one read maps ambiguously but the other does not, so in "toss" mode withkbp pothey're both discarded, but in "best" mode they're both kept, e.g. one with mapq=2 and the other with mapq ≥11.To me, considering only the uniqueness of each read individually defeats much of the value of aligning paired reads; if I just want bbmap's best guess for each read's optimal alignment regardless of pairing I would just align in single-end mode. Rather, the uniqueness of the pair should be considered, with the aligner striving to keep reads together in a concordant alignment rather than separating them (which it should only do if no concordant alignment can be found). In this example case, they should not be discarded in "toss" mode because one of the reads aligned uniquely and the other read can be placed nearby. Only in cases where there are multiple concordant paired alignments should "toss" discard the pair (or if there are zero, then consider each read individually, but in this case
kbp poshould eliminate them).This relates to Issue 1 because with
ambig=random, bbmap should assign the pair to a random location with a concordant alignment if possible, rather than separating them (and if a concordant alignment is not possible, thenkbpshould unmap the worse read andposhould unmap the other). If one read in a pair aligns to several locations and the other only aligns to one, then "random" should always align the pair to the one unique location.