Skip to content

fix(PIPECHO): revive dead mass-error feature and drop raw/inverted RT from mbr_score - #9674

Merged
timosachsenberg merged 1 commit into
developfrom
fix/pipecho-mass-rt-features
Jun 27, 2026
Merged

timosachsenberg merged 1 commit into
developfrom
fix/pipecho-mass-rt-features

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

fix(PIPECHO): revive the dead mass-error feature and drop raw/inverted RT from mbr_score

Summary

On real ProteomicsLFQ data, PIP-ECHO (-pip_echo true) produced zero
match-between-runs transfers at every FDR cutoff. Two of its three scoring
features were broken; the recently-merged #9661 SimpleSVM fix exposed it (the
old behaviour rode on a feature-index-misalignment bug that manufactured spurious
separation). This PR fixes the two feature bugs.

How it was found

Replicating the PXD016921 single-cell blank-leakage benchmark (the quantms
#287 dataset) on landed develop:
PIP-ECHO transferred 0 features at fdr = 0.01 / 0.05 / 0.10. Bisection
pinned the change to #9661; instrumenting the per-feature target/decoy AUC on real
data showed no feature separated (mass 0.50, intensity 0.52, RT 0.49). That
led to the two root causes below.

Root causes

1. mass_error was a dead (constant) feature

RunStatistics::init_mass_error calibrates a donor mass-error distribution via
Util::feature_mass_error, which computed getPPM(feature.getMZ(), theoretical).
But FeatureFinderIdentification seeds the feature's position m/z to the
peptide's theoretical m/z
, so this is identically 0 for every donor. The
distribution is degenerate → calc_score_using returns a constant MIN_SCORE
for every acceptor → SimpleSVM logs Predictor 'mass_error' is uninformative
and drops it.

The real observed mass accuracy is already computed and stored on the feature as
the masserror_ppm meta (the OpenSWATH DIA mass-difference score,
getPPM(observed, theoretical) per isotope) — but ProteomicsLFQ strips it
before grouping.

Fix: whitelist masserror_ppm in keep_meta, and read it in
feature_mass_error (monoisotopic-first; the -1 "no signal" sentinel matched
exactly so genuinely-negative errors are kept; precursor-m/z then feature-m/z
fallbacks). This mirrors FlashLFQ, which calibrates its ppm distribution from the
observed mass errors of identified peaks.

2. rt_diff_error was raw and inverted in mbr_score

The geometric-mean mbr_score multiplied in the raw absolute RT difference
(0–1200+ s, so it dominates the product by magnitude) with inverted
monotonicity
— a larger RT error increased the score. Because mbr_score
drives best-acceptor selection and the round-1 bootstrap seed, this corrupted
both. On pre-aligned runs the in-window decoys share the targets' RT range, so RT
is also a weak discriminator here.

Fix: drop RT from the mbr_score geomean (it is still handed to the SVM as a
feature). A correctly calibrated RT-agreement score is deferred to #9655 (see
below).

Results (PXD016921, Blank = empty run, direct-ID floor 93 peptides)

config transfers (fdr=0.05) realized FDR Blank Δpep 100-cell Δpep
develop 0 — 0 0
this PR 1280 ~5.2% +2 +392

PIP-ECHO now performs genuine FDR-controlled MBR: transfers concentrate in the
data-rich runs (100-cell +888, 20-cell +317 features) while the empty Blank stays
clean (+4 transfers → +2 peptides). The FDR knob behaves monotonically
(Blank 65→98, sensitivity rising) — driven by real mass signal, not an SVM
artifact. The donor calibration is now Normal(+1.91 ppm, 1.20), matching the
acceptor target population (+1.49 ppm).

Validation

  • PipEchoAlgorithm_test and PipEchoAlgorithm_realistic_test (slow): pass.
  • The keep_meta change is output-neutral: masserror_ppm is dropped at the
    consensus level (FeatureHandle is not a MetaInfoInterface), so it never
    reaches the consensusXML. The default pip_echo=false path is unchanged.
    (Worth confirming TOPP_ProteomicsLFQ_* in CI.)

Scope / honesty

This recovers the mass signal; it is not FlashLFQ-level MBR. The OpenMS
port still scores only 3 of FlashLFQ's 5 features — the strongest
discriminators (isotopic-distribution similarity and MS1 scan count) are absent,
and RT is dropped rather than properly calibrated. An RT attribution run shows the
raw-RT variant is more sensitive (2048 vs 1280 at fdr=0.05) but leaks 2× into
the Blank (8 vs 4) via that arbitrary magnitude-dominating term — so RT does carry
signal and should be added back calibrated, not kept raw. All of this is
tracked in #9655.

Files

  • src/topp/ProteomicsLFQ.cpp — keep_meta += "masserror_ppm"
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/Util.cpp — feature_mass_error reads masserror_ppm
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/RunStatistics.cpp — drop raw RT from the mbr_score geomean

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved mass error handling to prefer the most reliable source, including per-isotope values when available, with safer parsing and fallback behavior when metadata is missing or invalid.
    • Adjusted bootstrap scoring so retention-time agreement is excluded from that calculation, aligning the score with the intended input signals.
    • Ensured mass error metadata is preserved during feature processing when pip_echo is enabled, preventing it from being dropped before downstream steps.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0861abd7-f38b-4b5b-a0f7-a8cb3a07fbcb

📥 Commits

Reviewing files that changed from the base of the PR and between f04bb33 and 515d372.

📒 Files selected for processing (3)
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/RunStatistics.cpp
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/Util.cpp
  • src/topp/ProteomicsLFQ.cpp
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/topp/ProteomicsLFQ.cpp
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/Util.cpp
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/RunStatistics.cpp

📝 Walkthrough

Walkthrough

The PR updates PIPECHO mass-error handling so masserror_ppm metadata is preserved, feature_mass_error prefers metadata and peptide-identification values when needed, and RunStatistics::score now excludes RT from the bootstrap product.

Changes

PIPECHO mass-error flow and bootstrap scoring

Layer / File(s) Summary
Mass-error retention and lookup
src/topp/ProteomicsLFQ.cpp, src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/Util.cpp
ProteomicsLFQ::quantifyFraction_ keeps masserror_ppm during metadata cleanup, and Util::feature_mass_error now prefers stored masserror_ppm values before falling back to peptide-identification-derived PPM.
Bootstrap score RT exclusion
src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/RunStatistics.cpp
RunStatistics::score now computes the MBR bootstrap product from intensity and mass error only, with the RT term removed from the geometric mean and the comment updated accordingly.

Sequence Diagram(s)

sequenceDiagram
  participant ProteomicsLFQ as "ProteomicsLFQ::quantifyFraction_"
  participant Util as "Util::feature_mass_error"
  participant PeptideIdentification
  ProteomicsLFQ->>Util: preserve masserror_ppm metadata
  Util->>Util: read stored masserror_ppm values
  Util->>PeptideIdentification: fall back when metadata is absent
  PeptideIdentification-->>Util: observed m/z, sequence, charge
Loading

Suggested reviewers

  • jpfeuffer

Poem

A bunny I am, with ears so keen,
I sniff masserror_ppm where it’s been.
RT hops aside; mass and intensity sing,
And I bounce through PIPECHO with a tidy spring 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main changes: restoring the mass-error feature and removing RT from the MBR score.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pipecho-mass-rt-features

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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/MAPMATCHING/PIPECHO/Util.cpp`:
- Around line 64-85: The `Util.cpp` handling of `masserror_ppm` currently
assumes `errs.front()` is the monoisotopic error without verifying the
producer’s ordering contract. Trace the code path that calls
`setMetaValue("masserror_ppm", ...)` (especially `dia_massdiff_score` in
`DIAScoring`) and confirm whether index 0 is guaranteed to be the monoisotopic
isotope; if not, replace the `front()` shortcut with an explicit monoisotopic
check against the theoretical m/z or remove the assumption and use the
validated/ordered values only.
🪄 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: 31bdd535-c561-436e-aca9-6fd3485bfa1d

📥 Commits

Reviewing files that changed from the base of the PR and between 480d3eb and f04bb33.

📒 Files selected for processing (3)
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/RunStatistics.cpp
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/Util.cpp
  • src/topp/ProteomicsLFQ.cpp

… from mbr_score

PIP-ECHO's transfer-FDR SVM produced ZERO match-between-runs transfers on real
ProteomicsLFQ data (PXD016921 single-cell, quantms#287) at every FDR cutoff.
Root cause: two of its three scoring features were broken, which the #9661
SimpleSVM fix exposed (it previously rode on a feature-index-misalignment bug).

mass_error was DEAD. RunStatistics calibrates the donor mass-error distribution
via Util::feature_mass_error, which computed getPPM(feature.getMZ(), theoretical).
But FeatureFinderIdentification seeds the feature's position m/z to the peptide's
THEORETICAL m/z, so this is identically 0 for every donor: the calibration
distribution is degenerate, calc_score_using returns a constant MIN_SCORE, and
SimpleSVM drops the feature as uninformative. The real observed mass accuracy is
carried in the feature's "masserror_ppm" meta (the OpenSWATH DIA mass-difference
score = getPPM(observed, theoretical) per isotope), which ProteomicsLFQ stripped
before grouping. Fix: whitelist "masserror_ppm" in keep_meta ONLY on the pip_echo
path (it is needed solely by PIP-ECHO; keeping it on the default QT-linker path leaks
it into the consensusXML/mzTab output and shifts the TOPP_ProteomicsLFQ references),
and read it in
feature_mass_error (monoisotopic-first; -1 is a "no signal" sentinel matched
exactly, so genuinely negative errors are kept; precursor-m/z then feature-m/z
fallbacks). This mirrors FlashLFQ, which calibrates its ppm distribution from the
observed mass errors of identified peaks.

rt_diff_error was RAW and INVERTED in the geometric-mean mbr_score: it multiplied
in the raw absolute RT difference (0-1200+ s, magnitude-dominating) with inverted
monotonicity (a larger RT error increased the score), poisoning best-acceptor
selection and the round-1 bootstrap. Drop RT from the geomean (it is still given
to the SVM as a feature). A faithful calibrated RT-agreement score (FlashLFQ's
anchor-peptide RT prediction-error distribution) is a follow-up; see #9655.

Effect on the PXD016921 benchmark: PIP-ECHO goes from 0 transfers at every FDR to
FDR-controlled MBR -- at PipEcho:fdr=0.05, 1280 transfers at ~5% realized FDR,
adding +392 peptides to the deep run while the empty Blank stays clean (+2). Both
PipEchoAlgorithm tests pass; the keep_meta change is output-neutral (masserror_ppm
is dropped at the consensus level, so the default pip_echo=false path is unaffected).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@timosachsenberg
timosachsenberg force-pushed the fix/pipecho-mass-rt-features branch from f04bb33 to 515d372 Compare June 27, 2026 04:17
@timosachsenberg
timosachsenberg merged commit da10ab4 into develop Jun 27, 2026
41 checks passed
@timosachsenberg
timosachsenberg deleted the fix/pipecho-mass-rt-features branch June 27, 2026 05:24
timosachsenberg added a commit that referenced this pull request Jun 29, 2026
…O fixes) (#9677)

Documents two PIP-ECHO improvements merged on 2026-06-27:
- #9674: revive dead mass_error feature and drop raw/inverted RT from mbr_score
- #9676: isotope-distribution envelope correlation as a new SVM-only MBR feature


Claude-Session: https://claude.ai/code/session_01GRoRx9TnjaBjfuBWT8umia

Co-authored-by: Claude <[email protected]>
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.

1 participant