Repository navigation
[FEATURE,LOG] ProSE: peptdeep:enable fails instead of continuing without predictions - #10461
Merged
timosachsenberg merged 1 commit intoOct 8, 2026
Conversation
…out predictions 'peptdeep:enable' is an explicit request, so ProSE now throws when it cannot be honoured: an OpenMS built without ONNX, missing/unloadable models, or no PSM receiving predicted features. PeptDeepRescoring reports '[PeptDeepRescoring] Predicted features added: N / M PSMs (<features>), NCE=<nce>' and exposes getNumPSMs()/getNumPredictedPSMs(). Co-authored-by: Copilot App <[email protected]>
timosachsenberg
merged commit Oct 8, 2026
20ac1ab
into
OpenMS:claude/prose-onnx-rescoring-features-v2
2 checks passed
timosachsenberg
pushed a commit
that referenced
this pull request
Oct 13, 2026
…out predictions (#10461) 'peptdeep:enable' is an explicit request, so ProSE now throws when it cannot be honoured: an OpenMS built without ONNX, missing/unloadable models, or no PSM receiving predicted features. PeptDeepRescoring reports '[PeptDeepRescoring] Predicted features added: N / M PSMs (<features>), NCE=<nce>' and exposes getNumPSMs()/getNumPredictedPSMs(). Co-authored-by: Copilot App <[email protected]>
timosachsenberg
pushed a commit
that referenced
this pull request
Oct 13, 2026
The entry only described the failure behaviour of #10461 relative to a warning that never shipped. Describe the parameter, its five features, its requirements and its measured cost instead, and keep the failure and log details. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D1N3pC2AqJt57Q3v87bWxz
Merged
5 tasks done
timosachsenberg
added a commit
that referenced
this pull request
Oct 13, 2026
…5.0% PSMs at 1% FDR) (#9975) * Add PeptDeep rescoring features with auto-NCE and RT calibration Adds PeptDeepRescoring, which annotates PSMs with five features derived from AlphaPeptDeep predictions -- ms2_cosine, ms2_spectral_angle, ms2_pearson, ms2_frac_pred_found and rt_abs_error -- and registers them in the search parameters' extra_features so PercolatorAdapter picks them up. Observed intensities come from the PSM's own peak annotations, so no second pass over the spectra is needed. Two per-run quantities are calibrated from the data rather than asked of the user, because neither has a safe global default: - Collision energy. The mzML value (Precursor meta value "collision energy") is only the centre of a small search grid; each candidate is scored on a sample of confident PSMs and the best median cosine wins. The model's NCE scale does not coincide with the instrument's number -- on a Q Exactive HF run the file reports 27 while the scan selects 31. - Retention time. Predicted RT is in the model's own units, so it is mapped onto the run's gradient with an OpenMS TransformationModel (B-spline by default, lowess and linear also selectable) before the residual is taken. Confident PSMs are selected by search score rather than by spectral similarity, which would otherwise tie the RT feature to the MS2 features. Built only with WITH_ONNX, which now also defines WITH_ONNX=1 publicly so dependent code can compile the calls out, matching how WITH_OPENTIMS and WITH_THERMO_RAW are handled. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KPU24wdJgjAoyWYVuUU5FA * Wire PeptDeep rescoring into ProSE and add a class test Adds peptdeep:* parameters to ProSEAlgorithm and calls PeptDeepRescoring from all three search paths (single, chunked, and multi-file), so the prediction-based features reach the output idXML and its extra_features list. The step is skipped unless both model paths are set, so the default behaviour is unchanged. On a build without ONNX the call compiles out and an ini file that requests the models still runs, warning that the features were not added rather than failing. The test covers the feature-name contract, the parameter defaults, and the two refusal paths -- no models configured, and a configured model that does not exist -- since both would otherwise silently produce all-zero features. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KPU24wdJgjAoyWYVuUU5FA * Calibrate each identification run separately in PeptDeepRescoring Review found that annotate() built one calibration set and one TransformationModel from all peptide_ids. PSMs from runs with different gradients would then share a retention-time fit that describes neither, and extra_features was registered on protein_ids[0] regardless of which run the PSMs came from. Rows are now grouped by PeptideIdentification::getIdentifier() and each run gets its own collision energy, its own retention-time model, and its features registered on the ProteinIdentification with the matching identifier (falling back to the first run when identifiers do not line up). The two ONNX sessions are still created once and shared, since loading a model is the expensive part. ProSE was not affected -- all three of its call sites pass a single run -- but the class is public API and a merged idXML would have hit this. Also from the same review: - Reset used_nce_ and rt_calibration_error_ at the start of annotate(), so the getters describe the current call rather than a previous one. - Draw the NCE sample from the confident set only. It previously walked the whole score ranking, so a run with fewer confident PSMs than nce_sample_size would have selected its collision energy partly on PSMs that calibration_quantile excluded. - Document the constructor and destructor. Verified behaviour-preserving on a 70549-PSM Q Exactive HF run: NCE 31, median cosine 0.95045, retention-time residual 137.083 s over 35274 calibration PSMs, all identical to before the change. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KPU24wdJgjAoyWYVuUU5FA * Derive score direction and collision energy per run Two follow-ups to the per-run restructure, both found in review. Score orientation was still taken from peptide_ids[0] and reused for every run. A merged file can hold runs from engines that disagree on it, and the wrong direction makes annotateRun_() calibrate on the worst-scoring PSMs rather than the best. It is now read from the run's own identifications. The collision-energy grid was centred on the whole PeakMap. Runs acquired at different energies would share one grid, which can exclude an optimum. The per-spectrum energies are now collected once into a native-ID keyed map, and each run centres its grid on the spectra its own PSMs reference, falling back to all observed energies when the references do not resolve (older files, or identifications not linked to these spectra). annotateRun_() takes that map rather than the PeakMap, which was not otherwise used. Verified behaviour-preserving on the 70549-PSM Q Exactive HF run: NCE 31, median cosine 0.95045, retention-time residual 137.083 s. Also confirmed the reference lookup resolves rather than silently taking the fallback -- 500 of 500 sampled PSM references match mzML native IDs. 43/43 tests pass, and ProSEAlgorithm.cpp still compiles with WITH_ONNX undefined. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KPU24wdJgjAoyWYVuUU5FA * Drop the @htmlinclude that broke Doxygen_Warning_test The class documentation referenced OpenMS_PeptDeepRescoring.parameters, which is never generated: those files come from DefaultParamHandlerDocumenter, and only for the classes registered there. Doxygen reported "included file ... is not found. Check your EXAMPLE_PATH", which failed Doxygen_Warning_test on every build-and-test job. Registering the class with the documenter is not an option, since it cannot instantiate a type that only exists in ONNX-enabled builds. ProSEAlgorithm, also a DefaultParamHandler, omits the directive for the same reason, so this follows its neighbour. The reason is recorded in the class comment so the directive does not get added back. Reproduced against the project's own Doxygen settings before and after: one warning, then none. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KPU24wdJgjAoyWYVuUU5FA * Use '\n' rather than std::endl in the log statements added here The project's review guidance asks for '\n' over std::endl in .cpp files. I had declined this on the grounds that no such guideline appeared anywhere in the tree and that the surrounding code uses std::endl heavily; the guideline is configured outside the repository, so searching it was never going to find it. Scoped to the seven log statements this PR adds. The 37 pre-existing std::endl uses in ProSEAlgorithm.cpp are left alone: a directory-wide sweep is a separate change. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KPU24wdJgjAoyWYVuUU5FA * Do not attribute a collision energy to an ambiguous spectrum identifier The per-run collision-energy map added in 13fff19 is keyed by spectrum native ID, which is unique within a run but not across runs: scan numbering restarts per file, so a PeakMap spanning several runs can carry the same identifier twice. The map assignment silently overwrote, and a PSM in one run could then have its grid centred on another run's collision energy. Identifiers that recur with differing energies are now dropped instead of resolved arbitrarily, since nothing in the input says which run a PSM's reference meant; those runs fall back to the median over all observed energies, as they already did when no reference resolved. A warning names how many were excluded so the situation is visible rather than silent. Single-run behaviour is unchanged: the 70549-PSM Q Exactive HF run still selects NCE 31 with median cosine 0.95045 and a 137.083 s retention-time residual, and reports no ambiguity, its 135859 identifiers being unique. 43/43 tests pass. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KPU24wdJgjAoyWYVuUU5FA * Gate PeptDeep rescoring on a flag and default to the shipped models Setting 'peptdeep:ms2_model' but forgetting 'peptdeep:rt_model' silently did nothing, and a user of an ONNX-enabled build still had to locate the models the build had already downloaded. 'peptdeep:enable' now gates the step, and the two model parameters default to the shipped model names, so the feature needs no paths. They remain overrides: File::find() returns an absolute path unchanged. The models are downloaded to the build tree's share/OpenMS/models, which is not the compiled-in data path, so '../share/OpenMS' relative to the executable is searched too. That directory holds them in a build tree (bin/../share) and in an install tree alike, using the same idiom getOpenMSDataPath() already applies for installed tools. Default behaviour is unchanged: with the flag off the step stays inert and the ProSE golden files do not move. ctest -R 'ProSE|PeptDeep|FragmentIndex| PercolatorAdapter': 43/43. With the flag and no paths, all five features are written; without it, none are. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KPU24wdJgjAoyWYVuUU5FA * Cover PeptDeepRescoring end to end, and stop wasting work in the NCE scan Three changes from a review pass over the feature. The class test never called annotate(), so every line that computes a feature was unexercised: ion parsing, the similarity metrics, collision-energy selection, retention-time calibration, per-run grouping and the write-back. Three multi-run defects were found by reading during this branch's review and none by a test. Three sections now cover that ground, using the models the class-test CMake already stages beside the binary, the way PeptDeepInference_test does. Two runs are annotated so the per-run paths are exercised rather than assumed; a matching and a scrambled peptide are scored against the same observed spectrum, which is what would catch a wrong y-series ordinal. Two traps in writing it are worth recording. Sized for four PSMs per run, the retention-time fit is skipped and rt_abs_error is a constant zero that any range assertion passes, so the runs are wide enough to calibrate and getRTCalibrationError() is asserted non-negative. And a fixed NCE never reaches the grid scan, so a section drives the automatic path and checks the choice is a point of the grid it was given. observedIons_() was called inside that grid loop although the observed spectrum does not vary with the candidate energy: seven grid points over a 2000-PSM sample rebuilt the same maps ~14000 times. It is now built once per sample. The neighbouring empty-prediction guard is made to match the main loop's while the two lines are adjacent. ProSE forwarded neither the thread count nor the batch size, so inference ran at four threads while the search around it scaled with omp_get_max_threads(). It now forwards both, and peptdeep:batch_size is exposed as an advanced parameter. PeptDeepRescoring_test: 9/9 sections pass, with calibration confirmed running (5 PSMs per run) and NCE selection reporting a grid point. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KPU24wdJgjAoyWYVuUU5FA * Check for peak annotations per run, not per file The guard against missing peak annotations summed one counter over the whole input and fired only when it reached zero. A merged file where one run carries annotations and another does not therefore passed it, and the unannotated run received four MS2 features that were exactly zero for every one of its PSMs, with nothing said. Percolator pools the runs, so that constant block reads as a clean separator between runs rather than between targets and decoys. Annotations are now counted per identification run. All runs unannotated is still a hard error. A mix warns and names the runs, since the input remains usable and refusing it outright would break a workflow that partly works. The features are still written for every run: dropping them for one would leave Percolator with a ragged feature set, which is its own failure mode. The retention-time warning gets the same treatment. It said the residual would be zero "for this run" without naming which, and both per-run log lines now carry the run identifier, so a multi-run log can be read at all. Two test sections cover the case that had none: a two-run input where only one run is annotated, asserting that annotate() does not throw and that the unannotated run's cosines are zero while the other run's are not; and a two-run input where neither is annotated, asserting it still throws. ctest -R 'ProSE|PeptDeep|FragmentIndex|PercolatorAdapter': 43/43, with PeptDeepRescoring_test at 11 sections. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KPU24wdJgjAoyWYVuUU5FA * Document that PeptDeep calibration needs unmerged runs PeptDeepRescoring partitions PSMs by identification run and calibrates NCE and retention time separately for each. That partition is only as good as the run identifiers, so it quietly degrades to a single global fit if it ever runs on identifications whose runs have already been collapsed into one -- and it cannot detect that, because such input is indistinguishable from a genuine single run. The per-run optima really do differ: across six files of the HLA ligand atlas (PXD019643) the RT calibrations landed between 98 s and 625 s median residual, and each file selected its own collision energy. Nothing here changes behaviour. ProSE already calls this per input file, before the merge; this records why that ordering is load-bearing, at the call site, at the partition key, and in the API docs. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KPU24wdJgjAoyWYVuUU5FA * Take PeptDeep's instrument encoding from peptdeep The instrument reaches the MS2 model as a one-hot, so a name's position in peptdeep's list *is* its index, and the list was restated in C++ rather than mirrored: PeptDeepRescoring mapped Lumos to 0 and QE to 1, where peptdeep's model_const.yaml has QE first. The default is QE, so the default path asked the model for Lumos. The repository already recorded the right answer -- every row of proteomicsml_test_data_ms2_spectra.csv pairs instrument "QE" with instrument_index 0 -- while PeptDeepMS2Inference's own @PARAM documented the encoding backwards, which is what the map followed. So keep one copy of it, in PeptDeepUtils.h beside the mod-element table it already mirrors: ALPHAPEPTDEEP_INSTRUMENTS (QE, Lumos, timsTOF, SciexTOF, ThermoTOF), PEPTDEEP_MAX_INSTRUMENT_NUM, instrumentIndex() with peptdeep's case-insensitive lookup, and validateInstrumentIndices(). PeptDeepRescoring and ProSE now build their valid-strings list from that array, which also adds the ThermoTOF slot the hand-written list was missing, and an unrecognised name lands on peptdeep's catch-all slot 7 instead of on Lumos. The range check is not redundant: ONNX's OneHot answers an out-of-range index with an all-off row, so a bad index does not fail, it quietly removes the instrument from the prediction. Rejecting it at the inference boundary is the only place it can be noticed. Verified against the artefacts rather than from the docs. The shipped peptdeep_ms2_dynamic.onnx (sha256 4141ea23..., the hash pinned in CMake) one-hots instrument_indices to width 8 and feeds it through meta_nn.nn [7,9] = 8 instrument slots + NCE, matching peptdeep's Meta_Embedding exactly; all 8 slots carry distinct trained weights. export_peptdeep_models_to_onnx.py now prints that table from model_const and fails the export if the graph's one-hot width stops agreeing with max_instrument_num, so a future peptdeep release that appends an instrument surfaces there. PeptDeepUtils.h moves to the unconditional header list. It is header-only and has no ONNX dependency, and ProSE has to register the same 'peptdeep:instrument' values in both builds for an ini file to keep its meaning. Not rebuilt here: WITH_ONNX is off by default and no CI workflow enables it, so none of this compiles in CI either. The new header was compiled and its assertions run standalone (g++ 13, -Wall -Wextra -Wpedantic), and the two new export-script helpers were run against the shipped model. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KPU24wdJgjAoyWYVuUU5FA * Resolve the PeptDeep models the way the library predictor does PeptDeepLibraryPredictor landed in #10380 with its own bundled-model lookup, so there were two different hints for finding the same three ONNX files. Use its one. Both work around the same real gap: CF_OPENMS_DATA_PATH is the *source* share/OpenMS, which carries no models/ because the models are downloaded into the build tree, so File::find needs a hint to see them there. The hint this dropped, File::getExecutablePath() + "../share/OpenMS", resolves from wherever the running binary sits -- correct for a TOPP tool in bin/, wrong for anything else, a class test among them. OPENMS_BINARY_PATH names the build tree itself, so it holds whatever is running. On an installed OpenMS it is a dead path and File::find falls through to getOpenMSDataPath(), which is where 'make install' puts the models; File::find still returns an absolute peptdeep:ms2_model/rt_model unchanged, so the parameters mean what they did. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KPU24wdJgjAoyWYVuUU5FA * Calibrate PeptDeep NCE and retention time on each spectrum's best target hit The calibration set was the better-scoring half of all hits. With several hits per spectrum (report:top_hits > 1, the usual setting for Percolator) it is mostly lower-ranked candidates and decoys: with ten hits per spectrum only 12-14% of it were best-ranked target hits on two runs of the OpenMS#10364 suite, and the retention-time fit followed them. Only the best-scoring hit of each spectrum, and only a non-decoy, is now a calibration candidate, so the calibration no longer depends on report:top_hits; with one hit per spectrum it changes only by leaving out the decoys. On the 20-file suite of OpenMS#10364 (report:top_hits 10), the median retention-time residual of the calibration set falls from 806 to 147 s on the Q Exactive HF-X files and from 1924 to 277 s on the Fusion Lumos LFQ files. Percolator PSMs at 1% FDR rise by 1.6% over all 20 files (7 files up, none down); rt_abs_error alone goes from +0.04% to +2.1% over develop. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D1N3pC2AqJt57Q3v87bWxz * [FEATURE,LOG] ProSE: peptdeep:enable fails instead of continuing without predictions (#10461) 'peptdeep:enable' is an explicit request, so ProSE now throws when it cannot be honoured: an OpenMS built without ONNX, missing/unloadable models, or no PSM receiving predicted features. PeptDeepRescoring reports '[PeptDeepRescoring] Predicted features added: N / M PSMs (<features>), NCE=<nce>' and exposes getNumPSMs()/getNumPredictedPSMs(). Co-authored-by: Copilot App <[email protected]> * [DOC] CHANGELOG: introduce Search:peptdeep:enable in the ProSE entry The entry only described the failure behaviour of #10461 relative to a warning that never shipped. Describe the parameter, its five features, its requirements and its measured cost instead, and keep the failure and log details. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01D1N3pC2AqJt57Q3v87bWxz --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Julianus Pfeuffer <[email protected]> Co-authored-by: Copilot App <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Stacked on #9975 (
claude/prose-onnx-rescoring-features-v2), which adds theSearch:peptdeep:*parameters. I based it on the head of #9975 because those parameters andPeptDeepRescoringdo not exist on develop yet. Once #9975 is merged, GitHub retargets this PR to develop.Search:peptdeep:enableis an explicit request. Without this PR, ProSE only warns when it cannot be honoured, and Percolator then rescores without the predicted features. With this PR, ProSE throws, with a non-zero exit code, if any of these holds:WITH_ONNX(InvalidParameter).share/OpenMS/models/peptdeep_*_dynamic.onnx, or the file given inSearch:peptdeep:ms2_model/rt_model. The missing-model case gives exit code 1,FileNotFound.MissingInformation).On success it logs one line that pipelines can check:
PeptDeepRescoring::getNumPSMs()andgetNumPredictedPSMs()expose the two counts.Compatibility with #10449 and #10450
I merged this branch with #10449 (in-process Percolator via
-rescore) and #10450 (-outidparquet), and with the other open quantms-dependency PRs: #10452, #10453, #10454 and #10455.On that merge, the PeptDeep features feed the internal rescoring:
ProSE -ini ProSE_6_fdr.ini ... -rescore -Search:peptdeep:enable truelogsRescoring 896 PSMs in-process with 30 features.and[ProSE] Percolator : rescored 1 / 1 file(s).... with 25 features.No code change was needed for that: #9975 stores the predictions as
extra_features, and the in-process path reads them.Tests
PeptDeepRescoring_test: checks the counters, including the empty-input and partial-run cases.WITH_ONNX:TOPP_ProSE_peptdeepchecks the summary line.TOPP_ProSE_peptdeep_no_annotation_failsandTOPP_ProSE_peptdeep_missing_model_failsuseWILL_FAIL.TOPP_ProSE_peptdeep_requires_onnx(WILL_FAIL).Results:
-DWITH_ONNX=ON(Homebrew ONNX Runtime): all ProSE, PeptDeep and TOPP_ProSE* tests pass.Supports bigbio/quantms#740, which turns PeptDeep rescoring on by default.