Repository navigation
[FEATURE,PARAM] Add configurable max_apex_deviation_ppm guard in Mass… - #10929
martand-codes wants to merge 1 commit into
Conversation
|
Welcome @martand-codes and thank you for your contribution to OpenMS! To help us better understand our userbase and contributors, we would appreciate if you could complete the survey at the link below. Completing this survey will help us get to your PR sooner. Thank you for your participation! Before we review your PR, please confirm the following by replying to this comment with the checklist below (copy, paste and tick the boxes): |
timosachsenberg
left a comment
There was a problem hiding this comment.
Focused review of the m/z candidate selection, apex guard, trace extension, callers and new test. Reproduced the finding below with a compiled C++20 isolated harness mirroring the weighted-centroid update, nearest-candidate selection and guard; assertions passed. Base (guard disabled) accepts the selected peak, whereas the PR guard rejects it despite an admissible alternative. No full OpenMS build or integration test: no checkout or pyOpenMS in this environment, and git ls-remote cannot resolve github.com.
| } | ||
|
|
||
| // Edit: making a guard: A peak must not drift beyond the allowable tolerance relative to the apex | ||
| if(max_apex_deviation_ppm_ > 0.0) { |
There was a problem hiding this comment.
P2 – Search inside the apex window before choosing a peak. findBestPeak_() picks the m/z-nearest peak without the new apex bound, and this later check can reject it even if another peak in the same scan meets both the centroid and apex tolerances. That counts a false missed scan, potentially ending a valid trace after repeated misses. In a compiled C++20 isolated reproducer following the actual centroid update (including the apex's second weight), apex 500.0 with max_apex_deviation_ppm=50, mass_error_ppm=20 and reestimate_mt_sd=false reaches centroid 500.014679612 after four accepted 500.024 peaks. A subsequent scan containing 500.000 (valid) and 500.026 (outside 50 ppm) selects 500.026 as nearest, then rejects the scan, never considering 500.000. All assertions passed. With the guard disabled, the same selected candidate is accepted; the false miss is introduced by this parameter. Please apply the apex constraint while searching for the best candidate (for both non-IM and IM data) and cover the two-peak case in a regression test. This verifies the isolated selection logic, not a full OpenMS integration run.
There was a problem hiding this comment.
Thanks for the thorough review and reproducer @timosachsenberg!
Great catch regarding the false missed scans. I have updated findBestPeak_() to intersect the candidate search window with the apex envelope [left_bound, right_bound] before candidate selection for both non-IM and IM data, ensuring candidates outside the apex bound are never selected when an admissible alternative exists.
I also added your two peak scenario as a regression test in MassTraceDetection_test.cpp, added myself to AUTHORS and pushed the update to this branch. All local unit tests pass cleanly!
…regression test - Update findBestPeak_ to intersect the m/z search window with the apex tolerance envelope before selecting candidates for both non-IM and IM data, preventing false missed scans when an admissible alternative exists. - Add regression unit test in MassTraceDetection_test covering the two-peak scan scenario. - Add contributor to AUTHORS. Addresses review feedback on OpenMS#10929 by @timosachsenberg.
|
Thank you. But I was hoping for some comparison to a parameter-less fix. |
|
Hi @jpfeuffer, That's a very fair point regarding parameter proliferation Here is a comparison of the current develop baseline against a parameter less formulation on
For a parameter less fix, there are two primary directions we can take:
I can readily update this PR to be completely parameter less without adding any new user-facing parameters. Which of these formulations aligns best with what you had in mind? |
|
The one that works best with all data. |
…tic 3-sigma apex envelope - Derive apex-anchored guard automatically as 3 * mass_error_ppm (default -1.0), enabling out-of-the-box drift prevention across all datasets without requiring user parameter tuning. - Allow optional custom override via max_apex_deviation_ppm, or 0.0 to disable. - Intersect candidate search window with apex tolerance before peak selection in findBestPeak_. - Add unit tests covering guard cutoffs and the two-peak scan candidate selection scenario. - Confirmed on Metabolomics_1 (102 -> 0 drifting traces) and Metabolomics_2 (89 -> 0). Closes OpenMS#10905.
ef9ce08 to
d4b46df
Compare
|
Hi @timosachsenberg and @jpfeuffer, Following your feedback, I updated the implementation so that drift prevention is completely parameter less by default. The apex tolerance envelope is now derived automatically as Multi-Dataset Benchmark:
Pushed the update to this branch! |
|
Thanks! How did you ensure it? We require testing on large real life datasets (not only the test data in the repo). E.g. a minimum 10 real life datasets that have the issue, where you can confirm that this solves the tracing AND (most importantly) does not deteriorate the quantifications (e.g. coefficient of variation, number of features etc.). Will close until a full analysis is done. Thanks again |
|
Hi @timosachsenberg, That makes complete sense. Given the impact on downstream quantification and CVs, requiring a large scale statistical validation across real world biological datasets is absolutely the right call. As I am still new to the mass spectrometry domain, I don't currently have a local repository of 10+ real life datasets to run that level of biological validation. I will leave the C++ parameter-less implementation parked on this branch in case the core team wants to use it as a baseline for that future analysis! Thanks for the guidance and the deep architectural reviews on this learned a ton about the engine. I'll pivot to some other open issues to keep contributing! |
…TraceDetection
Add advanced parameter 'max_apex_deviation_ppm' to constrain peak excursion relative to the initial seed apex m/z during trace extension This prevents unanchored centroid walking into neighboring isotope channels (e.g. the 1.24 Th drift observed on Metabolomics_2.mzML in #10905) Defaults to -1.0 (disabled) to preserve existing behavior Added unit test in MassTraceDetection_test.
Fixes #10905
Fixes #10905
Description
Addresses the runaway$m/z$ drift in
MassTraceDetectionduring trace extension.Because
isPeakAcceptable_checked a window centered around a movingcentroid_mzwithout anchoring to the seed apex, weak tailing points could drag the search window into neighboring isotope channels across dozens of scans (e.g. the 1.20 Th drift observed onMetabolomics_2.mzML).Changes:
apex_mzintoisPeakAcceptable_to evaluate an apex-anchored tolerance envelope.max_apex_deviation_ppm(default:-1.0to preserve backward compatibility).isPeakAcceptable_rejects them, allowing consecutive missed scans to terminate the trace naturally.MassTraceDetection_test.cpp.Validation on
doc/pyopenms/src/data/Metabolomics_2.mzML:max_apex_deviation_ppm = 60.0, traces drifting0.0193to0.0142(median from0.00089to0.00072).2.34sto1.78s.Checklist
AI use (see the OpenMS AI Policy)
Co-authored-by:trailer, and the description above explains the design intent and rationale