Skip to content

[FEATURE] ProSE: self-trained per-run fragment ion priors as Percolator features - #10366

Closed
timosachsenberg wants to merge 4 commits into
codex/native-cidfrom
feature/prose-self-trained-ion-priors
Closed

timosachsenberg wants to merge 4 commits into
codex/native-cidfrom
feature/prose-self-trained-ion-priors

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

Follow-up to #10335, stacked on codex/native-cid (the base should move to develop once that PR merges). Implements item 7 of the ProSE/ANDES gap review: self-trained fragment ion priors as Percolator features, without shipping a trained model.

What changes

  • New class FragmentIonLikelihoodModel: a per-run likelihood model of fragment ion presence and intensity rank. Every theoretical ion is placed in a context (prefix/suffix series × precursor charge bucket 1-2 / 3 / ≥4 × fragment charge 1 / ≥2 × 10 relative-position bins); its outcome is absence or one of 7 intensity-rank bins. Two count tables are kept: the ions of confident peptides (signal) and the ions of their reversed sequences matched against the same spectra (noise). finalize() turns both into smoothed probabilities with pseudo-count back-off (full context → series and charges → series → flat prior), so a few thousand PSMs suffice and unseen contexts stay finite. score() yields three additive features per PSM: the summed log-likelihood ratio of its ion outcomes, the explained presence (Σ P(present) over matched ions / over all ions) and the observed fraction of the top-k ions the run predicts as most likely.
  • ProSE: annotate:self_trained_ion_priors (off by default), annotate:ion_prior_train_fdr (0.01) and annotate:ion_prior_min_psms (100). After PeptideIndexing and before FDR, each file's best target hits at target-decoy competition q ≤ threshold of the native score train the model; every hit then receives ion_prior_llr, ion_prior_explained and ion_prior_topk_observed, appended to extra_features so PercolatorAdapter picks them up. The training set is recorded as ion_prior:trained / ion_prior:training_psms. Without decoys, or with too few confident PSMs, the features are 0 (the columns stay complete) and a warning is logged. All three search paths are covered; multi-file runs train per file.
  • Native scores, candidate selection and the reported hits are unchanged. A test pins this by comparing against the same search without the option.
  • pyOpenMS binding of the model with a test, CHANGELOG entry, ProSE tool documentation note.

Why

ANDES's strong-mode rescoring gains much of its yield from fragmentation-aware features. Shipping a trained intensity model is out of scope for OpenMS and instrument-dependent. A model learned from the run's own confident PSMs, with reversed sequences as the null hypothesis, gives Percolator a fragmentation-pattern feature that adapts to the instrument, activation and charge regime of every file, with no external dependency and no pre-trained tables.

Tests

  • FragmentIonLikelihoodModel_test: intensity ranks, rank bins, contexts, ion-name parsing (incl. z+1 and cross-link names), the training/finalize contract, the flat prior without observations, back-off to unseen contexts, feature semantics (true peptide vs reversed sequence, unseen peptide and charge, Da/ppm parity, top-k bounds, empty inputs) and exceptions.
  • ProSEAlgorithm_test: features on every hit with provenance, unchanged native search, best hits score higher than their alternatives; zero fallbacks for too few confident PSMs, an unreachable q-threshold and a search without decoys; chunked and multi-file runs (per-file and chunk-major) with identical per-file results for identical input files.
  • test_FragmentIonLikelihoodModel.py: training, scoring and the static helpers through the binding.
  • The four ProSE TOPP references gain the annotate:self_trained_ion_priors search-parameter entry; every identification, score and annotation line is unchanged.

FragmentIonLikelihoodModel_test, ProSEAlgorithm_test, HyperScore_test, FragmentIndex_test and all TOPP_ProSE_* tests pass locally on this branch (merged with the current codex/native-cid); the binding file compiles.

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

🤖 Generated with Claude Code

https://claude.ai/code/session_01UGKGwMtvsf72yELV4xNmAQ


Generated by Claude Code

Independent 20-file benchmark

Independently benchmarked each PR patch on common base c1b2f202742270273a045ef4b56e7aa346e9871f, using all 20 frozen files (8,000 DDA MS2/file), the same FASTAs, and Percolator 3.09.0 seeds 1/42/137 at q ≤ 0.01. PRs are applied separately, not stacked. Sources, applied Git tree IDs, effective patches, exact requested/resolved parameters, commands, logs, output checksums and all seed counts are in the reproduction supplement.

Instrument / acquisition n Base This PR Delta
Velos CID 3 2876.6 2890.1 +0.47%
HF-X HCD 3 4383.3 4386.6 +0.07%
Astral HCD 3 2162.1 2276.3 +5.28%
Lumos HCD LFQ 3 5479.4 5481.3 +0.03%
Lumos CID TMT 3 2398.9 2415.6 +0.69%
Exploris 480 TMTpro 3 2247.4 2285.9 +1.71%
timsTOF HT 2 1038.0 1030.7 -0.71%

For all 20 files, #10366 has identical native candidate/score TSVs and byte-identical normalized PINs after removing only its three added prior columns. The measured changes therefore come from rescoring features. Gains are modest and dataset-dependent; keep the existing opt-in scope pending stronger validation.

Measured heads: #10365 160412c13122c1ae2205580eeec5b43018f7a006, #10366 5f66ab7ee2b7e3487081838964b9491e7696a4b8, #10368 initial 9a3d57796d3ef685f66f9962e49e4c3c90e5ac58 and latest d21f55b2575c523b4f8be13f407a62b276819496. Follow-up heads #10365 79e08f2948f6000787d4eef992bb6b33572f5419 / #10366 6a29032936bb6e4d49c4fa40e712f4bbefd1cee0 differ only in CHANGELOG; runtime/test sources are identical. #10368's subnormal-intensity correction was rebuilt and rerun on all 20 files.

Reproduce using the pinned ZIP pr-ablation-reproduction.zip, SHA256 `ec8e4813196141bd6394690fe3a3bac96841f9c0c0e29b577f58a43fa919ab09`. Verify its manifest, then follow the README's commands (`prepare_sources.py`, `build.py`, `run.py`, `evaluate.py --require-complete --write`, and `intensity_control.py`). The original input bundle remains pinned at `a5705ec8e1cb19d40ebfa7bb16f6b5651aa1dc65`. [Per-file/seed results](https://raw.githubusercontent.com/OpenMS/OpenMS/d3e79df9b54c1d6be37e49e4eddcade16f9b556c/benchmark-reproduction/prose-andes/pr-ablation-20260930/per_file.tsv),`` per-group results, [comparison with pinned ANDES/Sage](https://raw.githubusercontent.com/OpenMS/OpenMS/d3e79df9b54c1d6be37e49e4eddcade16f9b556c/benchmark-reproduction/prose-andes/pr-ablation-20260930/cross_engine.tsv).`` No raw data or result table is silently substituted.

Counts are nominal-q yields, not independently validated true positives. Seeds are algorithmic repeats. The prior model trains within the same file before Percolator cross-validation; out-of-fold prior training / independent FDR validation remains untested. The native harness recompiles the affected algorithms against pinned pyOpenMS support; this is not a full TOPP/binding build. Timings under concurrent load are not a speed benchmark.

Full comparison: #10364.

timosachsenberg and others added 2 commits September 30, 2026 17:12
Add FragmentIonLikelihoodModel, a per-run likelihood model of fragment ion
presence and intensity rank per ion series, precursor charge, fragment charge
and relative cleavage position, with pseudo-count back-off so that a few
thousand PSMs suffice. ProSE trains it per file when
annotate:self_trained_ion_priors is set: the confident target PSMs (target-
decoy competition q <= annotate:ion_prior_train_fdr of the native score)
provide the signal counts, their reversed sequences matched against the same
spectra the noise counts. Every hit then receives the additive features
ion_prior_llr, ion_prior_explained and ion_prior_topk_observed, which are
listed in extra_features for Percolator; the training set is recorded as
ion_prior:trained and ion_prior:training_psms. Runs without decoys or with
fewer than annotate:ion_prior_min_psms confident PSMs get zeros and a
warning. Native scores and candidate selection are unchanged, and nothing is
pre-trained or shipped.

The annotation runs after PeptideIndexing and before FDR in all three search
paths (single, chunked, chunk-major multi-file), so each file of a multi-file
run learns its own fragmentation pattern.

Includes class tests for the model and the ProSE integration, a pyOpenMS
binding with a test, a CHANGELOG entry and the ProSE tool documentation.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UGKGwMtvsf72yELV4xNmAQ
…uracy entry

The new bullet had been inserted inside the mass_accuracy entry, so that
entry's last three lines read as part of the ion-prior bullet.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UGKGwMtvsf72yELV4xNmAQ
claude added 2 commits October 1, 2026 11:16
…erences

Every search now records annotate:self_trained_ion_priors in its search
parameters. Only this UserParam line is added to ProSE_1_out (also used by
the multi-file and chunked tests), ProSE_2_out, ProSE_4_out and
ProSE_10_out; every identification, score and annotation line is unchanged.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UGKGwMtvsf72yELV4xNmAQ

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #10378, the standalone port of this PR onto develop. It does not depend on #10335.

#10378 keeps this PR's class, tests and binding. On top it adds a clang build fix, fragment charges that follow the deisotoping decision, a cross-fitted model, and bounds checks. Its benchmark on the 20-file suite of #10364 and the entrapment checks are in its description.


Generated by Claude Code

timosachsenberg added a commit that referenced this pull request Oct 2, 2026
…or features

Add FragmentIonLikelihoodModel, a per-run likelihood model of fragment ion
presence and intensity rank per ion series, precursor charge, fragment charge
and relative cleavage position, with pseudo-count back-off so that a few
thousand PSMs suffice. ProSE trains it per file when
annotate:self_trained_ion_priors is set: the confident target PSMs (target-
decoy competition q <= annotate:ion_prior_train_fdr of the native score)
provide the signal counts, their reversed sequences matched against the same
spectra the noise counts. Every hit then receives the additive features
ion_prior_llr, ion_prior_explained and ion_prior_topk_observed, which are
listed in extra_features for Percolator; the training set is recorded as
ion_prior:trained and ion_prior:training_psms. Runs without decoys or with
fewer than annotate:ion_prior_min_psms confident PSMs get zeros and a
warning. Native scores and candidate selection are unchanged, and nothing is
pre-trained or shipped.

The annotation runs after PeptideIndexing and before FDR in all three search
paths (single, chunked, chunk-major multi-file), so each file of a multi-file
run learns its own fragmentation pattern. The model sees the singly charged
fragments native scoring matches.

Standalone version of #10366 on develop (previously stacked on #10335).
The search parameters record annotate:self_trained_ion_priors; the four ProSE
idXML references gain that line.

Includes class tests for the model and the ProSE integration, a pyOpenMS
binding with a test, a CHANGELOG entry and the ProSE tool documentation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01D1N3pC2AqJt57Q3v87bWxz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants