Repository navigation
Improve isotope/adduct RT grouping for low-intensity mass traces (#4483) - #9711
Conversation
Low-intensity isotope and adduct mass traces are much shorter in RT than the intense monoisotopic/[M+H]+ trace, so the previous RT-overlap criteria (which measured against the longer/union RT range) failed to group them. FeatureFindingMetabo::scoreRT_: - Measure the RT overlap against the shorter co-eluting trace instead of the longer one, i.e. require the shorter trace to lie almost entirely within the longer trace. The threshold is exposed as the advanced parameter 'min_isotope_rt_overlap' (default 0.95). - Additionally require the apex of the longer trace to fall within the RT range of the shorter trace. MetaboliteFeatureDeconvolution: - Add advanced parameter 'rt_overlap_reference' to select the reference for the RT overlap fraction: 'union' (historic behavior, default) or 'shorter' (divide by the shorter feature's RT range) to group adducts with strongly differing intensities/elution widths. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01M1W3i5Pc8zT4GYfQQ8NVwT
|
@timosachsenberg The following names might be missing from the
Please consider applying the following patch: --- AUTHORS 2026-07-07 05:35:34.273588631 +0000
+++ AUTHORS.new 2026-07-07 05:35:39.322715679 +0000
@@ -25,6 +25,7 @@
- Chris Bielow
- Christian Ehrlich
- Christie Mathews
+ - Claude
- Clemens Groepl
- Cornelia Friedle
- Daniel Jameson |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds configurable RT-overlap reference modes for isotope grouping and adduct candidate pruning, replacing fixed overlap normalization with parameterized longer-or-shorter span checks. ChangesRT overlap grouping fixes
Sequence Diagram(s)sequenceDiagram
participant FeatureFindingMetabo
participant scoreRT_
participant Params
FeatureFindingMetabo->>Params: read min_isotope_rt_overlap
FeatureFindingMetabo->>scoreRT_: score trace pair
scoreRT_->>scoreRT_: choose longer_trace and shorter_trace
scoreRT_->>scoreRT_: compute overlap vs selected reference length
scoreRT_->>scoreRT_: require apex RT inside shorter trace range
scoreRT_-->>FeatureFindingMetabo: score or 0.0
sequenceDiagram
participant MetaboliteFeatureDeconvolution
participant candidateEdges_
participant Params
MetaboliteFeatureDeconvolution->>Params: read rt_overlap_reference
MetaboliteFeatureDeconvolution->>candidateEdges_: evaluate feature pair
candidateEdges_->>candidateEdges_: derive reference_length
candidateEdges_->>candidateEdges_: compare overlap ratio to min_rt_overlap
candidateEdges_-->>MetaboliteFeatureDeconvolution: keep or skip candidate
Related issues: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/openms/source/ANALYSIS/DECHARGING/MetaboliteFeatureDeconvolution.cpp (1)
461-474: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winNo test coverage for
rt_overlap_reference = "shorter".The existing regression test (
MetaboliteFeatureDeconvolution_test.cpp) exercises only the default"union"behavior. Given the edge case above, a test covering the"shorter"option (including a narrow/point-like feature) would help catch regressions.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/source/ANALYSIS/DECHARGING/MetaboliteFeatureDeconvolution.cpp` around lines 461 - 474, Add regression coverage in MetaboliteFeatureDeconvolution_test.cpp for the rt_overlap_reference = "shorter" path in MetaboliteFeatureDeconvolution, since only the default union behavior is currently tested. Create a case that sets rt_overlap_use_shorter via the relevant deconvolution configuration and includes a narrow or point-like feature so the shorter-reference overlap logic is exercised, then assert the expected grouping/deconvolution result.src/openms/include/OpenMS/FEATUREFINDER/FeatureFindingMetabo.h (1)
268-282: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winscoreRT_ Doxygen doc is now stale.
The doc still states "the overlap between the two peaks at FHWM needs to exceed a certain threshold. The threshold is set at 0.7 (i.e. 70 % overlap) as also described in Kenar et al." The implementation now uses a configurable
min_isotope_rt_overlap_(default 0.95) measured against the shorter trace, plus a new apex-containment requirement. Consider updating the doc to reflect the new behavior so future readers aren't misled.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/include/OpenMS/FEATUREFINDER/FeatureFindingMetabo.h` around lines 268 - 282, Update the Doxygen for scoreRT_ in FeatureFindingMetabo to match the current scoring logic: remove the outdated fixed 0.7 FHWM overlap description and document that the overlap is now checked against the configurable min_isotope_rt_overlap_ threshold (default 0.95) relative to the shorter trace, along with the new apex-containment requirement. Keep the summary aligned with the actual behavior so readers understand the current conditions under which scoreRT_ computes retention time similarity.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/openms/source/ANALYSIS/DECHARGING/MetaboliteFeatureDeconvolution.cpp`:
- Around line 461-474: The RT overlap check in MetaboliteFeatureDeconvolution
should fail closed when rt_overlap_use_shorter selects a zero-width reference.
In the overlap logic around reference_length, use the existing feature hull
bounds from f1 and f2 to detect degenerate RT length and reject the pair instead
of skipping the check when reference_length is 0.0, matching the zero-length
handling in FeatureFindingMetabo::scoreRT_.
---
Nitpick comments:
In `@src/openms/include/OpenMS/FEATUREFINDER/FeatureFindingMetabo.h`:
- Around line 268-282: Update the Doxygen for scoreRT_ in FeatureFindingMetabo
to match the current scoring logic: remove the outdated fixed 0.7 FHWM overlap
description and document that the overlap is now checked against the
configurable min_isotope_rt_overlap_ threshold (default 0.95) relative to the
shorter trace, along with the new apex-containment requirement. Keep the summary
aligned with the actual behavior so readers understand the current conditions
under which scoreRT_ computes retention time similarity.
In `@src/openms/source/ANALYSIS/DECHARGING/MetaboliteFeatureDeconvolution.cpp`:
- Around line 461-474: Add regression coverage in
MetaboliteFeatureDeconvolution_test.cpp for the rt_overlap_reference = "shorter"
path in MetaboliteFeatureDeconvolution, since only the default union behavior is
currently tested. Create a case that sets rt_overlap_use_shorter via the
relevant deconvolution configuration and includes a narrow or point-like feature
so the shorter-reference overlap logic is exercised, then assert the expected
grouping/deconvolution result.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: faa67de0-0810-4f24-a2c2-ae11c720bc54
📒 Files selected for processing (3)
src/openms/include/OpenMS/FEATUREFINDER/FeatureFindingMetabo.hsrc/openms/source/ANALYSIS/DECHARGING/MetaboliteFeatureDeconvolution.cppsrc/openms/source/FEATUREFINDER/FeatureFindingMetabo.cpp
…T_ docs
- MetaboliteFeatureDeconvolution: when 'rt_overlap_reference' is 'shorter' and
a feature has a zero-width RT hull, reject the pair instead of skipping the
overlap check (fail closed), matching the zero-length handling in
FeatureFindingMetabo::scoreRT_.
- FeatureFindingMetabo: update the stale scoreRT_ Doxygen to describe the
shorter-trace overlap ('min_isotope_rt_overlap') and apex-containment criteria.
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01M1W3i5Pc8zT4GYfQQ8NVwT
The shorter-trace overlap + apex-containment logic changed the default output
of FeatureFindingMetabo, breaking FeatureFindingMetabo_test and the
TOPP_FeatureFinderMetabo_{1,5,6}_out reference tests.
Gate the new logic behind the advanced parameter 'isotope_rt_overlap_reference'
(values 'longer'/'shorter', default 'longer'), mirroring the 'rt_overlap_reference'
switch already used in MetaboliteFeatureDeconvolution. With the default 'longer'
and 'min_isotope_rt_overlap' = 0.7, scoreRT_ reproduces the historic behavior
exactly (overlap / longer trace < 0.7). Setting it to 'shorter' enables the
shorter-trace normalization and apex-containment check from issue #4483.
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01M1W3i5Pc8zT4GYfQQ8NVwT
|
The initial commit made the improved isotope grouping the default, which changed I've refactored so both improvements are opt-in and the defaults reproduce the historic behavior exactly (isotope: Open question for you: do you want the Generated by Claude Code |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/openms/source/FEATUREFINDER/FeatureFindingMetabo.cpp (1)
662-672: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valueInconsistent zero-length guard between the two branches.
The new
shorterbranch guards againstmin_length == 0(Line 681:(min_length > 0.0) ? (overlap / min_length) : 0.0), but the historiclongerbranch'soverlap / max_length(Line 666) has no equivalent guard. If both traces have a degenerate zero-length FWHM,0.0 / 0.0yieldsNaN, andNaN < min_isotope_rt_overlap_evaluates tofalse, so the RT filter would be silently bypassed instead of rejecting the pair. This is pre-existing behavior now made more visible by branching, and the edge case is rare (FWHM is normally a small positive interpolated value), so it's low priority, but worth aligning for consistency.🛡️ Optional consistency fix
// Historic behavior: the overlap must exceed the given fraction of the // longer trace (default 0.7, i.e. 70 %, as described in Kenar et al.). - double proportion(overlap / max_length); + double proportion = (max_length > 0.0) ? (overlap / max_length) : 0.0; if (proportion < min_isotope_rt_overlap_) { return 0.0; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/openms/source/FEATUREFINDER/FeatureFindingMetabo.cpp` around lines 662 - 672, The RT-overlap check in FeatureFindingMetabo::computeCosineSim_ has an inconsistent zero-length guard between the shorter and longer branches, so align the historic longer-trace path with the safer handling used in the shorter path. Update the branch that computes proportion from overlap/max_length to explicitly handle max_length == 0 before comparing against min_isotope_rt_overlap_, using the same zero-safe pattern already present in the shorter branch, so degenerate traces are rejected consistently instead of producing NaN-based bypass behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/openms/source/FEATUREFINDER/FeatureFindingMetabo.cpp`:
- Around line 662-672: The RT-overlap check in
FeatureFindingMetabo::computeCosineSim_ has an inconsistent zero-length guard
between the shorter and longer branches, so align the historic longer-trace path
with the safer handling used in the shorter path. Update the branch that
computes proportion from overlap/max_length to explicitly handle max_length == 0
before comparing against min_isotope_rt_overlap_, using the same zero-safe
pattern already present in the shorter branch, so degenerate traces are rejected
consistently instead of producing NaN-based bypass behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1a78cb46-3e6d-42da-9a97-94810233971c
📒 Files selected for processing (2)
src/openms/include/OpenMS/FEATUREFINDER/FeatureFindingMetabo.hsrc/openms/source/FEATUREFINDER/FeatureFindingMetabo.cpp
Guard the historic 'longer' overlap path against a zero-length reference (overlap / max_length) the same way the 'shorter' path already does, so a degenerate pair with zero FWHM is rejected instead of bypassing the RT filter via NaN comparison. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01M1W3i5Pc8zT4GYfQQ8NVwT
PR #9711 (RT-overlap reference options for isotope/adduct mass-trace grouping, fixes #4483) merged without a CHANGELOG entry. Co-authored-by: Claude <[email protected]>
Description
Fixes #4483.
Low-intensity isotope and adduct mass traces are usually much shorter in RT than the intense monoisotopic /
[M+H]+trace. The previous RT-overlap criteria measured the overlap against the longer trace (isotope grouping) or the union of both RT ranges (adduct grouping), so these genuine peaks were often rejected — the union/longer length is dominated by the long, intense trace while the intersection is bounded by the short one. This is especially relevant for metabolites containing Cl, F, Br, etc.Both changes are opt-in and default to the historic behavior, so existing results and reference tests are unchanged (see the note at the bottom).
FeatureFindingMetabo::scoreRT_(isotope grouping)isotope_rt_overlap_reference(longer|shorter, defaultlonger):longer— historic behavior: overlap must be ≥min_isotope_rt_overlapof the longer trace.shorter— overlap is measured against the shorter trace, and additionally the apex of the longer trace must fall within the RT range of the shorter trace. This groups low-intensity isotope traces that are much shorter than the monoisotopic trace.min_isotope_rt_overlap(default0.7, range[0, 1]) exposes the overlap threshold that was previously hard-coded to0.7. Withisotope_rt_overlap_reference=shorter,0.95–0.99is recommended (per the issue discussion).MetaboliteFeatureDeconvolution(adduct grouping)rt_overlap_reference(union|shorter, defaultunion):union— historic behavior (intersection / union of both RT ranges).shorter— intersection / shorter feature RT range, which groups adducts with strongly differing intensities/elution widths (e.g. an intense[M+H]+and a weak[M+Na]+). Fails closed for degenerate zero-width features.Checklist
🤖 Generated with Claude Code
Summary by CodeRabbit