Fix fragment match double counting#183
Open
JemmaLDaniel wants to merge 2 commits intofeat-refactor-calibration-featuresfrom
Open
Fix fragment match double counting#183JemmaLDaniel wants to merge 2 commits intofeat-refactor-calibration-featuresfrom
JemmaLDaniel wants to merge 2 commits intofeat-refactor-calibration-featuresfrom
Conversation
8e9a314 to
f49db77
Compare
f0af123 to
3a65f83
Compare
f49db77 to
7b2daac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix fragment ion double-counting in peak matching
Summary
Fixes a bug in
find_matching_ionswhere an observed peak that was already matched as part of one theoretical ion's isotopic envelope could be re-matched as the M0 peak of a different theoretical ion. This inflated bothion_matchesandion_match_intensity, producing overly optimistic match rates.The fix tracks matched observed peak indices in a set and skips any peak that has already been assigned, ensuring each observed peak contributes to at most one theoretical ion match.
Changes
winnow/calibration/features/utils.py—find_matching_ionsnow maintains amatched_indicesset of already-assigned observed peak indices. Before matching an M0 peak, the function checks whether that index has already been claimed (either as a prior M0 or as part of a prior isotopic envelope). Isotopic envelope peaks are also added to the set when matched.tests/calibration/features/test_utils.py— adds targeted test cases that construct spectra where the same observed peak could be matched by multiple theoretical ions, verifying that only the first match is counted.