Skip to content

Fixes bug in assigning MAPQ 60 to reads that are not proper pairs.#596

Merged
marcelm merged 2 commits into
mainfrom
fix-not-proper-pair-mapq
Jun 26, 2026
Merged

Fixes bug in assigning MAPQ 60 to reads that are not proper pairs.#596
marcelm merged 2 commits into
mainfrom
fix-not-proper-pair-mapq

Conversation

@ksahlin

@ksahlin ksahlin commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Previously, the best non-proper pair would get a mapq of 60, regardless of whether it had multiple best scoring chains or not. This commit fixes the bug.

If the best pair is not proper: check for each read if the second-best chain has the same score, if so, assign mapq 0, otherwise compute mapq from our formula. If there is no second chain, the read gets 60.

The fix is quite modular. But we may want to watch out for conflicts or to reintroduce the faulty behavior when merging PR
#584 (based on PR #576)

This issue was detected when I was running samdiff.py for the 2bit-ref-rs PR (see end of this comment #595 (comment)), which had 4170 that had a MAPQ score of > 0 and logged under "changed in another way", but further assessment of those 4170 gave:

3,940 (94.5%) — same AS between versions, but mapped to a different but equally-scored location (should be MAPQ=0).

ksahlin and others added 2 commits June 12, 2026 11:25
Previously the individual best non-proper pair would get a mapq of 60,
regardless if it had multiple best scoring chains or not.
This commit fixes the bug.

If the best pair is individual: check for each read if second best chain
has the same score, if so, assign mapq 0, otherwise compute mapq from our
formula. If there is no second chain the read gets 60.
@marcelm marcelm force-pushed the fix-not-proper-pair-mapq branch from d9c0577 to e9cb278 Compare June 12, 2026 09:29
@marcelm

marcelm commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Nice, looks good! I have added a changelog entry and simplified the MAPQ computation by removing one nested if.

@ksahlin

ksahlin commented Jun 12, 2026

Copy link
Copy Markdown
Owner Author

great. I am ok to merge if you are.

@marcelm marcelm merged commit eaf9677 into main Jun 26, 2026
7 checks passed
@marcelm marcelm deleted the fix-not-proper-pair-mapq branch June 26, 2026 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants