Skip to content

Initial PIP-ECHO implementation - #9647

Merged
timosachsenberg merged 29 commits into
developfrom
pjones/pip-echo
Jun 25, 2026
Merged

timosachsenberg merged 29 commits into
developfrom
pjones/pip-echo

Conversation

@pjones

@pjones pjones commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

I am opening a draft PR so others (@timosachsenberg) can see what I did.

Summary by CodeRabbit

  • New Features

    • Added PIP-ECHO-based run matching for feature grouping and exposed it in the command line and Python interface.
    • Added support for ion-mobility-aware matching and confidence scoring in transfer-between-runs results.
    • Improved protein search settings reporting with more reliable metadata conversion.
  • Bug Fixes

    • Tightened transfer filtering to better control false discoveries and preserve valid donor identifications.
    • Fixed metadata cleanup and filtering behavior for downstream quantification outputs.
  • Documentation

    • Expanded developer guidance for internal implementation headers.

@pjones
pjones force-pushed the pjones/pip-echo branch from e614fb5 to f685377 Compare June 22, 2026 11:16
timosachsenberg

This comment was marked as outdated.

timosachsenberg

This comment was marked as outdated.

@timosachsenberg

Copy link
Copy Markdown
Contributor

@pjones — two changes in ProteomicsLFQ.cpp look like they may be unintended side effects of the refactor/reformat rather than deliberate. Together they account for all 28 failing TOPP_ProteomicsLFQ_* tests — and those run with pip_echo=false, so the new PIP-ECHO code isn't even exercised. Could you confirm whether each was intentional?

1. targeted_only is now always false (line 1044)

const bool targeted_only = getStringOption_("targeted_only") != "false" && getStringOption_("pip_echo") != "false";

main_() already throws if both targeted_only and pip_echo are non-"false", so this && can never be true → -targeted_only true is silently ignored (every run takes the untargeted seeding path). If the intent was just to force untargeted seeding when pip_echo is on, the plain getStringOption_("targeted_only") != "false" is enough — the validation already guarantees pip_echo ⇒ targeted_only=false.

2. QT linker RT tolerance narrowed (line 654)

The else (QT) branch now sets distance_RT:max_difference = max_alignment_diff, dropping the previous 2.0 * max_alignment_diff + 2.0 * median_fwhm (and median_fwhm is now an unused parameter of link_). That changes the default, non-PIP-ECHO linking window for all multi-run quantification. Intentional, or should the QT path keep 2·max_alignment_diff + 2·median_fwhm? (Separately: should the PIP-ECHO branch use the same widened window, or is the tighter one deliberate there?)

If these were accidental, I'm happy to push the one-line fixes — suggested diffs are in the inline review.

@pjones

pjones commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@timosachsenberg Yep, 1 is a complete mistake, no idea what happened there. And 2 was caused by a rebase and I guess me not paying attention. The max_alignment_diff variable had a different name and when I rebased I didn't see the logic involving median_fwhm. I'm not sure what happened there.

Please feel free to fix these. Sorry for the trouble.

@timosachsenberg

Copy link
Copy Markdown
Contributor

no worries. Totally expected. I asked for a draft ;)
I can try to fix the easy ones that don't need confirmation

@timosachsenberg

Copy link
Copy Markdown
Contributor

we previously split header and cpp files in OpenMS into separate folders.
Should we move to this layout in the future?
Should I reorgnizte them to match current folder structure?

# Conflicts:
#	src/topp/ProteomicsLFQ.cpp
@pjones

pjones commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

we previously split header and cpp files in OpenMS into separate folders. Should we move to this layout in the future? Should I reorgnizte them to match current folder structure?

I put the headers for the internal classes in the source directory to indicate they are not public. But I don't have strong feelings about this either way.

Address the team review on #9647. Two regressions in the default
ProteomicsLFQ path (root cause of the red TOPP_ProteomicsLFQ_* CI), plus
correctness/UB/determinism fixes in the new PIP-ECHO algorithm. All
confirmed by the PR author.

Default ProteomicsLFQ path (CI-critical):
- targeted_only was forced always-false by an && with pip_echo; restore it
- RT linking window lost the 2*max_alignment_diff + 2*median_fwhm term in a
  rebase; restore it (both the QT and PIP-ECHO branches, per author)

PIP-ECHO algorithm:
- k-fold CV trained on the held-out fold (groups[i] -> groups[j]) -> leakage
- ppm computed with *1e-6 instead of *1e6; use Math::getPPM
- sort comparator used a 0.01 epsilon band (not a strict weak ordering -> UB)
- HashGrid neighbor search: Int64 - size_t underflowed and skipped cells;
  make the neighbors parameter signed (Int64)
- nearby() double-counted the home cell; skip it in the neighbor loop
- RunStatistics: abs() the signed RT delta (pow of a negative -> NaN), and
  compute the acceptor mass error against the donor's sequence/charge
- non-deterministic std::srand/std::rand per call -> a single seeded
  std::mt19937 owned by Impl, with a new "random_seed" parameter
- decoy transfers no longer leak into the quantitative consensus output
- PIP-ECHO m/z default was 10 Da; default to ppm to match the QT linker
- replace a release-mode assert that could deref an empty optional
- catch SimpleSVM exceptions so PEP failure falls back to MBR scores
- drop a duplicate path-based Util.h include; add missing direct includes

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@timosachsenberg

timosachsenberg commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Pushed fixes for all confirmed review items to pjones/pip-echo (after merging current develop in — one trivial include conflict, plus a develop-side build-speedup that had trimmed a transitive ListUtils.h include Pep.cpp relied on).

✅ Verified

  • All 64 TOPP_ProteomicsLFQ_* tests pass (g++-13, local) without touching any reference file — empirically confirming the two driver regressions were the sole cause of the red CI (the missing develop commits touch nothing in ProteomicsLFQ's tests/refs/logic).
  • A -pip_echo true smoke run on the BSA example data completes cleanly (no crash / NaN), exercising the SVM→MBR fallback and decoy exclusion.

Fixed — default ProteomicsLFQ path (CI-critical)

  • targeted_only always-false — dropped the && pip_echo clause.
  • RT linking window — restored 2·max_alignment_diff + 2·median_fwhm; per your note, applied to both the QT and PIP-ECHO branches.

Fixed — PIP-ECHO algorithm

  • CV leakage — groups[i] → groups[j].
  • ppm — now uses signed Math::getPPM (was *1e-6).
  • sort SWO — exact pep_score equality instead of the 0.01 band.
  • grid underflow — nearby()'s neighbors parameter is now Int64 (your suggested approach), so the bound arithmetic is signed.
  • home-cell double-count — nearby() now skips the home cell in the neighbor loop (it was double-counted into find_random_donor's accumulator).
  • RT score NaN — std::abs on the signed RT delta (your line-111 fix).
  • acceptor mass error — computed against the donor's sequence/charge (acceptors are unidentified), as you noted.
  • RNG — single std::mt19937 owned by Impl, seeded once from a new random_seed parameter (replaces per-call srand(time())/rand).
  • decoy leak — decoy transfers are no longer inserted into the quantitative consensus output (FDR-only).
  • m/z default — PIP-ECHO now defaults to ppm (was 10 Da).
  • release-mode assert — replaced with a MissingInformation throw (it could deref an empty optional under NDEBUG).
  • SVM exceptions — Pep::run now catches them and falls back to MBR scores instead of aborting the tool.
  • Dropped a duplicate path-based Util.h include; added missing direct includes (ListUtils.h, MathFunctions.h).

Deferred

  • Decoy semantics (Impl.cpp:139-168) — reviewed, confirmed by-design (not a bug): find_random_donor's mass-shift legitimately picks an unrelated donor whose RT seeds an RT-decoy at the original m/z. Left as-is; worth a one-line confirm from @pjones.
  • const_cast on const FeatureMap& (Impl.cpp:108) — still open. In practice safe (inputs are never truly const); a proper fix means copying the feature maps. Left documented for @pjones.
  • CMake header registration (PIPECHO/sources.cmake) — fixed in 4544549: the impl headers were registered into OpenMS_sources_h, which includes.cmake resets after the source phase (so the line was inert), and OpenMS_private_sources_h is consumed as include dirs. Now registered on the master OpenMS_sources list (IDE listing only, not compiled).
  • Tests — added PipEchoAlgorithm_test in 4544549 (first test PIP-ECHO has had): construction, name, parameter defaults (ppm m/z default + random_seed), and a synthetic two-run group() asserting a non-empty consensus and reproducible output across runs (guards the seeded RNG). A FuzzyDiff TOPP test was skipped — the only pip_echo-capable example data (BSA) is degenerate (acceptor count below the SVM minimum), so a deterministic class test is the robust choice.

Reviewed by Claude Opus + Codex (two independent passes each on the findings and the fixes).

timosachsenberg and others added 3 commits June 23, 2026 11:26
Low-severity follow-ups from the post-fix review:
- correct the rng_ comment: a shared std::mt19937 is reproducible for the
  current single-threaded decoy search but is NOT thread-safe
- count only inserted targets in acceptors_seen so the "added N acceptors"
  log no longer includes skipped decoys
- use std::fabs (not std::abs) for the RT delta, matching the rest of the file
  and avoiding the <cstdlib> int overload if <cmath> ever drops transitively
- make the local neighbors Int64 to match nearby()'s new signed parameter

Co-Authored-By: Claude Opus 4.8 <[email protected]>
- sources.cmake: the PIPECHO private impl headers were registered into
  OpenMS_sources_h, which includes.cmake resets after the source phase (so
  the line was inert) and OpenMS_private_sources_h is consumed as include
  dirs. Register them on the master OpenMS_sources list instead (IDE listing
  only; not compiled).
- Add PipEchoAlgorithm_test: construction, name, parameter defaults (ppm m/z
  default + random_seed), and a synthetic two-run group() that asserts a
  non-empty consensus and reproducible output across runs (guards the seeded
  RNG). PIP-ECHO previously had no class or TOPP test.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Record the source map index and MBR q-value for each transferred target
acceptor, then attach them to the corresponding consensus feature as the
mbr_transfer_map_indices / mbr_transfer_qvalues meta values. This exposes
match-between-runs transfer provenance downstream.

Extend PipEchoAlgorithm_test to set fdr=1.0 (so transfers occur) and verify
the new meta values are present, parallel, and carry the expected values.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01M9hTADeVDDftuEaATDxhsX
@timosachsenberg

timosachsenberg commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

found by claude:
@pjones — while building a larger-scale, ground-truth test for the MBR path I think I hit two coupled bugs in the randomized-RT decoy generation. The net effect is that decoys are essentially never produced, so the transfer FDR is almost never estimable and the conservative fallback drops all transfers on any realistic dataset (which also explains why the existing tests only ever see 0 decoys / q = 0.5). Both are visible from the code alone; the PIP-ECHO paper confirms the intended behaviour. Wanted to lay it out so you can judge for yourself.

Reference: Improved Detection of Differentially Abundant Proteins through FDR-Control of Peptide-Identity-Propagation (PIP-ECHO), J. Proteome Res. 2025, doi:10.1021/acs.jproteome.5c00065; preprint bioRxiv 2024.11.15.623880 (methods via PMC12488043).

Bug 1 — decoy match window anchored at the wrong RT

Impl::find_acceptor_for() re-centers the grid search at the randomized RT:

const double rt = rt_override.value_or(donor.feature.getRT());
const AcceptorMap::grid_center_t center(rt, donor.feature.getMZ());

…but Acceptor::is_donor_compatible() checks the RT tolerance against the donor's true RT:

std::fabs(donor.feature.getRT() - this->feature.getRT()) <= window.rt_tol

By construction the randomized RT is far from the donor RT — find_random_donor() only accepts a randomized donor with rt_diff > rt_min_diff = window.rt_tol * 2. So for a decoy the grid is searched around the randomized RT while the predicate only accepts acceptors within rt_tol of the donor's true RT, i.e. a region the search is centered ≥ 2*rt_tol away from. The two conditions are mutually exclusive in the common case → a decoy is essentially never found.

Paper: the window "anchored at the randomized RT" has "the same window size" as the predicted-RT window, and a trace is eligible when its apex RT is within that window — i.e. the decoy RT tolerance should be applied around the randomized RT, not the donor's true RT.

Bug 2 — decoy RT-difference feature computed against the wrong RT

RunStatistics::score() computes the RT feature against the donor's true RT for every candidate:

rt_diff_error = std::fabs(acceptor.getRT() - donor.getRT())

A decoy acceptor lives near the randomized RT (≥ 2*rt_tol from the donor's true RT), so every decoy gets an artificially huge rt_diff_error while every target gets a small one. That value is fed straight to the SVM (Pep.cpp encodes rt_diff_error as a predictor), so the target/decoy label leaks into the feature, the classifier separates the classes trivially, and the PEP/q-values become meaningless (they collapse to a single value).

Paper: the scoring features are "mass error, intensity, difference between observed and predicted/randomized retention time, …"; for a decoy the RT difference is the deviation from the randomized RT, not the true predicted RT.

Proposed fix

  • Acceptor::is_donor_compatible() and RunStatistics::score() each take an optional donor_rt_override; for decoys the RT tolerance / RT-difference feature is measured against the randomized RT. find_acceptor_for() forwards rt_override.
  • In score() the override affects only rt_diff_error — mass error and intensity are properties of the donor identity and the acceptor trace and are left as-is.
  • Targets pass nullopt → unchanged.

Evidence (synthetic 10k-feature / 3-run ground-truth set)

  • Before: 2387 target transfers, ~0 decoys → FDR not estimable → all transfers dropped; q-values degenerate.
  • After: ~93 decoys; the SVM/PEP path runs; at fdr=0.05, 2462 transfers kept (2307 correct / 155 false vs. ground truth), realised FDR ≈ 0.06, ~97% of recoverable transfers recovered, q-values non-degenerate (58 distinct); deterministic with a fixed seed.

The existing PipEchoAlgorithm_test still passes and ProteomicsLFQ is unaffected (pip_echo defaults to false).

Minor follow-up (not changed)

link_donors_and_acceptors() breaks the window-expansion loop as soon as a target or a decoy is found, so target and decoy searches don't expand their windows fully independently — a small deviation from the paper, not required for correct FDR behaviour now that decoys generate. Flagging for a later look.

Happy to be wrong on any of this — let me know if I've misread the intent.

@timosachsenberg

Copy link
Copy Markdown
Contributor

Follow-up: I cross-checked the FlashLFQ reference implementation (the PIP-ECHO paper's own code), and it confirms both points line-for-line. The engine now lives in mzLib (smith-chem-wisc/mzLib, master, under mzLib/FlashLFQ/), not the FlashLFQ repo.

Bug 1 — decoy search window is anchored at the randomized RT (FlashLfqEngine.cs:1177-1178, inside FindAllAcceptorPeaks):

double rtStartHypothesis = randomRt == null ? rtInfo.RtStartHypothesis : (double)randomRt - (rtInfo.Width / 2.0);
double rtEndHypothesis   = randomRt == null ? rtInfo.RtEndHypothesis   : (double)randomRt + (rtInfo.Width / 2.0);

For a decoy the window is [randomRt − Width/2, randomRt + Width/2] — centered on the randomized RT, same width. Our port centers the grid at the randomized RT but then re-checks is_donor_compatible against the donor's true RT, so the decoy almost never falls inside the accepted window.

Bug 2 — the RT feature is scored against the randomized RT (FlashLfqEngine.cs:1284 → MbrScorer.cs:305):

// FlashLfqEngine.cs:1284
acceptorPeak.MbrScore = scorer.ScoreMbr(acceptorPeak, donorPeak, randomRt ?? rtInfo.PredictedRt);
// MbrScorer.cs:305
acceptorPeak.RtPredictionError = predictedRt - acceptorPeak.ApexRetentionTime;

i.e. the RT-prediction-error feature uses randomRt for decoys (the peak is even constructed with randomRt as its predicted RT and the decoy flag, FlashLfqEngine.cs:1261). Our RunStatistics::score() used the donor's true RT for all candidates, so decoys got an artificially huge RT error and the SVM separated the classes trivially.

For context, the rest of the port matches the reference closely, which is why these two stood out as isolated omissions:

  • GetRandomPeak (FlashLfqEngine.cs:822-868): 5×H … 11×H mass window, |ΔRT| > retentionTimeMinDiff, different BaseSequence, ×10 mass-window expansion on miss — same as our find_random_donor.
  • Gate mbrPeaks.Count > 100 && decoyPeakTotal > 20 (:1406) — same as our MIN_TOTAL_ACCEPTORS = 100 / MIN_DECOYS = 20.
  • The decoyPeptides / decoyPeaks / doubleDecoys hybrid competition (:1460-1466) — same as our compute_qvalues.

(One non-bug difference: FlashLFQ scores five features as 100·geomean^0.2; our port uses three as 100·geomean^(1/3) — a deliberate simplification, not a defect.)

So the fix in the commit above just restores the randomRt anchoring in the two places the port dropped it, matching upstream FlashLFQ.

@timosachsenberg

Copy link
Copy Markdown
Contributor

Note: the port scores 3 of FlashLFQ/PIP-ECHO's 5 features (relevant to MBR FDR calibration under co-elution)

Not a bug — a calibration/quality observation while validating the MBR FDR path against quantms#303.

What I checked. Using the synthetic ground-truth harness (PipEchoAlgorithm_realistic_test), I compared naive transfer (no FDR control, fdr=1.0) vs fdr=0.05 on the same engine/data. In the realistic regime the transfer FDR is controlled and behaves as designed (realized ≈ 6.8% at nominal 5%, conservative drop at unresolvable cutoffs, non-degenerate q-values). I could only push realized FDR well past nominal (20–29%) by injecting interfering ions at a real peptide's exact m/z and RT — i.e. false transfers that are observationally identical to true ones. That's uncatchable by any decoy-based MBR FDR, so it's not a defect here.

Grounding. The randomized-RT decoy null is a faithful port of FlashLFQ (FlashLfqEngine.cs, mzLib), and the paper states it "assumes incorrect matches are equally likely at predicted vs. randomized RTs, which may not capture systematic interference from co-eluting species at the same m/z." On real entrapment data the published method is well-calibrated (1.0% realized at 1% nominal, beating FlashLFQ v1.0 / IonQuant / MaxQuant) — because real interferers differ in isotope pattern and elution profile, which the classifier exploits.

The one port-specific gap. The published classifier uses 5 features — mass error, intensity, RT difference, isotopic distribution, and # MS1 scans with valid envelope. This port scores 3 (RunStatistics::score(): intensity, rt_diff_error, mass_error, combined as 100·(·)^(1/3) with measures = 3.0; the SVM in Pep.cpp::encode is fed exactly those three). The two dropped features are precisely the ones that best distinguish a co-eluting interferer from a true transfer, so the port is somewhat more exposed to in-window interference than the published method.

Suggestion. Keep as-is for now (the 3-feature model controls FDR in the benign regime), but if real-data calibration ever drifts above nominal, restoring isotopic-distribution similarity and MS1-scan/envelope count is the highest-leverage fix — and brings the port back in line with the paper's 5-feature model. Worth a // TODO near measures = 3.0.

timosachsenberg and others added 3 commits June 25, 2026 09:12
…hen present)

Adds ion mobility (IM) as an optional 4th match-between-runs scoring feature,
active only when the data carries it. IM_median/IM_min/IM_max already survive
ProteomicsLFQ's feature strip, so this needs no upstream re-plumbing (unlike the
isotope/scan-count features in #9655).

When IM is present the geometric-mean MBR bootstrap score becomes a 4th root
(measures 3->4) and an IM predictor is added to the SVM; when absent the
behaviour is byte-identical to the previous 3-feature scoring (the realistic
synthetic-FDR test is numerically unchanged: 2462 transfers / 155 false /
realized FDR 0.0629).

- Util: feature_ion_mobility (reads "IM_median"; falls back to
  Constants::UserParam::IM = "IM" for Biosaur2) + feature_im_width.
- RunStatistics: per-acceptor-run IM tolerance (zero-mean normal, sigma =
  median donor IM width / 2); calc_im_score = two-tailed CDF of the
  donor/acceptor IM difference. Decoys use the donor's real IM (the decoy RT
  override does not affect IM, mirroring mass_error).
- Score/Pep: new im_diff_score; the SVM IM predictor column is gated
  all-or-nothing so the predictor columns stay rectangular.
- ProteomicsLFQ: keep "IM" and "n_scans" through the feature strip
  (forward-compat for a direct-Biosaur2 path; no-op for FFID features).
- Test: PipEchoAlgorithm_test section asserting the IM-matching acceptor wins
  over an otherwise-identical mismatched-IM competitor.

Reviewed by Claude Opus + Codex (tag team). Fixed from that review: IM is now a
global, all-or-nothing decision across all runs (was decided per pair), so the
shared SVM mbr_score predictor and the fallback q-value ordering stay on one
scale. Two pre-existing bugs surfaced and filed separately rather than fixed
here: SummaryStatistics/quantile crash on exactly 2 values (#9659), and
SimpleSVM::predict misaligns feature indices for a train-constant predictor
(#9661).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Clean up the private file/header layout introduced with PIP-ECHO so it
matches OpenMS conventions, plus follow-up fixes:

- CMake: replace the dead OpenMS_private_sources_h var with a documented
  OpenMS_private_headers mechanism (private headers listed for IDEs only,
  never installed/exported); revert PRIVATE_INCLUDES to empty since the
  IsoSpec/eol-bspline targets already propagate their include dirs.
- Drop the per-directory .clang-format fork (80->150 col) and mk-clang-format.sh.
- Use <OpenMS/...> for public headers, quotes for local private headers.
- Give file-local helpers internal linkage via anonymous namespaces; notably
  mz_range was previously in the public OpenMS namespace.
- Rename the ambiguous Pep class to TransferFDRModel (PosteriorErrorProbability-
  Model already exists in OpenMS) and add a class doc comment.
- Document the private-implementation-header convention in the developer
  coding conventions.
- PipEchoAlgorithm.h: add @brief/@InGroup and group() param/@pre docs, mark the
  destructor override, and register the class with DefaultParamHandlerDocumenter
  so the @htmlinclude parameters table resolves.
- Normalize the copyright preamble to the standard OpenMS header.
- Correct the misleading getMaxMZ() comment in mz_range (it throws only on an
  un-updated range; the const maps here cannot be updated in place).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Expose PipEchoAlgorithm to pyOpenMS as a FeatureGroupingAlgorithm subclass
(constructor, group(list[FeatureMap], ConsensusMap), the inherited
transferSubelements, and the DefaultParamHandler API), mirroring the sibling
feature-grouping algorithm bindings.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@timosachsenberg

Copy link
Copy Markdown
Contributor

Real-data validation: single-cell MBR blank-leakage benchmark (quantms #287 / PXD016921)

I validated the PIP-ECHO MBR on the single-cell HeLa dilution PXD016921 — the dataset behind quantms issue bigbio/quantms#287 ("more proteins are misquantified in blank sample"), which motivated the MBR-FDR request in bigbio/quantms#303.

Why this dataset: the design has a Blank run (no cells loaded) in the same fraction as 4 single-cell, a 20-cell and a 100-cell run, so every run is an MBR candidate. Only 93 peptides survive PSM-level FDR filtering in the Blank — so any identified peptide quantified there above that floor is a false transfer. The Blank is a built-in transfer-FDR readout.

Setup (reproducible): PRIDE publishes the converted mzML + FDR-filtered idXML for this reanalysis, so no raw download or search is needed. Ran current ProteomicsLFQ four ways, holding everything constant except the MBR treatment (-targeted_only false, exact …-202210 DB, PEP promoted to main score via IDScoreSwitcher): -pip_echo false (baseline) and -pip_echo true -PipEcho:fdr {0.01, 0.05, 0.10}. Compared against the published old-quantms ProteomicsLFQ output (the #287 baseline). All numbers parsed from the resulting consensusXML.

Identified peptides quantified per run (Blank floor = 93 direct IDs)

config Blank pep Blank prot single-cell pep (∪ of 4) 100-cell pep consensus groups
published old-quantms (#287 result) 1071 632 4930 12401 52 344
standard MBR (pip_echo=false) 108 169 5739 13435 46 155
PIP-ECHO fdr=0.01 63 118 5604 11874 19 403
PIP-ECHO fdr=0.05 64 119 5615 11878 19 403
PIP-ECHO fdr=0.10 76 135 5643 11931 19 403

Findings

  • Save 3D view as image [287] #287 reproduces: old-quantms puts 1071 peptides / 632 proteins into an empty blank (~978 false transfers).
  • PIP-ECHO drives blank transfer to ≈0: at fdr=0.01 the Blank holds 63 identified peptides — below the 93 direct-ID floor, i.e. essentially nothing transferred. ~17× less than the historical result.
  • Sensitivity preserved: PIP-ECHO recovers 5604 single-cell peptides — ~98 % of the pip_echo=false baseline (5739), and more than old-quantms recovered (4930).
  • FDR knob is monotonic: 0.01 → 0.10 raises both blank leakage (63 → 76) and sensitivity (5604 → 5643) — a controllable specificity/sensitivity trade-off.
  • PIP-ECHO forms ID-anchored consensus (19 403 groups, nearly all identified) vs the baseline's 46 155 (many unidentified-feature groups), so configs are best compared at the identified-peptide level (*_pep columns).

Caveats

  • Blank protein counts are inflated by shared-peptide protein grouping (e.g. 118 proteins from only 63 peptides); the peptide column is the honest false-transfer metric.
  • The current pip_echo=false baseline (108) is already far cleaner than 2023 quantms (1071) — standard ProteomicsLFQ MBR improved since Save 3D view as image [287] #287 — so PIP-ECHO's dramatic win is vs the historical result; vs today's baseline it adds principled transfer-FDR control plus ~40 % less residual blank leakage at ~98 % sensitivity.
  • Unrelated bug noticed: every config (including pip_echo=false) crashes in the streaming mzTab exporter (DataValue Int→string, DataValue.cpp:635 ← ProteomicsLFQ.cpp:1923) after writing the consensusXML, so no mzTab/MSstats is produced on this data. Pre-existing and independent of PIP-ECHO, but worth a separate fix.
  • LIBSVM is not bit-reproducible across platforms, so counts may shift by a few peptides on re-run.

timosachsenberg and others added 2 commits June 25, 2026 19:28
getSearchEngineSettingsAsPairs() built a std::string pair member directly from
params.getMetaValue(key). Since the String class was removed,
DataValue::operator std::string() is strict and throws on any non-string type.
The first Int setting (e.g. Comet:missed_cleavages=2) therefore threw
"Could not convert non-string DataValue of type 'Int'", crashing ProteomicsLFQ's
streaming mzTab export (MzTabFile::store(ConsensusMap) -> CMMzTabStream ->
mapBetweenRunAndSearchEngines_) after the consensusXML had already been written.

Convert explicitly with StringUtils::toStr(), matching the other settings in the
same function. Adds a ProteinIdentification_test regression covering Int/Double/
String settings (the method was previously untested).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_016rawZsiVUCJjzyXTqkkrWK
@timosachsenberg
timosachsenberg marked this pull request as ready for review June 25, 2026 20:33
@timosachsenberg
timosachsenberg merged commit 600f3f0 into develop Jun 25, 2026
42 checks passed
@timosachsenberg
timosachsenberg deleted the pjones/pip-echo branch June 25, 2026 20:34
@timosachsenberg

Copy link
Copy Markdown
Contributor

Good enough for broader testing…

timosachsenberg added a commit that referenced this pull request Jun 25, 2026
…ics on small inputs (#9659) (#9664)

Math::quantile1st/quantile3rd took the median of an empty half for input
ranges of size 1 or 2, throwing Exception::InvalidRange. Math::SummaryStatistics
calls both unconditionally and inherited the crash (e.g. a ProteomicsLFQ
acceptor run with exactly 2 donor features aborted via PIP-ECHO, PR #9647).

- quantile1st: return the minimum for size < 3 (the lower half is empty);
  quantile3rd: return the maximum. This matches the median-of-halves
  convention and is continuous with the method's own size-3 and size-4
  results, which already yield min/max.
- SummaryStatistics: variance divides by (n-1) and is undefined for a single
  value; report 0.0 (as in the empty case) instead of a silent NaN now that
  the quantile calls no longer throw for n==1.
- Add StatisticFunctions_test coverage for quantile1st/quantile3rd at
  n = 1..4 and empty, plus a new SummaryStatistics section (previously
  untested).

The n>=3 code path is unchanged, so the pinned quantile values and downstream
reference outputs are unaffected.

Co-authored-by: Claude Opus 4.8 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a9f88d72-06f4-4c69-91cc-23066626589c

📥 Commits

Reviewing files that changed from the base of the PR and between 80a1854 and 328b60e.

📒 Files selected for processing (32)
  • doc/doxygen/parameters/DefaultParamHandlerDocumenter.cpp
  • doc/doxygen/public/developer_coding_conventions.doxygen
  • src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/PipEchoAlgorithm.h
  • src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/sources.cmake
  • src/openms/includes.cmake
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/FeatureTypes.cpp
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/FeatureTypes.h
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/GridWithStorage.h
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/Impl.cpp
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/Impl.h
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/MzDiff.h
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/Run.cpp
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/Run.h
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/RunStatistics.cpp
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/RunStatistics.h
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/Score.h
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/TransferFDRModel.cpp
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/TransferFDRModel.h
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/Util.cpp
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/Util.h
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/Window.h
  • src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/sources.cmake
  • src/openms/source/ANALYSIS/MAPMATCHING/PipEchoAlgorithm.cpp
  • src/openms/source/ANALYSIS/MAPMATCHING/sources.cmake
  • src/openms/source/METADATA/ProteinIdentification.cpp
  • src/pyOpenMS/bindings/bind_misc.cpp
  • src/tests/class_tests/openms/CMakeLists.txt
  • src/tests/class_tests/openms/executables.cmake
  • src/tests/class_tests/openms/source/PipEchoAlgorithm_realistic_test.cpp
  • src/tests/class_tests/openms/source/PipEchoAlgorithm_test.cpp
  • src/tests/class_tests/openms/source/ProteinIdentification_test.cpp
  • src/topp/ProteomicsLFQ.cpp

📝 Walkthrough

Walkthrough

This PR adds the PIP-ECHO feature-grouping pipeline, its scoring and transfer-FDR machinery, public wiring, tests, and ProteomicsLFQ support for selecting it and adjusting downstream filtering. It also updates ProteinIdentification search-parameter metadata stringification.

Changes

PIP-ECHO pipeline and ProteomicsLFQ integration

Layer / File(s) Summary
Core value types and utilities
src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/{Window.h, Score.h, MzDiff.h, Util.h, Util.cpp}
Window, Score, MzDiff, and feature utility helpers for peptide hits, decoy detection, mass error, and ion mobility are added.
Feature identity and run storage
src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/{FeatureTypes.h, FeatureTypes.cpp, GridWithStorage.h, Run.h, Run.cpp}
Feature-reference wrappers, donor and acceptor types, grid-backed storage, and donor/acceptor routing per run are added.
Scoring and transfer FDR
src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/{RunStatistics.h, RunStatistics.cpp, TransferFDRModel.h, TransferFDRModel.cpp}
Run-level score distributions, pair scoring, and transfer-FDR filtering with SVM-based PEP and q-value handling are added.
Algorithm orchestration and packaging
src/openms/source/ANALYSIS/MAPMATCHING/PipEchoAlgorithm.cpp, src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/PipEchoAlgorithm.h, src/openms/source/ANALYSIS/MAPMATCHING/PIPECHO/{Impl.h, Impl.cpp, sources.cmake}, src/openms/source/ANALYSIS/MAPMATCHING/{sources.cmake,...}, src/openms/include/OpenMS/ANALYSIS/MAPMATCHING/sources.cmake, src/openms/includes.cmake, doc/doxygen/{parameters/DefaultParamHandlerDocumenter.cpp,public/developer_coding_conventions.doxygen}, src/pyOpenMS/bindings/bind_misc.cpp
The internal implementation, public PipEchoAlgorithm entry point, source registration, Doxygen generation, Python binding exposure, and private-header build support are added.
PIP-ECHO tests and slow-test wiring
src/tests/class_tests/openms/{CMakeLists.txt,executables.cmake}, src/tests/class_tests/openms/source/PipEchoAlgorithm_test.cpp, src/tests/class_tests/openms/source/PipEchoAlgorithm_realistic_test.cpp
Unit and realistic PipEchoAlgorithm tests are added, along with executable registration and slow-test timeout labeling.
ProteomicsLFQ selection and input handling
src/topp/ProteomicsLFQ.cpp
pip_echo is added as a linker option, linking can use PipEchoAlgorithm, and input validation, preprocessing, ID handling, and feature loading are updated.
ProteomicsLFQ quantification and FDR
src/topp/ProteomicsLFQ.cpp
Quant-score filtering, metadata cleanup, protein FDR application, and export/reporting behavior are adjusted.
ProteinIdentification metadata stringification
src/openms/source/METADATA/ProteinIdentification.cpp, src/tests/class_tests/openms/source/ProteinIdentification_test.cpp
Search-engine settings now stringify non-string meta values with StringUtils::toStr, and the Comet:* output is covered by tests.

Sequence Diagram(s)

sequenceDiagram
  participant PipEchoAlgorithm
  participant PipEchoImpl as "PipEcho::Impl"
  participant TransferFDRModel
  participant ConsensusMap
  PipEchoAlgorithm->>PipEchoImpl: group(feature_maps, consensus_map)
  PipEchoImpl->>PipEchoImpl: partition_features(...)
  PipEchoImpl->>PipEchoImpl: link_donors_and_acceptors(...)
  PipEchoImpl->>TransferFDRModel: run(fdr_cutoff)
  TransferFDRModel-->>PipEchoImpl: filtered acceptors
  PipEchoImpl->>ConsensusMap: generate_consensus_map(...)
Loading

Possibly related issues

  • OpenMS/OpenMS issue 9655: The ProteomicsLFQ changes keep IM and n_scans metadata while enabling pip_echo, matching the metadata-preservation part of the issue.

Possibly related PRs

  • OpenMS/OpenMS#9666: Both PRs change ProteinIdentification::getSearchEngineSettingsAsPairs() to stringify non-string meta values and add matching test coverage.

Suggested reviewers

  • jpfeuffer
  • timosachsenberg

Poem

A rabbit hopped through PIP-ECHO trails 🐇
With q-values sparkling like tiny veils.
I munched a carrot, then ran the test,
And found the consensus behaved its best.

✨ 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 pjones/pip-echo

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.

timosachsenberg added a commit that referenced this pull request Jun 26, 2026
Documents PRs that landed after the last CHANGELOG update (#9656):
- #9647 PIP-ECHO match-between-runs algorithm in ProteomicsLFQ
- #9666 ProteomicsLFQ mzTab crash on non-string search settings
- #9658 ProteinQuantifier wrong per-file split on merged ID runs (fixes #5518)
- #9664 Math::quantile1st/3rd crash on 1–2 element inputs (fixes #9659)


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

Co-authored-by: Claude <[email protected]>
timosachsenberg added a commit that referenced this pull request Jun 26, 2026
…setup() (#9661) (#9670)

* fix(SimpleSVM): align predict() feature indices with the trained model

SimpleSVM::predict(PredictorMap&) built the LIBSVM nodes by iterating the
prediction map by position (index = position + 1). But setup()/convertData_
drops predictors that are constant during training (vmin == vmax) and assigns
LIBSVM indices only to the remaining informative predictors, recorded in order
in predictor_names_. So a predictor that was constant during training -- and
therefore absent from the model -- but present at prediction time shifted every
later feature's index by one, silently producing wrong predictions (and, once
the shift ran past the model's feature count, crashes). Fixes #9661.

Build the prediction nodes over predictor_names_ (the trained feature set, in
the exact order convertData_ used), looking each predictor up by name.
Predictors present at prediction but not in the model are ignored; a trained
predictor missing at prediction now throws instead of misaligning.

Affects any SimpleSVM caller whose features can be constant within a training
fold but present at prediction -- e.g. PIP-ECHO's cross-validated transfer-FDR
SVM (surfaced during the #9647 review).

Adds a SimpleSVM_test regression: a model trained with a constant predictor
present at prediction must match one trained without it. The constant predictor
is placed mid-sort so it exercises predict()'s indexing (and not convertData_'s
observation-count seeding from the first predictor).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_016rawZsiVUCJjzyXTqkkrWK

* fix(SimpleSVM): don't size training data from a constant first predictor

A second manifestation of the constant-predictor handling, on the setup side:
scaleData_ empties constant predictors, then convertData_ took the observation
count from predictors.begin()->second.size(). When the alphabetically-first
predictor was constant (hence emptied), n_obs became 0, the node arrays were
sized to 0, and setup() crashed dereferencing nodes_[training_index][0].

Derive n_obs from the first NON-empty (informative) predictor, and throw
MissingInformation when every predictor is constant rather than building a
degenerate/empty model.

Extends the SimpleSVM_test regression: a constant predictor sorting first must
train and predict like a model that never saw it, and an all-constant input must
throw. Mechanism independently confirmed by a second analysis pass.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_016rawZsiVUCJjzyXTqkkrWK

* test(SimpleSVM): use TEST_TRUE for boolean assertions

Per the OpenMS coding guideline (and CodeRabbit review on #9670): prefer
TEST_TRUE(expr) over TEST_EQUAL(expr, true) for the iterator-equality checks in
the new constant-predictor regression sections.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_016rawZsiVUCJjzyXTqkkrWK

* fix(SimpleSVM): derive predict() observation count from a trained predictor

Codex review of #9670: predict(PredictorMap&) took n_obs from
predictors.begin(), which need not be a model feature -- the prediction map may
carry extra predictors (e.g. ones constant during training and dropped). With an
inconsistent-length first predictor that mis-sizes the loop and could read out of
bounds. Derive n_obs from the first TRAINED predictor (predictor_names_[0]) and
throw if it is missing or the model has no features.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_016rawZsiVUCJjzyXTqkkrWK

* fix(SimpleSVM): validate consistent observation counts across predictors

Codex review follow-up (#9670): close the remaining length-consistency gap.
setup() now rejects predictor vectors of differing lengths up front (otherwise
its n_obs could desync from the node arrays convertData_ sizes from the first
informative predictor, letting the outcome-index guard pass an index past
nodes_). predict() resolves each trained predictor once (also removing a
per-observation map lookup) and verifies every column shares the observation
count so the node loop cannot read past a shorter column. Adds a SimpleSVM_test
case for both.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_016rawZsiVUCJjzyXTqkkrWK

---------

Co-authored-by: Claude Opus 4.8 <[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.

2 participants