Repository navigation
Conversation
…er reset_algorithm) Percolator's PSM-level FDR control fails when one peptide produces several spectra (Freestone, Noble, Keich 2024). Percolator-RESET (Freestone, Käll, Noble, Keich, J Proteome Res 2025; percolator/percolator#378) controls the FDR at the peptide level. Its core (pseudo-targets, the decoy fraction, the null-target win probability, dropping the training decoys) is already in the vendored tree at eb157f7; its driver lives in upstream's Caller.cpp and CompositionSorter.cpp, which are not vendored. - Percolator::rescore(): new parameter reset_algorithm (default false). It ports the driver of upstream master a90106b: best-single-feature scores, the best row of each RescoreInput::peptide_keys entry (peptides in the order of first appearance, upstream e9a2b60c), one coin per kept decoy (PseudoRandom, in that order), one fold with 3 nested bins, no mix-max (upstream 68ec0058). RescoreOutput gets reset_roles and per-row RESET peptide q-values/PEPs; rows outside the final list are scored by the final model. rescorePSMs() fills the peptide keys for it. - Vendored backports: patch 36 (upstream b8e59a02, decoy factor of the spline PEP) and patch 37 (one fold: no division by zero, as upstream 6068e7e2). No change of results without RESET. The pin stays at eb157f7; UPSTREAM.md explains why. - Tests: Percolator_test checks RESET's q-values (2 (D_est + 1) / T), roles, reproducibility and thread independence; a binary-gated section of Percolator_subprocess_parity_test compares with percolator --reset-algorithm (a90106b: same kept rows and estimating decoys, score r 0.999). - pyOpenMS: RescoreOutput.reset_roles. Co-authored-by: Claude Opus 5.5 <[email protected]>
timosachsenberg
left a comment
There was a problem hiding this comment.
Focused static review of the new reset_algorithm path and vendored Percolator TDC/selection logic. One substantive finding supported by a compiled standalone C++20 reproducer (not a complete OpenMS integration test).
| const bool use_pi0 = resolveUsePi0(impl_->use_pi0, impl_->post_processing_tdc, input); | ||
| // Percolator-RESET (parameter 'reset_algorithm'): no mix-max, as the executable, whose RESET keeps the best PSM of each | ||
| // peptide in a Scores object without pi0 (and is not stopped by its mix-max check, upstream 68ec0058) | ||
| const bool reset = impl_->reset_algorithm; |
There was a problem hiding this comment.
[P2] Do not silently apply spectrum-level TDC to RESET's peptide representatives. post_processing_tdc defaults to true (Percolator.cpp), and the unconditional if (impl_->post_processing_tdc) all_scores.weedOutRedundantTDC() later in rescore() still runs after selectResetRepresentatives() and cv.postIterationProcessing(). RESET has already selected one representative per peptide key, but weedOutRedundantTDC() instead keeps only one score holder per (specFileNr, scan, expMass) regardless of peptide key/label. Thus two different selected peptides from the same spectrum compete again; in particular, an estimating decoy can be removed by a higher-scoring target, changing the decoy counts and peptide-level q-values from the upstream --reset-algorithm semantics. The new parity test assigns a distinct scan to every row and cannot detect this. Please explicitly handle this option for RESET (at minimum avoid silently enabling the extra competition by default, and test multiple peptide keys sharing a scan). Own check: compiled and ran an isolated C++20 reproducer using the exact OrderScanMassCharge / UniqueScanMassCharge comparison rules and the sort+unique sequence from Scores::weedOutRedundantTDC(): three selected peptide representatives (target and estimating decoy at the same scan/mass, plus another peptide) were reduced to two, dropping the estimating decoy. This verifies the TDC pruning mechanism only, not a full OpenMS build or peptide q-value integration test; container has GCC/CMake but cannot access GitHub over DNS for a checkout.
|
Follow-up review of 9cb5b33. Based on reading the diff, the surrounding Summary: the patches are current and the port is faithful, but the option is not yet correct for all our input types. It is safe for existing users (off by default, every change gated on Patches and upstream
Problems
Smaller items
This review was prepared with Claude (AI-assisted). Generated by Claude Code |
…et:in_rescore) New parameter reset:in_rescore (default false): with algorithm 'reset', rescore(RescoreInput) runs the native PercolatorReset (as rescorePSMs() with algorithm 'reset'; all reset:* parameters apply, incl. two-decoy mode) instead of Percolator. New optional RescoreInput fields search_scores, stems and decoy_sets; the competition unit is the row's (spec_file_numbers, scan_numbers) / cv_group_keys as for the CV folds. Output: PSM-level scores/q/PEP, stem q-values in peptide_q_values, roles in reset_roles, full output via getResetOutput(). Default behaviour and interface unchanged: without reset:in_rescore, rescore() uses Percolator as before (also with algorithm 'reset'). rescoreReset_ is split into input building and runReset_ (shared). Test: rescore() matches rescorePSMs() RESET bit for bit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
There have been quite some changes to percolator. maybe good idea to rebase our internal patch set on it and work from there |
|
yeah, I think thats a good idea. This just came up from "your" review of #10920 which flagged the percolator issue. |
|
@poshul what about the native in OpenMS that is already there? Did this not work? |
NASE calls rescore(RescoreInput), whereas native RESET was dispatched through rescorePSMs(). I'm gonna close this and try again with the newer Percolator version that is in your open PR |
Description
Makes Percolator-RESET available in the in-process
OpenMS::Percolator::rescore(RescoreInput), in two opt-in ways. Both are off by default, so the existing interface, behaviour and test references are unchanged:reset_algorithm: upstream Percolator's RESET, ported from the percolator executable's--reset-algorithm.reset:in_rescoretogether withalgorithm=reset: OpenMS's nativePercolatorResetfrom [FEATURE] Percolator: exact parallel rescoring, Newton solver, RESET, feature matrix from PSMs #10772. Until now it was available only throughrescorePSMs().Why. Percolator's PSM-level FDR control fails when one peptide produces several spectra, some of which end up in the training folds and some in the test fold (Freestone, Noble, Keich 2024, Re-investigating the correctness of decoy-based FDR control). An entrapment check on NASE RNA data reproduced this: more entrapment hits were accepted than decoys, and they clustered on a few repeated oligos. Percolator-RESET (Freestone, Käll, Noble, Keich, J Proteome Res 2025; bioRxiv 10.1101/2023.10.26.564068; upstream percolator/percolator#378, rel-3-07) is the published fix. It keeps the best PSM of each peptide and splits the winning decoys at random into training decoys and estimating decoys. The estimating decoys count as targets during the training and are used to estimate the FDR. NASE rescoring (OpenMS/OpenMS#10920) will be the first user; this PR does not change NASE.
What was synced, and why the pin stays at eb157f7.
LabelType::PSEUDO_TARGET, the decoy fraction inScores::createXvalSetsBySpectrum, the null-target win probability (q-values with a decoy factor of 2), andCrossValidation::postIterationProcessing, which drops the training decoys. The driver (Caller::run --reset-algorithm,CompositionSorter::psmsOnly) is not vendored. Those files read the PSMs' peptide strings, and the wrapper uses those strings for row ids. The wrapper therefore ports the driver of upstream master a90106b (2026-11-13), which includes the November RESET fixes:Scores.cpp(+1337/−291),CrossValidation.cpp,SetHandler.cpp,SanityCheck.cppandPosteriorEstimator.cpp, and removeResultHolder,LoggerandScoreHolder.cpp, so all 35 OpenMS patches would have to be redone. Instead, the RESET fixes that touch vendored code are two new patches:patches/36-reset-pep-decoy-factor.patch(b8e59a02): the spline PEP (pep_method nonparametric) applies the decoy factor. The factor is exactly 1 without RESET.patches/37-cv-one-fold.patch(as upstream 6068e7e2): divides bymax(1, numFolds - 1). RESET trains on one fold, and there this was a division by zero.UPSTREAM.mddocuments all of this.sync-from-upstream.sh eb157f7applies all 37 patches cleanly.Design of the option (
Percolator.cpp:selectResetRepresentatives,resetOutput):RescoreInput::peptide_keys, which already exists. The keys are label-blind, as upstream keys by the peptide string only.SanityCheck::getInitDirection);PseudoRandom::lcg_uniform_rand() > 0.5, in the order of the kept rows, so the result is reproducible for a fixedseedand independent of the number of threads;decoysPerTargetat 1.--composition-matchis not ported.subset_max_train,subset_modeandpeptide_leveldo not apply whenreset_algorithmis on.RescoreOutput:q_values/pepsare set on the ranked rows only (targets and estimating decoys; 1 elsewhere);peptide_q_values/peptide_pepsgive the RESET values of each row's peptide key;reset_rolesis new: 0 target, 1 estimating decoy, 2 training decoy, the same values asPercolatorReset::Role;rescorePSMs()fills the peptide keys when the option is on.RescoreOutput.reset_roles.Native
PercolatorResetinrescore()(reset:in_rescore, opt-in). OpenMS's own RESET (algorithm=reset, #10772) supports stems, two-decoy mode, MLP and multiple rounds. It used to run only throughrescorePSMs(), because it needs per-PSM inputs thatRescoreInputdid not carry: a search engine score, the unmodified sequence (stem), the spectrum and, for two-decoy mode, the decoy database.RescoreInputgains the optional fieldssearch_scores,stemsanddecoy_sets(empty by default; ignored unless the option is on).spec_file_numbers,scan_numbers), elsecv_group_keys, else the row itself, the same keys asrescore()'s cross-validation folds (makeRowKeys).algorithm=resetandreset:in_rescore=true,rescore()runsPercolatorReset::run()with allreset:*parameters.scores/q_values/pepsare its PSM-level (heuristic) values.peptide_q_valuesholds the FDR-controlled stem q-value of each row;peptide_pepsstays empty, because the native RESET estimates no stem-level PEP.reset_rolesholds the roles, andgetResetOutput()returns the full output.reset:in_rescore,rescore()uses Percolator as before, also withalgorithm=reset(that is the documented behaviour, and the test checks it).reset_algorithmandreset:in_rescoretogether throw.rescoreReset_is split into building the input fromPeptideIdentifications and a sharedrunReset_(options, logging, weights,getResetOutput()). TherescorePSMs()path is unchanged.RescoreInput.search_scores,stemsanddecoy_sets.Tests
Percolator_test, new section, on a synthetic set of 1500 peptides with 1–4 PSMs each:min(1, 2 (D_est + 1) / T), monotonized;Percolator_test, second new section (reset:in_rescore): 900 PSMs are built into aRescoreInputwithbuildPSMRescoreInput.rescore()with the option matchesrescorePSMs()withalgorithm=resetbit for bit (scores, PSM q-values and PEPs, stem q-values, roles, salt). Withalgorithm=resetbut without the option,rescore()gives the same result as plain Percolator. Missing or shortsearch_scores/stems, two-decoy mode withoutdecoy_sets, and both RESET options together all throw.Percolator_subprocess_parity_test, newPERCOLATOR_BINARY-gated section, compares withpercolator --reset-algorithmon the same PIN. Against a90106b (built locally):--reset-algorithmskip the section.ctest -R Percolator: all 46 tests pass locally (Linux, GCC, Release).Not verified / known issues
def_rwfields; pyOpenMS is not configured in my build) and Windows/macOS builds were not run.PERCOLATOR_BINARYset, the existing section "realistic idXML parity at library layer" ofPercolator_subprocess_parity_testfails atmax_dpep <= 0.15(line 1218). It fails the same way on the unmodified code with a locally built eb157f7 binary, so it predates this PR. With the a90106b binary it also failsr >= 0.99.sync-from-upstream.sh eb157f7no longer reproducesCrossValidation.cpp. The nested-parallel fallback of [FEATURE] Percolator: nested pair loop in the OpenMP 2.0 fallback of trainFoldChains (cl.exe builds, follow-up to #10772) #10792 was committed without a patch. This also predates this PR and is not fixed here.Checklist
AI use (see the OpenMS AI Policy)
Co-authored-by:trailer, and the description above explains the design intent and rationaleNo need to edit the CHANGELOG file: entries are generated automatically once per week from merged changes.
🤖 Generated with Claude Code