Skip to content

Add table-driven chromatogram extraction and R-pinned peak metrics - #13

Merged
lfu46 merged 1 commit into
mainfrom
chromatogram-extraction
Sep 24, 2026
Merged

lfu46 merged 1 commit into
mainfrom
chromatogram-extraction

Conversation

@lfu46

@lfu46 lfu46 commented Sep 24, 2026

Copy link
Copy Markdown
Owner

Python counterpart of chromExtract() from the Bioconductor package Chromatograms (Louail et al., Anal Chem 2026, 10.1021/acs.analchem.6c03926), plus peak boundaries and quality metrics ported from the Chromatograms, MsQuality and MetaboCoreUtils R sources and pinned against them (tests/data/r_peak_reference.json). Deviations from R are opt-in and documented: nearest_valley, contains_rt, apex_window. Offline suite: 227 passed.

🤖 Generated with Claude Code

From the Chromatograms paper (Louail, Gatto, Gibb & Rainer, Anal Chem 2026,
10.1021/acs.analchem.6c03926):

- chrom_extract.extract_chromatograms(): a peak table (m/z + RT window per row,
  any annotation columns) -> one chromatogram per row and run, one pass per run,
  every row column carried through; chromatogram_rows() flattens for a DataFrame.
  Active rows are summed with one searchsorted over a cumulative intensity sum.
- xic.peak_boundary / peak_metrics / PeakMetrics / beta_values: boundaries,
  in-boundary area, FWHM, asymmetry, S/N, prominence and Kumler beta shape, ported
  from the Chromatograms, MsQuality and MetaboCoreUtils R sources. The port matches
  those functions run verbatim in R 4.5.2 to 1e-15 on 7 traces, pinned in
  tests/data/r_peak_reference.json.
- Opt-in deviations, all measured on real glycopeptide MS1 (NGlycoMM TMT runs):
  nearest_valley (R's left boundary walks through a flat floor to the trace start:
  132 of 400 zero-filled traces vs 19), contains_rt (the peak containing the MS2
  time; the MS2 can fire on a tail a minute past the apex), apex_window.
- XIC.area docstring corrected: it integrates the whole trace.

On two real caches the table extraction reproduces extract_xics exactly when both
compute in float64 (400 rows).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@lfu46
lfu46 merged commit 474531a into main Sep 24, 2026
@lfu46
lfu46 deleted the chromatogram-extraction branch September 24, 2026 15:49
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.

1 participant