Skip to content

[FIX] Correct FLASH averagine normalization and isotope cosine - #10543

Merged
poshul merged 2 commits into
OpenMS:developfrom
poshul:fix/flash-averagine-norm
Oct 13, 2026
Merged

poshul merged 2 commits into
OpenMS:developfrom
poshul:fix/flash-averagine-norm

Conversation

@poshul

@poshul poshul commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

FLASH averagine trimming counted the boundary isotope as removed even when trimming stopped before removing it. Normalizing by that underestimated retained power inflated both peptide and RNA model norms and affected the SNR multiplier. Count power only for isotopes actually trimmed. The public isotope cosine also measures both vector norms, accumulates in double precision and bounds numerical roundoff, preventing values above one from producing negative noise power.

The fixes use the existing FLASHHelperClasses and SpectralDeconvolution class tests; no new test file or target. This is a standalone library correctness change, separated from the NASE FLASH feature stack (#10531–#10533).

Validation (Linux Release, GCC14/C++23): FLASHHelperClasses, SpectralDeconvolution, PeakGroup and TOPP_FLASHDeconv_1 pass. Across 199 sampled masses per model, maximum squared-norm error changes from 0.002904 to 1.63e-7 for peptides and 0.003322 to 1.37e-7 for RNA. Regression tests independently check the retained-model SNR multiplier and a non-normalized vector cosine.

Before/after FLASHDeconv runs use the identical existing FLASHDeconv_sample_input1.mzML, default parameters and one thread. The output changes from 34 to 33 MS1 envelopes. The 33 shared envelopes keep their masses, charges and recruited peaks, but cosine/SNR/Qscore values change; the missing envelope is near 2911.12 Da in scan 562. This comparison is a small fixture, not proof of unchanged full-dataset results or improved identification accuracy. Existing frozen NASE experiments are preserved. This numeric behavior change needs FLASH maintainer review.

@timosachsenberg timosachsenberg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The averagine power is now subtracted only for isotopes that are actually trimmed, so templates have unit norm, and the new tests check that. Non-blocking: add a CHANGELOG entry, since FLASHDeconv scores change (34 → 33 envelopes on the sample input), and add #include <algorithm> for std::clamp. The PR still needs to be marked ready for review.


Generated by Claude Code

@poshul
poshul marked this pull request as ready for review October 13, 2026 13:42
@poshul
poshul merged commit 1381c50 into OpenMS:develop Oct 13, 2026
31 of 32 checks passed
timosachsenberg pushed a commit that referenced this pull request Oct 13, 2026
Conflicts and ports to the owning model:
- #10519: exact score ties. Run::retainBest() without ties (IDFilter::keepBestMatchPerObservation, the
  counterpart of getBestMatchPerObservation) keeps the first match in value order (encoding, representation,
  charge, adduct) instead of the first match, so the choice does not depend on the order of the matches and
  prefers neither targets nor decoys. QueryMatches::getBestMatch() keeps the first of equal matches, as the
  stable PeptideIdentification::sort() does. Legacy export keeps the order of the matches (exact round trips);
  NucleicAcidSearchEngine adds its matches in value order.
- #10519 in NucleicAcidSearchEngine: hits sorted by value before registration, ambiguity variants merged
  within each precursor hypothesis, complete tie groups at report:top_hits, finite LFQ retention times; a
  cached digest also gives the oligo lengths and enzyme specificity of the run (tolerances and modifications
  are those of the search). Processing actions and OMS schema 6 have no counterpart (no processing steps; .oms
  is removed). The new NASEDigestion_test sections use digest entries, adduct values, native bundles and a
  run of the owning model; IdentificationData_test checks the tie order of retainBest().
- #10537: RNaseCleavageSensitiveModGroups returns copies and inferCleavageSensitiveMods() resolves registered
  definitions, next to the DigestedOligo binding of this branch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B51nRFoHvZuVXD7cT8XZav
timosachsenberg pushed a commit that referenced this pull request Oct 13, 2026
…, #10470 QualityControl sort)

QualityControl_1_out.consensusXML/.mzTab conflicted: this branch changed them for the
identification-data IDConflictResolverAlgorithm (148ce81), #10470 for the best-first order of a
feature's identifications with lower-is-better scores. This merge keeps this branch's files; the
QualityControl test of the merged code decides whether #10470's order changes them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B51nRFoHvZuVXD7cT8XZav
timosachsenberg added a commit that referenced this pull request Oct 15, 2026
Combines the entries of the open CHANGELOG pull requests #10387, #10483,
#10511, #10535, #10555 and #10580 into one change on top of develop, and
covers #10252 and #10267, whose edits develop already carries.

- OpenMS Library: PeptDeepLibraryPredictor (#10380),
  OpenSwathLibraryPreparation (#10373), BedRModFile (#10529), FLASH
  averagine/cosine fix (#10543), WebAssembly-found fixes (#10558),
  MzMLSqliteHandler array length check (#10471), Percolator data race
  (#10474). #10471 and #10543 were each proposed by two of the PRs; they
  appear once.
- TOPP tools: OpenDIA as a new tool (#10373), qualified by the review on
  #10387 (peptidoform inference needs workflow:working_format sqlite), and
  the NucleicAcidSearchEngine options of #10526, #10529-#10532, moved from
  the top of the release block into the tool's section together with the
  NucleicAcidSearchEngine bullet that sat there outside any section.
- Restore the ProteomicsLFQ -feat_dir entry (#10481, #10486) and the three
  FileInfo entries (#10497, #10498, #10499) that the merge of #10470
  dropped, and remove the second copy of the -write_cwl entry it added
  (cited #10459, tab indentation replaced by spaces).
- Build System: ONNX Runtime versioned files and symlinks (#10465).
- 3.6.0: #10255 made WITH_WNETALIGN opt-in; it did not change the ONNX
  Runtime requirement (review on #10267).


Claude-Session: https://claude.ai/code/session_01QfTdEQjN4tBfS49WcriPYu

Co-authored-by: Claude <[email protected]>
KyowonJeong pushed a commit to t0mdavid-m/OpenMS that referenced this pull request Nov 18, 2026
…S#10543)

* [FIX] Normalize retained FLASH averagine isotope power

* [FIX,TEST] Normalize both vectors in FLASH isotope cosine

Backported from OpenMS develop (Samuel Wein, 1381c50). The same normalisation and clamping is applied to the inlined cosine
of SpectralDeconvolution::getIsotopeCosineAndIsoOffset, which copied getCosine for speed. Eclipse lysates 1476/1479/1480:
5244 -> 5241 proteoforms, 1006 -> 1004 proteins, entrapment 0.55% unchanged; native test set unchanged (35/43, null 0).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
KyowonJeong pushed a commit to t0mdavid-m/OpenMS that referenced this pull request Nov 18, 2026
…S#10543)

* [FIX] Normalize retained FLASH averagine isotope power

* [FIX,TEST] Normalize both vectors in FLASH isotope cosine

Backported from OpenMS develop (Samuel Wein, 1381c50). The same normalisation and clamping is applied to the inlined cosine
of SpectralDeconvolution::getIsotopeCosineAndIsoOffset, which copied getCosine for speed. Eclipse lysates 1476/1479/1480:
5244 -> 5241 proteoforms, 1006 -> 1004 proteins, entrapment 0.55% unchanged; native test set unchanged (35/43, null 0).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
KyowonJeong added a commit to t0mdavid-m/OpenMS that referenced this pull request Nov 18, 2026
…Deconv SD:precursor_mass

FLASHTnT -target <fasta>: the proteins known to be in the sample (e.g. a purified protein or a construct), without decoys. Needs a
FASTA -db with decoys. A target protein whose sequence is in -db is that entry; any other is added for the run with a decoy of its own
(shuffled, the first two residues kept). The search is unchanged. With -native, a target protein that the search did not report in a
spectrum is characterized there in a target round after the search: its sequence-tag and sliding-ladder candidates are extended whatever
their decoy margin, annotated on the raw spectrum and appended; they remove no masses, exclude no protein and enter none of the tests of
the search. The PrSM and proteoform files get, only with -target, the columns TargetProtein (0: not a target protein; 1: reported by the
search; 2: characterized on request only) and DecoyMargin (candidate score minus the best decoy candidate of the same source in the
spectrum). Without -target the outputs are unchanged (native test spectra byte-identical).

FLASHDeconv SD:precursor_mass: the mass of the isolated precursor ion (the whole complex if one was isolated), for when the mass is
known and the charge is not. With precursor_charge 0, the charge of each MSn spectrum is round(precursor_mass / (precursor m/z - proton
mass)), and everything else is as with precursor_charge at that charge.

The expected outputs of TOPP_FLASHDeconv_9 and TOPP_FLASHTnT_1/_2 already differ since OpenMS#10543 (not changed here).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
KyowonJeong added a commit to t0mdavid-m/OpenMS that referenced this pull request Nov 18, 2026
…Deconv SD:precursor_mass

FLASHTnT -target <fasta>: the proteins known to be in the sample (e.g. a purified protein or a construct), without decoys. Needs a
FASTA -db with decoys. A target protein whose sequence is in -db is that entry; any other is added for the run with a decoy of its own
(shuffled, the first two residues kept). The search is unchanged. With -native, a target protein that the search did not report in a
spectrum is characterized there in a target round after the search: its sequence-tag and sliding-ladder candidates are extended whatever
their decoy margin, annotated on the raw spectrum and appended; they remove no masses, exclude no protein and enter none of the tests of
the search. The PrSM and proteoform files get, only with -target, the columns TargetProtein (0: not a target protein; 1: reported by the
search; 2: characterized on request only) and DecoyMargin (candidate score minus the best decoy candidate of the same source in the
spectrum). Without -target the outputs are unchanged (native test spectra byte-identical).

FLASHDeconv SD:precursor_mass: the mass of the isolated precursor ion (the whole complex if one was isolated), for when the mass is
known and the charge is not. With precursor_charge 0, the charge of each MSn spectrum is round(precursor_mass / (precursor m/z - proton
mass)), and everything else is as with precursor_charge at that charge.

The expected outputs of TOPP_FLASHDeconv_9 and TOPP_FLASHTnT_1/_2 already differ since OpenMS#10543 (not changed here).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
KyowonJeong added a commit to t0mdavid-m/OpenMS that referenced this pull request Nov 18, 2026
…ll apart are decided by a farther isotope

In MSn a candidate at charge z is accepted on its neighbouring isotope peak, but the check was skipped when that peak
cannot tell z from z +- 1 (their isotope positions within the tolerance: m/z x z x (z + 1) above about 100,000 at
10 ppm). There only a chain of consecutive charges in the same mass bin was left, and large, high-charge fragments
were lost. Now the nearest isotope that does tell the charges apart is required, with all isotopes up to it present
(within the isotope count of the averagine). MS1 is unchanged.

Fragment level: on Eclip_1480, FLASHDeconv reports 64% instead of 16% of the b and y fragments TopFD finds in that
zone (charges 10-20; 82% elsewhere), and complementary-pair supported masses per spectrum go from 5.41 to 5.73. On
the expert annotation of PXD018043 (30 FT-ICR MS2 spectra), precision / recall at Qscore >= 0.5 go from 0.68 / 0.42
to 0.75 / 0.46 (TopFD 0.73 / 0.47). On 25 native MS2 spectra, fragments of the known proteins against shuffled
decoys at equal depth: 1159 / 109 -> 1296 / 137 (IsoDec 1128 / 116).
Identifications are unchanged: three Eclipse lysates 5241 proteoforms / 1004 proteins -> 5256 / 1002, entrapment
proteoforms 0.55% -> 0.60% (proteins 7 -> 10 of about 990); native test set 36 -> 35 of 43 expected proteins, one
null-database call as before. The new fragments fall in spectra that were identified already (96%), and the
raw-spectrum scoring saw them before. FLASHDeconv and FLASHTnT run times unchanged.

TOPP_FLASHTnT_3 expected outputs regenerated. TOPP_FLASHDeconv_9_out1-4 and TOPP_FLASHTnT_1/_2 fail as before this
commit (expected files not regenerated since OpenMS#10543).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
KyowonJeong added a commit to t0mdavid-m/OpenMS that referenced this pull request Nov 18, 2026
… MSn without its parent spectrum, -iq:correction_matrix

Output only; deconvolved masses and identifications are unchanged (Eclip_1480, FLASHTnT defaults: PrSM and proteoform tables
byte-identical to e9336d7).

1. Precursor window share (spectrum TSV and -out_quant). The writers looked the precursor up among the masses of its isolation window
   by an exact mass match (0.0001 Da). Since the precursor takes the mass of its MS1 feature (a2685a1) the match failed and the
   precursor's window intensity and share were written as 0. The precursor is now the window mass nearest to the precursor mass within
   10 ppm, the same isotope before a neighbouring one (one helper, windowMasses, for both writers). One iodoTMT6 run (E. coli ratio,
   9904 MS2 with a precursor): window intensity 0 in 8081 before, 32 now; all other columns and files identical.

2. -iq on an MSn (n > 2) spectrum whose MS(n-1) spectrum is not in the file (e.g. a file of MS3 reporter scans only): the channel
   extractor threw and FLASHDeconv stopped. Such spectra are now passed to the extractor as MS2 spectra on a copy of the experiment
   and quantified by their own reporter ions; a spectrum above MS1 without precursor information is left out. Both cases are reported
   as warnings. Files without such spectra are passed as before.

3. New option -iq:correction_matrix: the reporter ion impurities of the reagent lot replace the matrix built into the method of
   -iq:type (tmt6plex: TMTsixplex lot ZE386964). The same values as the built-in matrix give identical output; a wrong number of
   entries or values stops the tool with an error. Reagents that share the reporter masses but not the impurities of a method
   (iodoTMTsixplex with tmt6plex) need their own lot's values.

TOPP tests: no expected output changes; the nine tests failing since OpenMS#10543 (FLASHDeconv_9_out1-4, FLASHTnT_1_out1-3, FLASHTnT_2_out1-2)
fail as before.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
KyowonJeong added a commit to t0mdavid-m/OpenMS that referenced this pull request Nov 18, 2026
… a proteoform takes at least its protein's q-value

Entrapment proteins of the final rerun (50350f9) stood at 1.42 % on three E. coli lysates (B. theta entrapment, three decoy seeds).
Most of the calls were one protein, the 50S ribosomal protein L11 of B. theta (59 % identical to that of E. coli, 12 identical residues
in a row), reported in 8 of 9 runs from spectra of oxidised E. coli L11: its PrSM (+62.058 Da on residues 1-17) holds the b ions of
E. coli L11 with the known N-terminus (Met loss and two trimethylations, -46.947 Da).

1. FLASHExtender. The suffix and prefix paths of a PrSM without a mass are paired within max_blind_mod_count blind shifts. When each
   path needs a shift of its own no pair exists, and the path of the suffix mode, set when only that mode had run, stayed whatever the
   prefix path scored (E. coli L11, Eclip_1479 scan 7554: prefix 101, suffix 19; the hit was then dropped for having no tag on its
   path). Now the better path alone is taken. Such a one-sided PrSM with a shift is not reported (as before), but it is remembered
   (2). Letting each path carry its own shift in every PrSM was tried and rejected: the decoys gain the same freedom (three lysates
   1002 -> 964 proteins, 5256 -> 5158 proteoforms).

2. FLASHTnT, similar proteins. Per spectrum, the best PrSMs of up to three other proteins than the reported one, and the one-sided
   PrSMs with a blind shift that are not reported, are remembered. Before the FDR, a reported PrSM without a mass whose tags all lie in
   stretches of at least 8 residues that its protein has in common with another protein is replaced by that protein's remembered PrSM
   of the spectrum, when that protein has a PrSM with a mass in the run that scores above every PrSM with a mass of the first protein.
   The PrSM that comes in is classed and counted like any other. A tag anywhere in the other protein is not enough: 12 of 1002 E. coli
   proteins were taken for DnaK, RNase E, EF-G and the like by tags of four or five residues. Not with -native.

3. FLASHTnT, proteoform q-values. A proteoform's q-value is not below that of its protein. The proteoform classes with a mass are
   nearly free of decoys, so their q-values pass low-scoring proteoforms that the protein level does not accept; on the reference runs
   such proteoforms were 1.4-1.8 % of the E. coli proteoforms and held most of the entrapment proteoforms (lysates 61 of 87). Not with
   -native.

Against 50350f9, same commands (proteoforms / proteins at 1 %; entrapment = B. theta share x (1 + 1/1.368)):
  three lysates, E. coli            5256 / 1002  ->  5182 / 1004 (no protein lost)
  three lysates, entrapment x3      proteoforms 0.98 -> 0.17 % (87 -> 15), proteins 1.42 -> 0.89 % (24 -> 15), E. coli proteins 2905 -> 2918
  CZE PXD007273 (held out)          1315 / 398 -> 1293 / 398; entrapment proteoforms 0.83 -> 0.33 %, proteins 1.08 -> 1.08 %
  AI-ETD PXD012247 (held out)       3975 / 1375 -> 3917 / 1380; entrapment proteoforms 1.09 -> 0.62 %, proteins 0.92 -> 0.76 %
Proteins moved to their similar protein: L11, L7/L12, DnaK and an AhpC homolog of B. theta to the E. coli proteins; among E. coli
paralogs EF-Tu 1/2, HU alpha/beta, the cold shock proteins, TdcF/RidA. One chimeric round (-chimeric_rounds 1) on top was tried and
not adopted: +205 proteoforms on the lysates, 6.0 % entrapment among the residual-round proteoforms.

TOPP tests: no expected output changes; the nine tests failing since OpenMS#10543 fail as before.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
KyowonJeong added a commit to t0mdavid-m/OpenMS that referenced this pull request Nov 19, 2026
…with an undetermined terminus needs twice the margin

A sliding ladder places a protein by masses read from any start or to any end of it. When the PrSM has no proteoform mass and one of
its termini rests on no fragments of its own (open after the extension, or the terminal fragment envelopes of that side on the raw
spectrum at chance, the test of setNativeTermini_), only the ladder's score separates it from a window of a random protein. On the 58
native development spectra and the 52 external files at b8f7cd4, all five null-database calls were such ladders (margins 2.8-3.1);
sequence-tag PrSMs gave none. Such a PrSM now needs native_margin + run_margin (5.0 + log10 N) instead of run_margin. Sequence tags,
precursor ladders, ladders with both termini determined, PrSMs with a mass and target-round PrSMs are unchanged. The candidate margin is
kept on every native candidate (NativeMargin; the DecoyMargin column still only with -target); the chance test of the sides is a helper
(nativeSidesAtChance_) shared with setNativeTermini_. Native mode only; the default mode is unchanged (first-set default runs identical).

Against b8f7cd4 (analysis/20261016/native_ladder_1119; natalt/ladder_rule):
- 25 native spectra (first set): expected proteins 35 -> 34 of 43 (infliximab subunit 1 in inf90, margin 2.8, C side at chance), other
  proteins 4 -> 3, null-database calls 1 -> 0 (YADN_ECOLI in NISTmAb_6), mAb chains 19 -> 18 of 20 (infliximab subunit 1 in inf60, 4.6).
- Set H (33 spectra): named proteins 27 of 27 unchanged, other proteins 20 -> 16 (TPX, ENO, CYSA, YBIO), null calls 1 -> 0 (Q8A535_BACTN).
- 20 public fragmentation files: expected protein in 14 unchanged, other proteins 6 -> 4, null calls 1 -> 0 (YDHS_ECOLI, BR2_L7; also
  CH60-less GroEL_MS1_L5b intact-mass file 1 -> 0). 27 precisION files: expected protein in 21 unchanged, null calls 1 -> 0 (RL31_ECOLI).
- Spectra of the expected proteins in the external files 6123 -> 6048 (ADH_L7 -55, GroEL_L7 -16; no file loses its protein).
TOPP tests: no expected output changes; the five FLASHTnT tests failing since OpenMS#10543 fail as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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