Release/4.0 - #265
Merged
Merged
Conversation
…into spectrum-feature-generator
…into spectrum-feature-generator
…into spectrum-feature-generator
…trum-feature-generator
pull main in spectrum-feature-generator
…pectrum-feature-generator
…mics/ms2rescore into spectrum-feature-generator
…nal API surface - Fix rescore() always returning empty feature_weights/n_iterations: it rebuilds the final result via ristretto.evaluate() (no training, so those fields come back empty), discarding the real values from the earlier ristretto.rescore() call. Now carried over explicitly, including through the constant-PEP fix path. Regression test added. - Drop the "ristretto"/"rescore" infix from rescoring-table filenames (<prefix>.psms.tsv, .peptidoforms.tsv, .peptides.tsv, .proteins.tsv, .weights.tsv) and rename the main PSM list output from <prefix>.psms.tsv to <prefix>.tsv, freeing up the naming collision. Docs and tests updated. - Remove PIN file output for disabled rescoring/DEBUG mode: the main PSM list TSV already carries all rescoring features, and PIN/Percolator format is no longer relevant since the ristretto migration. - Simplify USI handling: build the (run, spectrum_id) -> USI lookup once and reuse it for both the early before_result remap and the later psm_list rename, instead of generating USIs twice. Also fixes a latent bug where the two passes used mismatched row indices when mumble is enabled. Inlined the one-line USI construction and removed the now-unused spectrum_usi helper. - Report text: chart descriptions in texts.toml hardcoded "1% FDR threshold", which became wrong once report_fdr became configurable. Now templated with the actual configured value. - Docs: swap the train_fdr example from 0.1% to 10%, more representative of a difficult dataset where the 1% default yields no accepted PSMs; fix a stale ms2rescore-report CLI usage example. - GUI: word-wrap the rescoring model description like other Advanced tab descriptions. - Minimize internal API surface: rename utils.py to _utils.py (mirroring the existing _version.py convention) and merge rescoring.py's functions into it, since none of it is used outside ms2rescore's own submodules -- make that explicit rather than presenting it as public API. Also privatized build_features_dataframe and fix_constant_pep, which were only ever called internally within the rescoring workflow itself.
The GUI's logging setup only ever attached a plain FileHandler for <prefix>.log.txt -- unlike the CLI, it never used a recording Rich console or called save_html(), so <prefix>.log.html (documented as always written) was silently never created for GUI-launched runs. Added the same Console(record=True) + RichHandler + save_html() pattern the CLI already uses, wrapped around the rescore() call so the HTML log is written even if the run raises. Also add an INFO-level log line when rescoring actually starts, since the per-fold/rollup/competition detail ristretto itself logs is moving to DEBUG level (fixed at the source, in ristretto).
Cumulative summary of the mokapot -> ristretto rescoring engine migration (report_fdr, model choice, auto score-direction inference, output-file renames, GUI log.html fix, and the resulting config/API removals), merged into the existing Unreleased section.
Review findings from the cumulative-diff review, addressed: - rescoring: null never actually disabled rescoring (CascadeConfig's none_overrides_value=False silently ignores it), and the "skip rescoring" path that was reachable only in principle would have written no output at all. Rather than fix the cascade-merge bug, remove the skip-rescoring feature entirely: rescoring always runs, the null option is dropped from the schema (now a validation error instead of a silent no-op), and docs updated to match. - infer_score_direction() now groups by run (matching _build_features_dataframe's existing guard), so multi-file input with colliding native spectrum/scan IDs across runs no longer risks corrupting the inferred score direction. Added direct unit tests, including one confirming run_col reaches ristretto.evaluate(). - Simplified the `config["rescoring"].get(...) if config["rescoring"] else 0.01` ternary in parse_psms.py/_utils.py to a plain .get() -- config["rescoring"] can no longer be None after config parsing. - Removed stale mokapot/rescoring_engine definitions from docs/source/config_schema.md (hand-maintained schema reference). Also reformats CHANGELOG.md's "Breaking changes" section (non-standard Keep a Changelog category) into the canonical Added/Changed/Removed sections, with breaking items tagged [BREAKING].
Replace mokapot rescoring engine with ristretto
…into fix/rescoring-module
…s2rescore into fix/docs-after-ristretto
Move package-level private rescoring functions to new module _ristretto_utils.py
…into fix/docs-after-ristretto
Fix /docs after ristretto integration
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.
MS²Rescore 4.0.0
This PR prepares the stable MS²Rescore 4.0.0 release. It consolidates the extensive feature-generation, prediction, rescoring, reporting, and configuration refactors developed through the 3.3 alpha series into a single stable release.
The version was increased to 4.0.0 because the release introduces substantial user-visible and breaking changes. Most notably, MS²Rescore now uses ristretto as its integrated rescoring implementation, centralizes spectrum annotation, adopts the latest DeepLC, IM2Deep, MS²PIP, and
ms2rescore-rsAPIs, and substantially revises its configuration and output files.Breaking changes
engine, and rescoring always runs. The
rescoring_engineoption has been removed and replacedby the
rescoringconfiguration block, withtrain_fdrandmodel(svmorlda) options.Removes both the external
percolatorbinary dependency and themokapotdependency.per-run linear CCS calibration, IMS fine-tuning folded in), ms2rescore-rs 0.5 API
(
score_ms2_spectra, centralizedannotate_spectra()— every PSM's spectrum is nowannotated once before feature generators run, not per generator).
ionmobfeature generator removed (superseded by IM2Deep v2).maxquantfeature generatorremoved (its features folded into the
ms2generator).MS2PIPFeatureGenerator/MS2FeatureGenerator:ms2_tolerance,spectrum_path,spectrum_id_pattern,mass_mode,processesparams removed — fragment tolerance is now setglobally via top-level
tolerance_value/tolerance_mode(default0.02 Da, fixing a priorfallback bug where it silently defaulted to
20 ppm).lower_score_is_betterremoved — search-engine score direction is now inferred automaticallyper run through spectrum-competed target-decoy evaluation.
fasta_file,write_rescoring_tables, and the mokapot-specificwrite_weights,write_txt,and
protein_kwargsoptions removed. Rescoring result tables are always written, andprotein-level results use ristretto's picked-protein competition when
id_decoy_patternisconfigured. While top-level
fasta_fileoption and mokapot-based FASTA protein inference have been removed, this does not affect Mumble's nestedpsm_generator.mumble.fasta_fileoption, which is used when validating amino-acid-combination candidates.rescoring: nullis rejected by config validation insteadof being silently ignored.
<prefix>.psms.tsvto<prefix>.tsv; crash-recovery output renamedto
<prefix>.intermediate.tsv.ms2rescore.utilsis no longer part of the public API. General internal helpers now reside inms2rescore._utils, with ristretto-specific integration helpers inms2rescore._ristretto_utils.Changed
max_psm_rank_output > 1now applies consistently across the main output, rescoring tables,and report. Multiple ranked PSMs are retained per spectrum, with q-values and PEPs evaluated
over the retained rows rather than through full spectrum competition. This mode is intended
for inspecting ambiguous candidates, such as Mumble candidates, and should not be interpreted
as a statistically rigorous spectrum-level FDR-controlled count.
provenance information in the main PSM TSV, including during standalone report generation.
New
ms2feature generator (Rust,ms2rescore_rs): direct-spectrum features (matched ioncounts/percentages, hyperscore, intensity ratios), ion series expanded to a/b/c/x/y/z.
ristretto-ms, with semi-supervised SVM and faster LDAmodels, configurable training FDR, run-aware spectrum competition, and PSM-, peptidoform-,
peptide-, and protein-level result tables.
spectrum IDs across multiple input files do not interfere with the inferred direction.
report_fdroption controlling console identification counts, HTML reportstatistics and charts, and FlashLFQ filtering.
ms2rescore-report --fdroption for regenerating reports at a different FDR threshold withoutrerunning feature generation or rescoring.
ms2rescore[mumble],>=0.3.0) for exploringmass-shift candidate peptidoforms pre-rescoring, with a full user-guide page and corrected
config schema. Mumble remains beta software.
peptidoformandCCScolumns.<prefix>.intermediate.tsvon error) and skip-if-already-presentfeature generators, so a crashed run can resume without recomputing everything.
<prefix>.psms.tsv,.peptidoforms.tsv,.peptides.tsv,.proteins.tsv,.weights.tsv) are always written as plain TSV files, independent ofrescoring engine internals.
GUI runs now also write an HTML log file (
<prefix>.log.html), matching the CLI.realistic regressions, not just detect change, together with end-to-end rescoring,
report-generation, and ristretto integration tests.
corresponding original PSM are removed before rescoring.
configuration error listing the available generators.
Fixed
max_psm_rank_input > 1(missing per-PSM annotation / missingsort_index()after q-valuesort).
intensities length X != peak count Y): observed-spectrum dedup keyedon
spectrum_idalone, which Sage'sscan=NIDs repeat across runs — now keyed on(run, spectrum_id)(fixed upstream in ms2pip 4.2.0, pulled in here).basicfeature generator: missing precursor m/z or search-engine score producedNaNinsteadof the documented
0(None not in ...check never fired against float64 NaN arrays).the run; now selects the best head per run.
(each candidate inherits the original PSM's score/q-value via
deepcopy, so calibrationcouldn't tell an unconfirmed candidate from the confirmed hit) — now filtered out via
get_original_hit_mask().FileNotFoundErrorbecause thefile-existence check was inverted.
Nonevalues;processes=-1(our default) was passed straight toDeepLC's
num_threads, which requires a positive int orNone; numpy 2.0 compatibility(
np.trapz→np.trapezoid).rescoringdictionaries raisedKeyErrorinstead of falling back toristretto defaults.
weight and iteration outputs.
and reconstructing pre-rescoring results could mutate the original PSM objects.
spectrum_id; these now consistently key on(run, spectrum_id).psm_id_patternuniqueness validation incorrectly treated identical spectrum IDs in separateruns as collisions.
annotation settings, or the DeepLC
epochsoption.<prefix>.log.html), unlike CLI runs — the GUI'slogging setup only ever attached a plain text-file handler.
Docs
New Mumble user-guide page, corrected
config_schema.md/.json(previous Mumble defaults werewrong and missing several real parameters),
"Optional dependencies"section ininstallation.rst,"Configuring PSM generators"section inconfiguration.rst, tie-breakcaveat for
max_psm_rank_output: 1with Mumble enabled (candidates can score identically;selection isn't a meaningful tie-break), and updated configuration and migration documentation
for ristretto, centralized spectrum annotation, output file changes,
report_fdr, and automaticscore-direction inference.
Dependencies
Dependencies finalized to
ms2pip>=4.2.0,ms2rescore_rs>=0.5.0,im2deep>=2.0.1,ristretto-ms>=0.3.0, and optionalmumble>=0.3.0.deeplc>=4.0.0b1continues to allow theDeepLC v4 beta rather than blocking on a stable release. Added
pyarrow>=14.