Repository navigation
Add optional Percolator rescoring to NASE - #10920
Conversation
First step towards in-process Percolator rescoring in NASE. Nothing uses the features yet, so search results are unchanged. - New RNARescoringFeatures builds one feature row per hit of a spectrum: native score, delta to the next different sequence and to the best hit, absolute ppm error, isotope offset, one-hot charge, length, modifications, adduct, per-series matched fractions, matched ions and intensity (shared peaks counted once), longest ion series, backbone coverage, plus optional route, graph-tag, diagnostic-ion and FLASH groups. Columns depend only on the options, so targets and decoys are described identically. - NASE separates the number of hits kept during the search from report:top_hits; postProcessHits_ trims to report:top_hits (keeping ties) after ambiguity resolution. Both are equal for now, so the trim is a no-op until rescoring raises the search depth. - Unit test with hand-computed values for every feature. Co-Authored-By: Claude Opus 5.5 <[email protected]>
New 'rescoring:' section (off by default). With rescoring:enable, the best native hit of every spectrum is rescored by Percolator on the RNARescoringFeatures rows, and the q-values are calculated on the Percolator score. The native score, percolator:score (MS:1001492) and percolator:PEP (MS:1001493) are reported. - One Percolator row per spectrum (its best native hit); the other retained hits (rescoring:top_hits, default 2) give only the score margin features. Feeding runner-ups as rows does not work for RNA: every target has an isobaric reversed decoy, so most spectra have a strong decoy runner-up. Without Percolator's target-decoy competition its training q-values and PEPs count those runner-ups; with it, the losing rows come back as score 0 / PEP 1, indistinguishable from real values. The order of the hits of a spectrum is therefore unchanged; hits tied at the best native score share its Percolator score and PEP, lower hits get none (and no q-value). - Falls back to the native score with a warning if fewer than rescoring:min_decoys (default 100) spectra have a decoy best hit (Percolator itself reports success on as few as two rows) or if Percolator throws. Requires fdr:decoy_pattern. - rescoring:seed, rescoring:out_features (TSV of features, label and Percolator score/q-value/PEP per rescored spectrum). - postProcessHits_ now sorts and resolves ambiguities for all spectra before rescoring, then registers the matches; calculateAndFilterFDR_ takes the ranking score type. Tests: - rescoring_fallback: the one-spectrum fixture with rescoring enabled falls back and reproduces NucleicAcidSearchEngine_12_out.mzTab. - rescoring: synthetic data, compared as mzTab and feature TSV. The data were generated with a throwaway program on OpenMS (NucleicAcidSpectrumGenerator, std::mt19937 seed 7): 110 unique random 8-12-mer targets (not palindromic) with reversed decoys (DECOY_ prefix) in the FASTA; one spectrum per target at charge -2 or -3 (alternating) with the target's a-B/c/w/y ions at fragment charges down to -(z-1), each kept with p=0.75 (p=0.3 and 40 instead of 15 random noise peaks for every third spectrum); and 260 poor spectra at target precursor masses with 25 random peaks plus fragments of the target or its decoy (coin flip) kept with p=0.15. Precursor m/z from NASequence::getMonoWeight(Full, -z) / z, negative polarity, stored as zlib-compressed mzML and gzipped. 357 spectra get hits, 135 with a decoy best hit; 85 targets pass 1% FDR versus 80 with the native score (Percolator keeps its best single feature on this small set, so the test covers the wiring, not the model). Co-Authored-By: Claude Opus 5.5 <[email protected]>
- README.rescoring.md and the doxygen page TOPP_NASE_Rescoring: usage, why only the best hit per spectrum is rescored (and what that means for ties and lower-ranked hits), the features and optional groups, output columns and the out_features TSV, fallback conditions, reproducibility, and limits (synthetic test data, reversed RNA decoys sharing fragments with their targets, entrapment as the check for FDR control). - The NASE tool page links to the new page. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s its model When Percolator's sanity check rejects the learned model, it scores with its best single feature. NASE used that score, which can rank far worse than the native one: on HAP1 clone1 rep3 searched against an entrapment database (targets + shuffled entrapment + shuffled decoys), a top-scoring decoy left no target at q < 1% on a held-out fold, and the single-feature score kept 16 / 102 / 329 spectra at 1% / 5% / 10% FDR, against 0 / 2,095 / 2,474 for the native score. NASE now falls back to the native score with a warning, as for too few decoys; the rerun reproduces the native counts exactly. Tests: - The previous synthetic set (110 identifiable + 260 poor spectra) is one on which Percolator rejects its model; it is renamed to NucleicAcidSearchEngine_rescoring_rejected.* and its rescored output must now equal a native run of the same data. - NucleicAcidSearchEngine_rescoring.* is a larger synthetic set on which Percolator trains a model: 330 identifiable + 330 poor spectra, same throwaway generator and seed as before (NucleicAcidSpectrumGenerator, std::mt19937 seed 7; 8-12-mer targets with reversed DECOY_ entries; a-B/c/w/y ions at charge -2/-3, kept with p=0.75, every third spectrum p=0.3 with 40 noise peaks; poor spectra with 25 random peaks plus target or decoy fragments kept with p=0.15). On it the trained model keeps fewer targets at 1% than the native score; the tests check the wiring, not the model. References regenerated from it. README and doxygen page document the new fallback case. Co-Authored-By: Claude Opus 5.5 <[email protected]>
New advanced option rescoring:train_fdr (default 0.01, unchanged behavior) sets Percolator's train_fdr and test_fdr together: the FDR at which it selects positive training examples and at which its sanity check accepts the learned model on held-out folds. At 0.01, Percolator rejected its model on all three HAP1 clone1 searches against an entrapment database (420 targets + 420 shuffled entrapment sequences + shuffled decoys of both), because a top-scoring decoy left no target at q < 1% on a fold. At 0.05 it trained on all three. Pooled over the three files, Percolator accepted 7,038 / 8,028 target spectra at 5% / 10% q-value against 6,405 / 7,597 for the native score, with combined entrapment FDP estimates of 4.4% / 8.8% (native: 4.0% / 7.6%). README and doxygen page describe the option. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The mzTab export numbers score columns in the order of the first exported match that has them, following the search software's assigned_scores. NASE assigned native score, q-value, Percolator score, PEP. Tied hits that the FDR calculation does not pick get no q-value, so when the exporter (which follows the address order of the matches) met such a hit first, the q-value moved to the last column. Two HAP1 searches of the same input exported different column orders with identical values; the positional TOPP mzTab comparison could fail at random. The q-value now comes last (native, Percolator score, PEP, q-value), so every match's scores are a subsequence of that order. Searches without rescoring keep their order (native, q-value). Reference regenerated; it differs from the previous one only in column order. 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 rescoring call path, RNARescoringFeatures, and Percolator/FDR consumers. I independently compiled and ran a C++20 (-O2) minimal benchmark of the feature builder's nested score-margin loops; it is a reproduction of that computational cost, not a full OpenMS build or integration test. The container has GCC/CMake but no OpenMS checkout and GitHub cloning fails DNS resolution.
| inputs.push_back(std::move(input)); | ||
| } | ||
| // All retained hits give the margins; only the best one is rescored. | ||
| scan_rows[scan_index] = std::move(builder.computeSpectrum(inputs, spectrum_input).front()); |
There was a problem hiding this comment.
[P2] Avoid quadratic work for hits whose feature rows are discarded. Only .front() is sent to Percolator, but computeSpectrum(inputs, ...) computes a complete feature row for every retained hit, and each row scans all retained hits to find delta_next. Thus -rescoring:top_hits 0 (or -report:top_hits 0), both supported ways to retain all hits, make rescoring O(H²) per spectrum and allocate H full feature rows although only one is used. This is additional cost introduced by this PR; the other hits are needed only as context for the top hit's margin. In an independently compiled C++20 -O2 minimal benchmark of these exact nested margin loops, 8,000 distinct hits require 64 million comparisons and ~178 ms for all rows, versus 8,000 comparisons and ~0.005 ms computing only the first margin (1,000 hits: ~3.8 ms versus ~0.0007 ms). These times are from the extracted loop, not an OpenMS run. Please compute only the best hit's feature row while still looking at all retained runner-ups for its margin; this avoids an avoidable quadratic blow-up on larger searches.
There was a problem hiding this comment.
Thanks, agreed. RNARescoringFeatures::computeRow(hits, index, spectrum) now builds only the rescored hit's row, scanning the other retained hits once for its margins (linear in the number of hits); NASE uses it instead of computeSpectrum(...).front(). computeSpectrum shares the row code and is documented as quadratic. A new unit test checks computeRow against every computeSpectrum row for several hit orders, including ties and a single hit. Outputs are unchanged: TOPP references pass as before, and a HAP1 clone1 rep1 run gives byte-identical feature rows and mzTab. Fixed in a0bad25.
Addresses review: only the best hit of a spectrum is rescored, but computeSpectrum() built a row for every retained hit, each scanning all hits for its score margin, so rescoring was quadratic in the hits per spectrum (e.g. with rescoring:top_hits 0 or report:top_hits 0). RNARescoringFeatures::computeRow() builds the row of one hit and scans the other hits once for its margins (linear); NASE uses it. computeSpectrum() shares the row code and documents its quadratic cost. A new unit test checks computeRow() against every computeSpectrum() row for several hit orders, ties and a single hit. Outputs are unchanged: TOPP references pass, and HAP1 clone1 rep1 gives byte-identical feature rows and mzTab. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Written by an AI agent using GPT-6. [P2] Keep rescored FDR calculations at one match per spectrum At line 3598, Reproduced using the committed synthetic rescoring fixture, changing only Please force one match per spectrum for FDR whenever rescoring succeeds, preserving the existing native-score behavior on fallback. Add a regression comparing primary-hit q-values with reporting limits 1 and 2. Validation: rebuilt the updated NASE tool against existing local OpenMS libraries; both focused unit tests and all 23 tests in the NASE TOPP harness passed. A full OpenMS build was not run. |
With report:top_hits above 1, hits tied with a spectrum's best native hit share its Percolator score, so the FDR calculation counted such spectra several times although Percolator scored one row per spectrum. When rescoring succeeds, q-values are now calculated on the best match per spectrum whatever report:top_hits is; the native fallback is unchanged. On the synthetic rescoring set, report:top_hits 2 put 711 instead of 651 matches into the FDR calculation and changed 405 q-values; now both settings give the same 651 q-values. New TOPP test: the set at report:top_hits 1 and 2 with fdr:cutoff 0.05 must give identical mzTab output (fails without the fix). Outputs at the default top_hits 1 are unchanged. Docs note the per-spectrum q-values. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Agreed, thanks. When rescoring succeeds, the FDR calculation now uses one match per spectrum regardless of |
poshul
left a comment
There was a problem hiding this comment.
Ready for review.
route_score was always equal to native_score: the route features only exist when route scoring is the search method, whose native score is the route score. diagnostic_unsupported_mods was always modifications minus diagnostic_supported_mods (an untested modification counts as unsupported but passes the diagnostic filter). Both carried no information and made Percolator's weight table misleading. HAP1 clone1 rep1-3 (route-scored search, train FDR 1%): 5,878 / 7,762 / 8,654 PSMs at 1% / 5% / 10% q-value against 5,932 / 7,789 / 8,655 before (per-file changes at 1% of +71, -39 and -86, within the model's training variation); entrapment search at train FDR 5% unchanged at 5% and 10% (7,036 vs 7,038 and 8,017 vs 8,028; estimated FDP 4.4% and 8.8%). The synthetic TOPP references have neither feature group and are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adds the route evidence of each rescored hit (route_score, route_nodes, route_intensity_ratio, route_prefix_length, route_suffix_length) to the Percolator features of a hyperscore or MVH search. The route score is computed as 'scoring:method route' would for the hit's intact model (without the support scaffolds of graph_routes); the search and its ranking are unchanged. Route-scored searches already have these features (their native_score is the route score), so the option changes nothing there. Off by default. If route evidence fails (e.g. routes:max_states), NASE warns and keeps the native score, like the other rescoring fallbacks. RNARescoringFeatures gets Options::route_score (a route_score column in the route group; requires Options::route). NASE passes a route-evidence callback to rescoreHits_, which evaluates only the rescored hit, and prepares the route-scoring spectra when the option is on. HAP1 clone1 rep1-3, PSMs at 1% / 5% / 10% q-value (summed): - main database, train FDR 1%: route search + Percolator 5,878 / 7,762 / 8,654; hyperscore + Percolator 5,678 / 7,397 / 8,075, with route features 6,442 / 7,683 / 8,220; MVH + Percolator 5,784 / 7,843 / 8,467, with route features 6,388 / 7,840 / 8,515. - entrapment database, train FDR 5% (estimated FDP at 5% / 10%): route search 800 / 7,036 / 8,017 (4.4% / 8.8%); MVH with route features 3,493 / 7,379 / 8,280 (3.8% / 8.9%); hyperscore with route features 1,436 / 7,205 / 8,010 (4.2% / 8.8%). One dataset and seed; not a validation of FDR control. These counts equal those of a prototype with the features appended last (route features identical; Percolator scores within 6e-6). Tests: unit tests for the column, its value and the invalid option combination; TOPP test TOPP_NucleicAcidSearchEngine_rescoring_route on the synthetic set (feature table reference, written by this code after checking the route columns: median route score 10.2 for targets, 0 for decoys). It uses train FDR 0.05: at 0.01 Percolator rejects the model on this small set (no target at q < 1% on a held-out fold). Co-Authored-By: Claude Opus 5.5 <[email protected]>
timosachsenberg
left a comment
There was a problem hiding this comment.
AI-generated initial review
This is an automated, AI-generated first review. It looks only for high- and medium-priority issues (no nits) and checks whether the PR has tests and measurements. Please double-check anything before acting on it; a maintainer will follow up. I reviewed c2a3c89e (stacked on #10913, 1e92a60d) merged into the current develop (a5b0f3fe). The whole stack merges cleanly.
What I ran:
-
Build: current develop with the whole NASE stack (#10909–#10913) and this PR merged on top. Release, Linux, GCC 13.3,
OPENMS_USE_VCPKG=OFF, system Boost 1.83; Arrow 24.0.0, libxml2 2.15.4, HiGHS 1.14.0 and yaml-cpp 0.9.0 built from source; Thermo RAW and OpenTIMS off.- For comparisons I also built NASE from #10913's head (
1e92a60) against the samelibOpenMS.
- For comparisons I also built NASE from #10913's head (
-
Tests: these pass:
- the class tests
RNARescoringFeatures_test,NASEDigestion_test,ModifiedNASequenceGenerator_test,RNASpectrumGraph_test,RNASensitivity_testandSpectrumAnnotator_test; - all 26
TOPP_NucleicAcidSearchEngine*tests, 11 of them new; - the NASE INI/CTD tests.
- the class tests
-
CI: the PR's base is
codex/nase-stack/07-graph-routes, so onlycppcheck-testran (passed).build-and-testdidn't run and CodeRabbit skipped. The new tests haven't run in CI yet; they will once the stack targets develop. -
Real data:
- Data: PXD016328
HAP1_tRNA_clone1_rep1(10,992 MS2), with the project's FASTA (420 tRNAs + 420 reversed decoys). - Settings: to complement your route-scoring benchmark, I used the default HyperScore: RNase T1, 2 missed cleavages, 3 ppm precursor and fragment tolerance, 13 variable modifications (D m1A m5C m7G Cm Gm Um m1G m2G t6A I m5U i6A),
fdr:decoy_pattern DECOY_, 4 threads, everything else at defaults.
native -rescoring:enablespectra with a target best hit at q ≤ 1 / 5 / 10 % 546 / 1,154 / 1,711 1,623 / 1,932 / 2,094 wall time, peak RSS 1:17, 1.00 GB 1:19, 1.01 GB - 545 of the 546 native spectra at 1 % are also accepted after rescoring.
- With the default HyperScore the gain at 1 % is about 3×; you report +9 % with route scoring.
- Data: PXD016328
-
Entrapment (same file):
- Database: the 420 targets + 420 entrapment sequences (
DecoyDatabase -type RNA -method shuffle -seed 2, relabelledENTRAP_) + decoys of both. - Estimated FDP = 2E/(T+E), the combined estimate (roughly an upper bound).
decoys of targets + entrapment q ≤ native: accepted / est. FDP rescored: accepted / est. FDP shuffled (seed 1) 1 % 131 / 0.0 % 1,016 / 0.4 % 5 % 1,093 / 1.3 % 1,729 / 2.7 % 10 % 1,342 / 3.9 % 2,043 / 5.7 % reversed (the DecoyDatabasedefault, identical to the PRIDE FASTA's decoys)1 % 546 / 0.0 % 1,386 / 1.2 % (8 entrapment hits) 5 % 1,074 / 0.9 % 1,791 / 3.7 % 10 % 1,466 / 4.2 % 1,985 / 6.3 % - Database: the 420 targets + 420 entrapment sequences (
Verdict:
- High priority: none.
- Medium priority: none.
- Checked and fine:
- Searches without rescoring are unchanged: on the full file, the mzTab is byte-identical to #10913's (apart from dates and paths).
- With rescoring on, the search keeps more hits, and
postProcessHits_resolves ambiguities before trimming toreport:top_hits. resolveAmbiguousMods_only merges hits with equal scores, so the reported hits are still those of a native search.
- With rescoring on, the search keeps more hits, and
- Fallback: on the RT window 35–39 min (943 MS2; 611 rows, 218 decoy best hits), Percolator's sanity check rejects the model ("Found 0 test set PSMs with q<0.01"). NASE warns, and the mzTab is identical to the native one, with 1 and with 4 threads.
- One row per spectrum:
scan_numbersare unique, so Percolator's TDC (post_processing_tdc) removes nothing and no row comes back as score 0 / PEP 1.getBestMatchPerObservation()only considers matches that have the Percolator score, so lower hits can't take a spectrum's q-value.
- Ties: 152 of 6,076 spectra have a target and a decoy tied for best. In all 152, the label of the Percolator row is the label of the match that gets the q-value.
- Thread count: with a trained model, the feature rows, Percolator scores and q-values are identical with 1 and 4 threads. Only the PEPs differ (see below).
- Reversed decoys:
- The weights are asymmetric: negative for
frac_c/frac_b/frac_a-B, positive forfrac_y/frac_x/frac_z. That fits mirror matching: a reversed decoy's c ladder covers its target's y ladder. At native scores ≥ 30, decoy best hits are indeed prefix-heavy (meanfrac_c0.46 vsfrac_y0.31; targets 0.58 vs 0.51). - The model doesn't use this to spot decoys, as far as I can tell: in a local build with all
frac_*columns held at 0, the reversed-decoy estimates are 1.4 / 2.9 / 4.7 % (1,315 / 1,632 / 1,788 accepted).- At 1 %, the per-series features are not what puts the estimate at 1.2 %. With 8–9 entrapment hits, that is within noise of 1 %.
- At 5–10 %, they add accepted spectra and estimated FDP together, and both stay below nominal.
- Shuffled decoys did better: they gave the lower estimate at every cutoff. That supports the README's "shuffled decoys may separate better". You could make it the recommendation in the README and in the
rescoring:enabledescription.
- The weights are asymmetric: negative for
- idXML (
-id_out): the main score stays the native score; the Percolator score and PEP become meta values. - Exceptions:
Percolator::rescorerethrows upstream failures asException::InvalidValue, socatch (const Exception::BaseException&)covers them.
- Searches without rescoring are unchanged: on the full file, the mzTab is byte-identical to #10913's (apart from dates and paths).
Outside this PR (for information)
- PEPs depend on the thread count: they differ between 1 and 4 threads by up to 5.6e-4 (absolute), while scores and q-values are identical.
- That comes from core Percolator's PEP estimation, not from this PR.
- The README says results depend on
threads. That is accurate, but it's only the PEPs.
Tests
-
You added:
RNARescoringFeatures_test: hand-computed values for every feature, andcomputeRowagainstcomputeSpectrum;- 11 TOPP tests: a trained model with mzTab and feature-table references,
report:top_hits1 vs 2, a rejected model vs a native run, and too few decoys vs the existing native reference.
All pass here.
-
They catch regressions: I mutated the code locally.
- Reverting the FDR change of
c2a3c89(q-values from all hits withreport:top_hits 2) failsrescoring_top_out. - Disabling the
usedDefaultDirection()fallback failsrescoring_rejected_out.
- Reverting the FDR change of
-
Missing: nothing I would require.
Measurements
- You provided: HAP1 clone1 rep1–3 with route scoring, on the main database and with entrapment, at train FDR 1 % and 5 %.
- Added above:
- the default HyperScore on clone1 rep1: yield, runtime and memory (no measurable overhead: +2 s wall, +10 MB);
- entrapment with shuffled and reversed decoys;
- the native-output identity with #10913;
- the fallback and thread checks.
Description
- The AI use is disclosed: the AI-policy box and "Substantial" are ticked, and all 8 commits carry a
Co-authored-by:trailer.
Generated by Claude Code
timosachsenberg
left a comment
There was a problem hiding this comment.
AI-generated initial review
This is an automated, AI-generated first review. It looks only for high- and medium-priority issues (no nits) and checks whether the PR has tests and measurements. Please double-check anything before acting on it; a maintainer will follow up. I reviewed a6fce818 against its base codex/nase-stack/07-graph-routes (1e92a601, #10913).
What I ran:
- Build: this PR's head from source (Release, Linux, GCC 13.3,
OPENMS_USE_VCPKG=OFFwith system packages; Arrow 24 as shared libraries, libxml2 2.15.4 from source; Thermo RAW and OpenTIMS off). - Tests: all 33 NASE tests pass. That includes
NASEDigestion_test,RNARescoringFeatures_testand the 13 newTOPP_NucleicAcidSearchEngine_rescoring*tests.Percolator_testpasses too. - CI: only
cppcheck-testran (passed). The base is a stack branch, sobuild-and-testhas not run on this PR; the run above is the only build and test run so far. - Real data: PXD016328,
HAP1_tRNA_clone2_rep1andHAP1_tRNA_clone3_rep1, whole files with 10,602 MS2 each. Your benchmark used the clone1 files, so these runs are independent of it.-
Database: the 420 targets of the project's
hg19-mature-tRNA_TargetDecoy.fasta, with shuffled decoys fromDecoyDatabase -type RNA -method shuffle, decoy seeds 1, 2 and 3. -
Settings: simpler than your HAP1 recipe, so that the roughly 90 searches fit in the session:
- RNase T1, 1 missed cleavage, precursor 5 ppm, fragment 10 ppm, isotopes 0 and 1;
- 14 variable modifications (D m1A m5C m7G Cm Gm Um m1G m2G t6A I m5U i6A m22G), at most 2 per oligo;
- enumeration, default ions and preprocessing, 4 threads.
-
Target spectra at q ≤ 1 / 5 / 10 %:
clone2, decoy seed 1 seed 2 seed 3 clone3, decoy seed 1 seed 2 seed 3 hyperscore 892 / 1,318 / 1,769 981 / 1,401 / 1,855 1,037 / 1,388 / 1,741 804 / 1,177 / 1,664 950 / 1,340 / 1,988 762 / 1,122 / 1,437 hyperscore + Percolator 1,630 / 2,107 / 2,337 1,171 / 1,648 / 2,177 1,686 / 2,164 / 2,344 1,671 / 2,048 / 2,261 1,364 / 2,072 / 2,291 1,320 / 1,946 / 2,196 hyperscore + Percolator + route_features1,737 / 2,165 / 2,333 1,433 / 2,193 / 2,363 1,831 / 2,167 / 2,350 1,731 / 2,083 / 2,236 1,652 / 2,094 / 2,312 1,505 / 2,131 / 2,258 MVH 652 / 1,403 / 1,830 1,208 / 1,928 / 2,215 1,022 / 1,591 / 2,048 537 / 1,273 / 1,821 1,221 / 1,869 / 2,143 147 / 1,390 / 1,913 MVH + Percolator 1,564 / 2,022 / 2,282 fallback (= native) 1,928 / 2,140 / 2,309 1,524 / 2,052 / 2,201 1,711 / 2,128 / 2,316 1,416 / 2,073 / 2,264 MVH + Percolator + route_features1,688 / 2,098 / 2,285 fallback (= native) 1,759 / 2,138 / 2,308 1,718 / 2,055 / 2,235 1,836 / 2,173 / 2,332 1,533 / 2,081 / 2,222 route 1,203 / 1,862 / 2,182 1,149 / 2,132 / 2,358 30 / 1,840 / 2,244 815 / 1,779 / 2,170 847 / 2,093 / 2,278 22 / 1,775 / 2,240 route + Percolator 1,218 / 2,008 / 2,248 1,352 / 2,196 / 2,425 1,442 / 1,976 / 2,200 1,401 / 1,927 / 2,180 1,241 / 1,908 / 2,239 1,256 / 1,901 / 2,134 -
Hyperscore and MVH: at nominal q-values, rescoring roughly doubles the spectra at 1 %.
-
Unstable native 1 % counts: rescoring keeps the 1 % count stable across decoy seeds where the native count collapses: route with seed 3 goes from 30 to 1,442 and from 22 to 1,256; MVH on clone3 with seed 3 from 147 to 1,416. Your recipe's 10-seed record shows the same native instability.
-
Route scoring: the result is mixed beyond 1 %. On clone3 with seed 2, 5 % drops from 2,093 to 1,908, and three of the six route runs drop at 10 %.
-
Fallback: on MVH, clone2, seed 2, Percolator's sanity check rejected the model, with and without
route_features. Both mzTabs are byte-identical to the native search apart from the date and file path, as documented.
-
- Runtime and memory:
- Rescoring adds no measurable wall time: about 36 s for hyperscore, 48–50 s for MVH and 42–48 s for route, with or without it.
rescoring:route_featuresadds 2–4 s and doubles peak memory, from about 0.7 to 1.4 GB, because all spectra are copied and prepared for route scoring.
- Reproducibility:
- 1 and 4 threads give identical feature tables and Percolator scores, and a rerun is identical.
rescoring:seed1, 2 and 3 give 1,630, 1,736 and 1,658 at 1 % (clone2, hyperscore, decoy seed 1).
- Entrapment: the check that your README recommends, on the same two files; see High priority 1.
Verdict:
- High priority: one. In an entrapment check on these two files, the Percolator q-values understate the FDR much more than the native ones. Decoys are suppressed far more than false target hits.
- Medium priority: none.
- Checked and fine:
- Feature rows:
computeRow()gives the same row ascomputeSpectrum(); I checked by reading the code, and your unit test covers it. - Route evidence lambda: everything it captures is declared in
main_at the scope of thepostProcessHits_()call, so nothing dangles. - Retained runner-ups:
resolveAmbiguousMods_()merges only exact-score groups and the trim keeps ties. Retaining extra hits for the margins therefore doesn't change the reported native hits. The fallback outputs above confirm it. - Ties at the top: for a target/decoy tie, the Percolator label depends on the sequence order. On clone2 with decoy seed 1, this happens for 25–75 spectra per method, and none of them is accepted at 1 %.
- Meta values:
diagnostic_allowed_modsand the FLASH values are set on the same spectra that rescoring reads.
- Feature rows:
High priority
1. Entrapment check: the Percolator q-values understate the FDR, because decoys no longer track the false target hits
-
Setup: the same design as yours.
- 420 targets, 420 shuffled entrapment sequences (
DecoyDatabaseshuffle with seed 99, accessions renamedENTRAP_), and shuffled decoys of both (seed 1). That is 255 unique target and 255 unique entrapment sequences. - Search settings as above.
- On the unmodified T1 digest, the entrapment sequences have 1,381 oligos not shared with targets, against 1,255 target oligos. The 1:1 assumption of the estimate 2E/(T+E) therefore roughly holds.
- 420 targets, 420 shuffled entrapment sequences (
-
Accepted spectra / entrapment hits / estimated FDP:
clone2: q ≤ 1 % 5 % 10 % clone3: q ≤ 1 % 5 % 10 % hyperscore 201 / 0 / 0.0 % 826 / 9 / 2.2 % 1,444 / 133 / 18.4 % 250 / 0 / 0.0 % 580 / 3 / 1.0 % 977 / 50 / 10.2 % hyperscore + Percolator 1,319 / 68 / 10.3 % 1,970 / 187 / 19.0 % 2,332 / 314 / 26.9 % 804 / 30 / 7.5 % 1,224 / 106 / 17.3 % 1,562 / 194 / 24.8 % MVH 53 / 0 / 0.0 % 306 / 1 / 0.7 % 1,783 / 176 / 19.7 % 141 / 0 / 0.0 % 216 / 0 / 0.0 % 1,616 / 144 / 17.8 % MVH + Percolator + route_features1,447 / 91 / 12.6 % 1,942 / 188 / 19.4 % 2,291 / 297 / 25.9 % 1,106 / 56 / 10.1 % 1,935 / 197 / 20.4 % 2,159 / 260 / 24.1 % route 568 / 5 / 1.8 % 1,580 / 57 / 7.2 % 2,023 / 140 / 13.8 % 652 / 12 / 3.7 % 1,164 / 34 / 5.8 % 1,947 / 148 / 15.2 % route + Percolator 1,040 / 44 / 8.5 % 1,792 / 154 / 17.2 % 2,163 / 254 / 23.5 % 1,000 / 34 / 6.8 % 1,750 / 163 / 18.6 % 2,102 / 242 / 23.0 % -
The native q-values are not well calibrated in this setup either: at 10 % they reach 10–20 %. So read the absolute FDP values with care. The comparison between the two rows of each method is fair, though: same database, same spectra, same estimator.
-
The ranking itself improves; the FDR estimate is what fails. At a similar depth, Percolator's list has fewer entrapment hits than the native one, but far fewer decoys:
- clone2, hyperscore, native at q ≤ 10 %: 1,444 accepted, 133 entrapment, 145 decoys;
- Percolator at q ≤ 1 %: 1,319 accepted, 68 entrapment, 14 decoys.
-
Entrapment and decoys should behave alike: both are shuffles made by the same tool. They also share target 6-, 8- and 10-mers equally often (57.7 / 7.8 / 0.7 % for entrapment, 58.7 / 8.4 / 0.6 % for decoys of targets). Among all best hits there are 1,069 entrapment and 2,262 decoy hits (E/D 0.47, clone2, hyperscore).
- Native: at 5 % and 10 %, E/D among the accepted hits stays below 1 in all six runs, e.g. 9 / 42 and 133 / 145. The native 1 % lists are too short to tell.
- Percolator: E/D is 3–6.5 at 1 % (68 / 14, 91 / 14, 44 / 10, 30 / 6, 56 / 11, 34 / 11) and 1.7–2.0 at 5 %.
-
Toward a mechanism (not conclusive):
- Clustering: the accepted entrapment hits come from a few sequences that match many spectra. At 1 % on clone2 with hyperscore, the 68 entrapment spectra come from 22 sequence/charge pairs, and 91 % of them share sequence and charge with another spectrum. The 14 accepted decoys come from 12 pairs, only 43 % repeated. Before the threshold, entrapment and decoy best hits repeat equally often (56 % and 58 %).
- Unexplained analytes: 63 of these 68 spectra are not accepted at 1 % in the plain target/decoy search. Their best hit there is a decoy or a target with q > 1 %. They are mostly long, doubly modified oligos such as
AUU[m2,2G]DCAAUCCACAUUGp: analytes that the database does not explain. - Fold assignment: NASE sets
RescoreInput::scan_numbersto the scan index, so the repeated spectra of one analyte fall into different cross-validation folds.Percolator.hwarns that such rows needcv_group_keys("Otherwise q-values will be optimistic"). - Local experiment, not pushed: I put rows with the same best-hit sequence into one fold via
cv_group_keys. That only takes effect withscan_numbersempty (seemakeRowKeys()), and then also needspost_processing_tdcoff, because the key becomes the TDC dedup key; I also turned offtrain_best_positiveanduse_pi0.- It lowered the 1 % FDP in three configurations (12.6 → 6.4 %, 8.5 → 2.3 %, 10.1 → 6.8 %) and raised it in one (10.3 → 14.0 %).
- Percolator rejected its model in 8 of 24 searches.
- So the fold leakage is probably part of the cause, but this grouping alone doesn't fix it.
-
Why your entrapment check looks different: you used the full HAP1 recipe (graph routes, FLASH, legacy deisotoping, 33 modifications) on clone1, and got 4.4 / 8.8 % against native 4.0 / 7.6 %. My settings are simpler.
rescoring:enableworks with any NASE setting, though, and the README example uses the defaults. -
Mitigation:
- Before merging, repeat the entrapment check with default-like settings and on other files. Report E/D among the accepted hits next to 2E/(T+E); it compares two kinds of shuffles and needs no assumption about the entrapment-to-target ratio.
- Put repeated spectra of one analyte into one fold with a label-independent key, e.g. precursor m/z within the precursor tolerance, charge and an RT window. Leave
scan_numbersempty for that and handle TDC (there is one row per spectrum anyway). Then repeat the check. - Until the check passes, say in the help of
rescoring:enableand in the README that the rescored q-values can understate the FDR. Here the estimated FDP was 7–13 % at q ≤ 1 %. Alternatively, mark the option as experimental.
Tests
-
You added:
RNARescoringFeatures_test: hand-computed features,computeRow()againstcomputeSpectrum()including ties, annotation parsing and the options;- TOPP tests for a trained model, a rejected model, too few decoys, top 1 equal to top 2, and
route_features.
All of them pass here.
-
Missing: nothing I would require for the wiring. FDR control can't be tested with a small fixture; the entrapment check above is the relevant evidence.
Measurements
- You provided: HAP1 clone1 rep1–3 counts for all three scores, with and without
route_features, plus an entrapment check (three files pooled, one decoy seed). - What was missing: other files, variation across decoy seeds, runtime and memory. I added them above.
- The route-scored 1 % gain is within the native spread across decoy seeds. Your recipe's own record has native 1 % counts from 6,369 to 15,548 over ten decoy seeds (nine files), while your route-scored gain at 1 % is about 8 % (5,454 → 5,878). Rescoring narrows that spread here, which is a real benefit if the q-values hold.
Description
- The AI use is disclosed, the policy box is ticked, and all 10 commits carry a
Co-authored-by:trailer. - The PR is stacked on #10913, so it can only be merged after the stack.
Generated by Claude Code
Mark rescoring:enable as experimental: when an analyte produces several spectra, they fall into different Percolator cross-validation folds, and the rescored q-values can understate the FDR (Freestone, Noble and Keich 2024). Entrapment checks on HAP1 clone2/clone3 with simplified settings show this: accepted entrapment matches cluster on a few repeated oligos. The help, README and doxygen page describe the issue, recommend shuffled decoys and an entrapment check, and say that with 1 and 4 threads only the PEPs differ. rescoring:route_features no longer copies and prepares every spectrum up front: only the rescored hit of a spectrum is route-scored, so its peaks are selected and its context prepared when it is scored. On HAP1 clone1 rep1 (hyperscore + route_features) the feature table and mzTab are identical and peak RSS falls from 983 MB to 477 MB. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for the entrapment check; it found a real problem. Summary of what I found and what changed in 958546a: Reproduction. Same design as yours (420 targets + 420 shuffled entrapment + shuffled decoys of both), hyperscore with your simplified settings, clone2/clone3 rep1. My yields are lower than yours (native 71 / 81 at 1%), but the pattern is the same:
Across all best hits, entrapment and decoy hits are exchangeable: E/D is 0.37 (about 0.5 expected from the database), and the per-feature AUCs (entrapment vs decoy) lie between 0.43 and 0.56, with 0.48–0.52 for the Percolator score. So no feature separates decoys from false targets in general; the problem is only at the top of the ranking. There it is clustering, as you saw: on clone3, 13 of the 26 accepted entrapment spectra at 5% are Mechanism. This is a known Percolator flaw. Freestone, Noble and Keich (2024, "Re-investigating the correctness of decoy-based false discovery rate control in proteomics tandem mass spectrometry") showed with an entrapment experiment that Percolator's PSM-level FDR control fails when one peptide produces several spectra. Some spectra land in the training folds and some in the test fold, so the model overfits. Analysing runs separately reduced the violations. Applied here: repeated spectra of a wrongly explained analyte pull each other up when the wrong match is a target or entrapment sequence (positives in training), and push each other down when it is a decoy (negatives). Decoys then stop tracking false targets, which is your E/D of 3–6.5. Fix. The same group's fix is Percolator-RESET (Freestone, Käll, Noble and Keich; bioRxiv 10.1101/2023.10.26.564068). It trains at peptide level (the best PSM per peptide) and randomly splits the winning decoys into a training set and an estimating set. Upstream Percolator has had it since rel-3-07 (percolator/percolator#378), but OpenMS's vendored copy keeps only the PSM rescoring path. Vendoring RESET and exposing it in In this PR:
All 36 NASE tests pass locally. |
|
The Percolator-RESET PR mentioned above is #10923 (draft): upstream RESET in |
Description
Stacked on #10913 (
codex/nase-stack/07-graph-routes, head1e92a601d3).Adds optional semi-supervised rescoring of NASE's spectrum matches with the in-process Percolator of OpenMS core (
Percolator::rescore). It is off by default (rescoring:enable) and requires decoys (fdr:decoy_pattern); searches without it are unchanged.Design
RNARescoringFeatures(tool-local, unit-tested) builds one feature row per hit: native score, margins to the next different sequence and to the best hit, |ppm error|, isotope offset, one-hot charge, length, modifications, adduct, per-series matched fractions, matched ions and intensity, longest ion series (sharedSpectrumAnnotator::computeLongestIonSeries), backbone coverage, plus optional route, graph-tag, diagnostic-ion and FLASH groups. Columns depend only on the parameters, never on target/decoy labels. No column duplicates another: route-scored searches get no separateroute_score(it isnative_score), and only the count of diagnostic-supported modifications is a feature (the unsupported count ismodificationsminus it).rescoring:route_features(off by default) adds the route evidence of the rescored hit (route_score, nodes, intensity ratio, prefix/suffix length) to the features of a hyperscore or MVH search. The route score is that ofscoring:method routefor the hit's intact model (withoutgraph_routessupport scaffolds); the search and its ranking are unchanged. Each spectrum's route context is prepared only when its rescored hit is scored, not for all spectra up front (peak RSS on HAP1 clone1 rep1: 477 MB, previously 983 MB, identical output). On HAP1 this gave the most spectra at 1% (below).rescoring:top_hits, default 2) only feed the margin features. Runner-ups are not rows because every RNA target has an isobaric reversed/shuffled decoy, so most spectra have a strong decoy runner-up: without Percolator's target-decoy competition its training q-values and PEPs count them as independent chances; with it, losing rows come back as score 0 / PEP 1 and cannot be distinguished from real values. Consequently the order of hits within a spectrum stays native; ties at the top share the Percolator score/PEP; lower hits get no Percolator score or q-value.report:top_hitsis;percolator:score(MS:1001492) andpercolator:PEP(MS:1001493) are reported next to the native score. mzTab score columns are native, Percolator score, PEP, q-value: the export numbers columns by the first exported match that has them, and tied hits not picked by the FDR calculation have no q-value, so the q-value must come last for a run-independent order. Searches without rescoring keep native, q-value.rescoring:min_decoys(100) spectra have a decoy best hit, if Percolator throws, if the route evidence ofrescoring:route_featuresfails, or if Percolator's sanity check rejects the learned model. (Percolator would otherwise score with a single feature, which on one HAP1 entrapment search kept 16 / 102 / 329 spectra at 1% / 5% / 10% against 0 / 2,095 / 2,474 natively.)rescoring:train_fdr(default 0.01) sets Percolator's train/test FDR;rescoring:seed;rescoring:out_featureswrites the feature rows and Percolator results. With 1 and 4 threads the scores and q-values are identical; only the PEPs differ slightly (core Percolator).postProcessHits_now sorts and resolves ambiguities for all spectra before rescoring, then registers matches;calculateAndFilterFDR_takes the ranking score type.Docs:
README.rescoring.mdand the doxygen pageTOPP_NASE_Rescoring, linked from the tool page.Tests
RNARescoringFeatures_test: hand-computed values for every feature, annotation parsing, option validation.report:top_hits1 and 2 (withfdr:cutoff 0.05) must give identical output. The synthetic set withrescoring:route_features(train FDR 0.05; at 0.01 Percolator rejects the model on this small set) is compared against a feature-table reference. The synthetic generator is described in the commit messages; it is not committed. These tests check the wiring, not the model. Test data adds about 1.3 MB (650 KB of it gzipped mzML).OpenMS-build, every NASE test target rebuilt). Full repository and pyOpenMS builds were not run; no bindings are affected.HAP1 benchmark (PXD016328 clone1 rep1–3; recipe of
doc/benchmarking/nase/hap1_legacy_sensitivity_corrected_2026.jsonwith corrected chemistry and the regenerated seed-1 shuffled decoy FASTA). Rerun on this stack after rebasing onto1e92a601d3(the recipe sets the route options whose defaults that commit changed): the counts were identical to the pre-rebase runs, file by file, with byte-identical feature tables (that rerun is where the score-column order issue above showed up). The Percolator counts below are from the current head, after dropping the two duplicate features (before: 5,932 / 7,789 / 8,655 on the main database).Main database, native counts reproduce the record exactly:
rescoring:route_featuresrescoring:route_featuresThe first two rows use route scoring (the recipe); the others change only
scoring:method. With route features, every file gains at 1% (by 183–274 PSMs).Entrapment database (420 targets + 420 shuffled entrapment sequences + shuffled decoys of both; combined estimate 2E/(T+E), pooled over the three files). At train FDR 1% Percolator rejects its model on all three (a top-scoring decoy leaves no target at q < 1% on a fold), so NASE falls back to native and reproduces the native result. At train FDR 5%:
MVH search with
rescoring:route_features(same train FDR): 7,379 / 3.8% at 5% and 8,280 / 8.9% at 10% (hyperscore with route features: 7,205 / 4.2%, 8,010 / 8.8%).At 1% both rankings are unstable on this database (native 213, Percolator 800, MVH with route features 3,493 with 0.7% estimated FDP). The estimated FDP stays below nominal but is slightly higher than native; this is a single three-file, single-seed check, not a validation of FDR control.
FDR control (see the review of 2026-11-16 for the independent check). With simplified settings (hyperscore, RNase T1, 1 missed cleavage, 14 modifications) on clone2/clone3 rep1 and the same entrapment design, accepted entrapment matches cluster on a few repeated oligos. On clone3, 13 of the 26 entrapment spectra at q ≤ 5% are one oligo at charges 4 and 5; the accepted decoys are mostly single spectra.
Across all best hits, entrapment and decoys are exchangeable (per-feature AUCs ≈ 0.5); the problem is only at the top of the ranking. The independent review measured 7–13% at q ≤ 1% with its settings.
Checklist
AI use (see the OpenMS AI Policy)
Assisted-by:trailerCo-authored-by:trailer, and the description above explains the design intent and rationale🤖 Generated with Claude Code