Repository navigation
quant: isobaric reporter (--tmt) and label-free MS1 (--lfq) quant - #119
timosachsenberg wants to merge 8 commits into
Conversation
…ation
andes now quantifies the confident rank-1 PSMs inside the search run, at the
feature level, and leaves normalization, protein roll-up and statistics to
quantms / OpenMS.
New crate `quant` (pure algorithms over peak lists):
- isobaric: TMT 6/10/11/16/18 and iTRAQ 4/8 channel tables (OpenMS values),
most-intense-peak reporter extraction within a tolerance, the OpenMS text
impurity sheet (4 and 8 column forms) parsed into observed = M * true and
solved by Lawson-Hanson NNLS, as IsobaricIsotopeCorrector does.
- purity: precursor isolation purity from the preceding MS1 scan (isotope
ladder at 10 ppm, the PrecursorPurity rule).
- ms1_index / xic / lfq: a run's MS1 scans indexed by RT; four isotope
chromatograms per target, Savitzky-Golay smoothing, apex climbed from the
PSM's scan, boundaries at the first valley or 2 % of the apex, trapezoid
areas; envelope cosine against the peptide's formula-derived theoretical
envelope (formula.rs; modification deltas as averagine atoms).
- tdc: picked target/decoy competition against a twin extracted 11 Th above
each target, giving a feature q-value (IonQuant's ion-level scheme).
Readers: the mzML reader captures every MS1 scan (RT + centroids) and MS3+
scans with their `<precursor spectrumRef>` on request, without emitting them
as searchable spectra; the Thermo reader does the same (master scan via the
precursor's parent index). New `model::scan::{Ms1Scan, ProductScan}`.
Driver: `--tmt <plex>`, `--tmt-level 2|3`, `--tmt-tol`, `--tmt-correction`,
`--tmt-min-purity`, `--lfq`, `--lfq-tol`, `--lfq-rt-window`,
`--lfq-min-cosine`, `--lfq-feature-fdr`, `--quant-fdr`, plus a `quant:`
group in the YAML config. Reporter ions are read from each MS2 while its
peaks are in memory; quantification runs after rescoring on PSMs at
q <= --quant-fdr (every rank-1 target PSM, with a warning, without
rescoring). `--lfq` / `--tmt-level 3` need mzML or .raw and are rejected
with --chimeric, MGF, .d and --glyco.
Outputs: Sage-shaped `<stem>.tmt.tsv` (corrected channels, raw block when
a matrix was applied, purity), `<stem>.lfq.tsv` (wide over runs at the
feature FDR), `<stem>.lfq_features.tsv` (every feature with apex, bounds,
areas, score, decoy score, q), and with --output-parquet the QPX feature
view `quantms.feature.parquet` (OpenMS QPXFeatureSchema, file_type
feature_file, intensities as [{label, intensity}]).
Tests: unit tests in every quant module and the writers; reader tests for
MS1/MS3 capture; end-to-end tests on two synthetic fixtures generated by
scripts/make_quant_fixtures.py (six BSA peptides with designed reporter
patterns, an interfered precursor, and Gaussian elution profiles) checking
the reporter ratios, the impurity correction, the purity, the MS3 linkage
and the integrated areas against the designed values.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0116xbaQQJpHtmofZc5FirfT
…er trailer The MS3 capture resolved the parent through precursor().parent_index(). On PXD007683 a05058 (Lumos, ion-trap MS2 + SPS-MS3) that index matched the scan's Master Scan Number trailer for 5,702 of 37,326 MS3 scans; otherwise it named the MS3 itself or the last MS2. 7,984 of 12,077 PSMs got no MS3 and 2,543 of the 4,093 linked ones carried another peptide's reporter ions. The trailer is on every MS3 of that file. Reading it links 11,963/11,963 shared PSMs to the same MS3 as the mzML path (FileConverter spectrumRef), and 12,008/12,013 scans carry the same reporter values as OpenMS IsobaricAnalyzer. Without the trailer the scan stays unlinked rather than mislinked. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0191LNr9sLGKAN6uGXdyH88H
Boundaries stopped at the first 10 % rise above the running minimum, which on ~1 s Orbitrap survey scans is noise. On PXD001819 (UPS1 2,500 vs 25,000 amol in yeast, three replicates each) the same yeast peptide's integration window differed by 2x or more between replicates for half the peptides, and the area CV was 39.7 % against 10.9 % for OpenMS FeatureFinderIdentification on the same targets. Each boundary now sits two half-widths at half maximum from the apex of the smoothed monoisotopic trace (98 % of a Gaussian), or at an earlier deep valley (below half the apex, then a 1.5x rise). A feature whose monoisotopic area holds less than 30 % of its theoretical share is not returned: its M+1.. traces belong to an isotope-shifted species (a deamidated N-G peptide was integrated at ~100x). 0.9 % of UPS1 features fall below that; the median observed/theoretical share is 1.07. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0191LNr9sLGKAN6uGXdyH88H
…cosine - --tmt-level 3 defaults to 20 ppm. The default followed the MS2 model, so ion-trap SPS-MS3 data got 0.3 Da and every TMT N/C pair read the same peak (127N == 127C on 11,980/11,981 a05058 PSMs). A reporter window that reaches half the kit's closest channel spacing is now refused, which also rejects TMT10+ at MS2 on ion-trap data. - --lfq no longer refuses a low-resolution MS2 model: high/low methods (Velos/Elite/Fusion/Lumos) have Orbitrap MS1. Each run's MS1 is checked instead (share of intense centroids with a 10 ppm isotope partner: Orbitrap 0.70-0.93, ion-trap-like 0.09-0.32) and a warning names low-resolution runs. - --lfq-min-cosine was parsed but never applied; lfq.tsv now leaves out features below it (lfq_features.tsv and the parquet keep them). - --chimeric --tmt: say once that purity is not computed there and refuse --tmt-min-purity instead of filtering nothing. - QPX: iTRAQ labels as ITRAQ<channel> (OpenMS's canonical form), and an empty scan list instead of [0] when the native id has no scan number. - Clippy suspicious_map in the new mzML test; parse_protocol doc comment back on parse_protocol; GlycoCfg keeps #[serde(default)]. - DOCS: the purity rule as implemented (it is not OpenMS's, which misses the upper isotopes: OpenMS/OpenMS#10467), the new boundaries, the MS1 check, and 16 bytes per captured MS1 centroid. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0191LNr9sLGKAN6uGXdyH88H
Fixes for the review above, re-measured against OpenMSThe fixes are three commits on
Local checks:
Before / after, same data and the same OpenMS nightly
How the LFQ change was chosen. Before touching Rust, I re-implemented the extraction in Python. The re-implementation reproduced all 28,600 PR-head features to within 1%. I then compared boundary rules on the same features:
I kept the existing 5-point Savitzky–Golay trace and apex climb, and only replaced the boundary rule. The valley cap protects against running into a co-eluting neighbour. Together with the monoisotope check (features with less than 30% of their theoretical mono share are not returned, 0.9% of UPS1 features), the fixed binary gives the 11.3% above. What changed, by finding
Not fixed here (need a design call or touch pre-existing code)
Generated by Claude Code |
Cache MS1 scans losslessly in private temporary files before rescoring, then load one run at a time for LFQ and precursor purity. Release prepared-search scratch state before output and Percolator. Document scratch requirements and verify exact round trips and cleanup. The six-file UPS1 full pipeline now completes within 8 GiB: 6.51 GiB peak process-tree RSS. PIN, Percolator, and LFQ tables are byte-identical; all PSM and feature Parquet data match.
Keep raw-area integration and symmetric target/decoy processing. Retain the existing default, document acquisition-dependent feature-q coverage, and clarify that feature competition cannot replace PSM confidence.
…FAIMS voltage) The readers now record, for every searched MS2, the scan its precursor references (mzML <precursor spectrumRef>, .raw Master Scan Number), its acquired m/z range and its FAIMS compensation voltage; MS1 scans keep their native id and voltage, and MS3 reporter scans their m/z range. - Precursor purity is computed on the MS2's own survey scan (else the last MS1 at the same FAIMS voltage, else the last MS1 in time). On a three- voltage FAIMS SPS-MS3 TKO run (PXD017803) the last MS1 in time is usually another voltage's survey scan: purity was missing for 2,308 of 4,570 PSMs and 0 for most others (median 0); it is now present for all, median 0.98. Filtering at purity >= 0.9 keeps 3,487 PSMs and lowers the knockout-channel interference (KO/non-KO median) from 0.128 to 0.040. - A reporter scan whose scan window does not cover every reporter m/z is not quantified. On the same study's FAIMS hrMS2 run the automatic first mass was above 126 Th for 4,345 of 6,361 quantified PSMs: their low channels were never measured and were written as zero intensities. - Label-free extraction keeps one chromatographic series per FAIMS voltage and extracts each precursor at its PSM's voltage. Interleaved voltages put zeros between the measured scans: on the FAIMS hrMS2 run the mixed series gave a median integration window of 3.9 s instead of 22 s and areas 10.7x too small. Runs without FAIMS and without recorded survey references behave as before.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Superseded by #139. It carries all commits from this PR (authorship kept), the defects found while testing them (FAIMS-aware purity and LFQ, purity window centred on the isolation target, unacquired reporter channels skipped, valid float output for values in [1, 10)), and multi-run LFQ with match-between-runs. #139 is stacked on #138 for now. This PR can be closed once #139 is reviewed. |
quant: TMT/LFQ quantification and scalable multi-run match-between-runs (supersedes #119)
andes now quantifies the confident rank-1 PSMs inside the search run, at the feature level, and leaves normalization, protein roll-up and statistics to quantms / OpenMS.
New crate
quant(pure algorithms over peak lists):Readers: the mzML reader captures every MS1 scan (RT + centroids) and MS3+ scans with their
<precursor spectrumRef>on request, without emitting them as searchable spectra; the Thermo reader does the same (master scan via the precursor's parent index). Newmodel::scan::{Ms1Scan, ProductScan}.Driver:
--tmt <plex>,--tmt-level 2|3,--tmt-tol,--tmt-correction,--tmt-min-purity,--lfq,--lfq-tol,--lfq-rt-window,--lfq-min-cosine,--lfq-feature-fdr,--quant-fdr, plus aquant:group in the YAML config. Reporter ions are read from each MS2 while its peaks are in memory; quantification runs after rescoring on PSMs at q <= --quant-fdr (every rank-1 target PSM, with a warning, without rescoring).--lfq/--tmt-level 3need mzML or .raw and are rejected with --chimeric, MGF, .d and --glyco.Outputs: Sage-shaped
<stem>.tmt.tsv(corrected channels, raw block when a matrix was applied, purity),<stem>.lfq.tsv(wide over runs at the feature FDR),<stem>.lfq_features.tsv(every feature with apex, bounds, areas, score, decoy score, q), and with --output-parquet the QPX feature viewquantms.feature.parquet(OpenMS QPXFeatureSchema, file_type feature_file, intensities as [{label, intensity}]).Tests: unit tests in every quant module and the writers; reader tests for MS1/MS3 capture; end-to-end tests on two synthetic fixtures generated by scripts/make_quant_fixtures.py (six BSA peptides with designed reporter patterns, an interfered precursor, and Gaussian elution profiles) checking the reporter ratios, the impurity correction, the purity, the MS3 linkage and the integrated areas against the designed values.
Claude-Session: https://claude.ai/code/session_0116xbaQQJpHtmofZc5FirfT
Acquisition context (survey scan, scan window, FAIMS) — follow-up commit
The readers now record each MS2's survey-scan reference, acquired m/z range and FAIMS compensation voltage.
Validation:
-D warningsis clean, and thethermofeature type-checks.