Skip to content

[FEATURE] ProSE: fit the mass-accuracy kernel center during calibration; calibration:enabled gains 'auto' - #10365

Closed
timosachsenberg wants to merge 5 commits into
codex/native-cidfrom
feature/prose-calibrated-mass-accuracy-kernel
Closed

timosachsenberg wants to merge 5 commits into
codex/native-cidfrom
feature/prose-calibrated-mass-accuracy-kernel

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 2 of the ProSE/ANDES gap review: the mass-accuracy kernel is fitted per run instead of assuming a Gaussian centered at zero, and calibration:enabled gains a resolution-aware auto mode.

What changes

  • runCalibrationPass_ also collects the signed ppm errors of the matched fragment ions of its confident PSMs (same score crop and precursor band as the tolerance estimates) and fits the kernel of scoring:method=mass_accuracy from them: center = median, width = 1.4826 × MAD (floored at 0.1 ppm), requiring at least max(calibration:min_psms, 50) matched ions. The main search centers its Gaussian on the fitted center and uses the fitted width only when it is wider than scoring:mass_error_sd; the fit never narrows the kernel. The calibration pass itself keeps scoring with the configured kernel, so the fit is not circular.
  • calibration:enabled gains auto: the pass runs for high-resolution fragment tolerances (≤ 0.1 Da / ≤ 100 ppm, the resolution proxy the scorer selection already uses) and is skipped otherwise. true and false keep their meaning, and false stays the default.
  • The kernel the main search used is recorded in the search parameters (scoring:mass_error_kernel = calibrated or configured, scoring:mass_error_sd_resolved, scoring:mass_error_shift_resolved) in all three search paths: single file, chunked, and chunk-major multi-file (per file).
  • HyperScore::computeMassAccuracy takes an optional kernel center (mass_error_shift_ppm, default 0, so existing calls are unchanged); new HyperScore::matchedFragmentErrorsPpm exposes the matched ions' signed errors. Both are bound in pyOpenMS.

Why

ANDES's rank-based scorer is insensitive to the fragment error distribution; ProSE's Gaussian kernel is only as good as its center. Real runs carry a residual calibration offset (−2.6 to +3.1 ppm across the 20 benchmark files below), so a kernel centered at zero penalizes every true fragment by the offset. Fitting the center from the run's own confident PSMs removes that.

Why the defaults changed after the first revision

The first revision made auto the default and used the fitted width as is. The independent 20-file benchmark below measured both:

  • Auto calibration cost rescored yield on unlabelled HCD and timsTOF data (HF-X −3.5%, Lumos LFQ −4.0%, timsTOF −2.5%) while helping Astral (+4.6%) and TMTpro (+1.7%). The losses come from the base's calibration pass, which tightens the precursor window to the 0.5–99.5% quantiles of the most confident isotope-error-0 PSMs and then applies it to every candidate; real PSMs with larger precursor errors (mostly with a nonzero isotope correction) never become candidates. Until that window gets a safety margin, calibration stays opt-in; auto remains available.
  • The fitted width (1.7–3.5 ppm on Orbitrap and Astral files, versus the configured 7 ppm) was rescoring-neutral but cost 3–38% of the native TDC yield per file: it is fitted on the intense, accurate fragments of the most confident PSMs and then penalizes the weaker true fragments of borderline PSMs. The fit therefore only widens the kernel now (timsTOF, where the fitted width is wider, gained natively).

Behaviour change

None with default parameters. With calibration:enabled=true or auto and scoring:method=mass_accuracy, the main search uses the fitted center and a width that is never narrower than scoring:mass_error_sd. An explicit scoring:mass_error_sd remains the kernel whenever no calibration ran or the fit had too few ions.

Tests

  • HyperScore_test: kernel center, matched-error helper, Da/ppm parity, empty and out-of-tolerance cases, exceptions.
  • ProSEAlgorithm_test: the default is off and auto follows the fragment tolerance resolution; the fit recovers a synthetic ~4 ppm shift with a narrow width; with a wider configured width the main search keeps that width and the fitted center, with a narrower configured width it widens to the fit; the recorded kernel and provenance in single-file, chunked and multi-file runs; an uncalibrated run keeps the configured kernel.
  • test_HyperScore_mass_accuracy.py: centered kernel and error helper through the binding.
  • The four ProSE TOPP references gain the three kernel provenance entries (scoring:mass_error_kernel, scoring:mass_error_sd_resolved, scoring:mass_error_shift_resolved); every identification, score and annotation line is unchanged.

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

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 2876.6 +0.00%
HF-X HCD 3 4383.3 4231.7 -3.46%
Astral HCD 3 2162.1 2262.3 +4.64%
Lumos HCD LFQ 3 5479.4 5261.7 -3.97%
Lumos CID TMT 3 2398.9 2398.9 +0.00%
Exploris 480 TMTpro 3 2247.4 2285.7 +1.70%
timsTOF HT 2 1038.0 1011.8 -2.52%

pr65_auto still uses HyperScore on high-resolution files, so its changes measure auto calibration, not the new mass-accuracy kernel. The separate kernel comparison below sets calibration=true and mass_accuracy on both sides and verifies identical calibrated tolerances. Do not enable auto calibration universally on the strength of the labelled-data gains: the matrix includes substantial unlabelled HCD losses. On lumos_lfq_5192, the mass window tightens from ±20 ppm to approximately −3.50/+3.11 ppm; 1,726/1,919 lost baseline assignments across the three seeds lie clearly outside that window, considering every isotope offset and a 0.05-ppm guard beyond rounded log bounds. Most of these exclusions involve a nonzero isotope correction. The diagnostic and its limits are saved in diagnostics/calibration_losses.json.

Group Fixed kernel Fitted kernel Rescored delta Native TDC delta
HF-X HCD 4206.7 4217.0 +0.25% -566.3
Astral HCD 2296.6 2292.2 -0.19% -571.7
Lumos HCD LFQ 5294.6 5299.1 +0.09% -160.3
Exploris 480 TMTpro 2267.3 2270.4 +0.14% -137.0
timsTOF HT 1003.8 1000.3 -0.35% +41.0

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.

claude and others added 2 commits September 30, 2026 16:40
…brate high-resolution searches by default

Collect the signed ppm errors of the matched ions of the calibration pass'
confident PSMs and fit the kernel of scoring:method=mass_accuracy from them:
the main search centers the Gaussian on their median and uses 1.4826 * MAD as
its width instead of the fixed scoring:mass_error_sd. The calibration pass
itself keeps scoring with the configured kernel. The kernel the main search
used is recorded in the search parameters, in all single-file, chunked and
chunk-major multi-file paths.

calibration:enabled gains 'auto', now the default: the pass runs for
high-resolution fragment tolerances (<= 0.1 Da / <= 100 ppm) and is skipped
otherwise, following the resolution proxy of the scorer selection.

HyperScore::computeMassAccuracy takes an optional kernel center and
HyperScore::matchedFragmentErrorsPpm exposes the matched ions' errors; both
are bound in pyOpenMS.

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

The calibration pass now fits the kernel center and width, so the earlier
entry's sentence contradicted the new one.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UGKGwMtvsf72yELV4xNmAQ
claude added 3 commits October 1, 2026 11:04
…ernel only widens

The independent 20-file benchmark of this PR showed that running the
calibration pass by default costs rescored yield on unlabelled HCD and
timsTOF data (HF-X -3.5%, Lumos LFQ -4.0%, timsTOF -2.5%): the base's
calibration tightens the precursor window to the 0.5-99.5% quantiles of
the most confident isotope-error-0 PSMs, and real PSMs outside that window
never become candidates. calibration:enabled therefore defaults to false
again; 'auto' stays available.

The fitted kernel width (1.7-3.5 ppm on Orbitrap and Astral files) was
rescoring-neutral but cost 3-38% of the native TDC yield per file: it is
fitted on the intense, accurate fragments of the most confident PSMs and
then penalizes the weaker true fragments of borderline PSMs. The main
search now uses the fitted width only when it is wider than
scoring:mass_error_sd; the fitted center is always used.

Tests cover the default, the kept configured width with a fitted center,
the widening to a wider fit, and the chunked and multi-file provenance.

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

Every search now records scoring:mass_error_kernel,
scoring:mass_error_sd_resolved and scoring:mass_error_shift_resolved in its
search parameters. Only these three UserParam lines are 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
@timosachsenberg timosachsenberg changed the title [FEATURE] ProSE: fit the mass-accuracy kernel during calibration and calibrate high-resolution searches by default [FEATURE] ProSE: fit the mass-accuracy kernel center during calibration; calibration:enabled gains 'auto' Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #10379, the standalone port of this PR onto develop. It carries the opt-in mass-accuracy scorer itself, so it does not depend on #10335.

#10379 also changes this PR's behaviour, based on the 20-file benchmark of #10364:

  • calibration:enabled=auto narrows only the fragment window and keeps the configured precursor window.
  • Calibration fits only the kernel center by default (scoring:mass_error_kernel_fit=shift).

As this PR stands, auto cost HF-X −3.3% and Lumos LFQ −4.2% of Percolator PSMs; #10379 reduces that to −0.9% and −0.4%. Whether auto becomes the default is still open on #10379.


Generated by Claude Code

timosachsenberg pushed a commit that referenced this pull request Oct 2, 2026
…ibrate high-resolution searches by default

Collect the signed ppm errors of the matched ions of the calibration pass'
confident PSMs and fit the kernel of scoring:method=mass_accuracy from them:
the main search centers the Gaussian on their median and uses 1.4826 * MAD as
its width instead of the fixed scoring:mass_error_sd (floored at 0.1 ppm; at
least max(calibration:min_psms, 50) matched ions). The calibration pass itself
keeps scoring with the configured kernel. The kernel the main search used is
recorded in the search parameters (scoring:mass_error_kernel,
scoring:mass_error_sd_resolved, scoring:mass_error_shift_resolved) in the
single-file, chunked and chunk-major multi-file paths.

calibration:enabled gains 'auto', now the default: the pass runs for
high-resolution fragment tolerances (<= 0.1 Da / <= 100 ppm, the resolution
proxy of the deisotoping choice) and is skipped otherwise; 'true' and 'false'
keep their meaning.

HyperScore::computeMassAccuracy takes an optional kernel center and
HyperScore::matchedFragmentErrorsPpm exposes the matched ions' errors; both
are bound in pyOpenMS.

Standalone version of #10365 on develop (previously stacked on #10335).

The four ProSE idXML references gain the three kernel lines (ProSE_4, which
calibrates, records its fitted kernel); hits are unchanged.

The parameter is no longer a true/false flag, so a bare -Search:calibration:enabled
is not read as 'true' by TOPPBase any more: the Bruker DDA calibration TOPP tests pass
'true' explicitly, and the uncalibrated Bruker DDA baseline pins 'false' to keep
measuring what its PSM floor was set for.

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