Repository navigation
Initial PIP-ECHO implementation - #9647
Conversation
The PIP-ECHO scoring system is built around per-run statistics which means we do in fact need to process the acceptors and donors by looping over "runs". This change introduces a new layer of abstraction and breaks apart the feature maps into runs that themselves contain acceptors and donors.
I refuse to use a column width of 150.
|
@pjones — two changes in 1. const bool targeted_only = getStringOption_("targeted_only") != "false" && getStringOption_("pip_echo") != "false";
2. QT linker RT tolerance narrowed (line 654) The If these were accidental, I'm happy to push the one-line fixes — suggested diffs are in the inline review. |
|
@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 Please feel free to fix these. Sorry for the trouble. |
|
no worries. Totally expected. I asked for a draft ;) |
|
we previously split header and cpp files in OpenMS into separate folders. |
# Conflicts: # src/topp/ProteomicsLFQ.cpp
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]>
|
Pushed fixes for all confirmed review items to ✅ Verified
Fixed — default ProteomicsLFQ path (CI-critical)
Fixed — PIP-ECHO algorithm
Deferred
Reviewed by Claude Opus + Codex (two independent passes each on the findings and the fixes). |
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
|
found by claude: Reference: Improved Detection of Differentially Abundant Proteins through FDR-Control of Peptide-Identity-Propagation (PIP-ECHO), J. Proteome Res. 2025, Bug 1 — decoy match window anchored at the wrong RT
const double rt = rt_override.value_or(donor.feature.getRT());
const AcceptorMap::grid_center_t center(rt, donor.feature.getMZ());…but std::fabs(donor.feature.getRT() - this->feature.getRT()) <= window.rt_tolBy construction the randomized RT is far from the donor RT — 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
rt_diff_error = std::fabs(acceptor.getRT() - donor.getRT())A decoy acceptor lives near the randomized RT (≥ 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
Evidence (synthetic 10k-feature / 3-run ground-truth set)
The existing Minor follow-up (not changed)
Happy to be wrong on any of this — let me know if I've misread the intent. |
|
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 ( Bug 1 — decoy search window is anchored at the randomized RT ( 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 Bug 2 — the RT feature is scored against the randomized RT ( // 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 For context, the rest of the port matches the reference closely, which is why these two stood out as isolated omissions:
(One non-bug difference: FlashLFQ scores five features as So the fix in the commit above just restores the |
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 ( Grounding. The randomized-RT decoy null is a faithful port of FlashLFQ ( 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 ( 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 |
…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]>
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 Identified peptides quantified per run (Blank floor = 93 direct IDs)
Findings
Caveats
|
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
Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_016rawZsiVUCJjzyXTqkkrWK
|
Good enough for broader testing… |
…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]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (32)
📝 WalkthroughWalkthroughThis 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. ChangesPIP-ECHO pipeline and ProteomicsLFQ integration
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(...)
Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
✨ 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 |
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]>
…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]>
I am opening a draft PR so others (@timosachsenberg) can see what I did.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation