Skip to content

metabolomics: run targeted panels in raw mode (platforms, internal standards, LOD, tank units) - #69

Merged
sr320 merged 2 commits into
mainfrom
workflow/metabolomics-targeted-panel
Oct 16, 2026
Merged

sr320 merged 2 commits into
mainfrom
workflow/metabolomics-targeted-panel

Conversation

@sr320

@sr320 sr320 commented Oct 16, 2026

Copy link
Copy Markdown
Owner

The metabolomics workflow's raw_reanalysis path had never been run. It fitted only two groups, using TIC normalization and log2(x + 1). That's reasonable for an untargeted feature table but wrong for a targeted MRM panel. DUPERRET2025_POMS_STARVE's Table S12 is the first real case:

  • four platforms on different scales;
  • spiked internal standards;
  • 0.0001 below-detection placeholders, which log2(x + 1) would read as real intensities.

This PR adds what a targeted panel needs. Every option defaults to the old behaviour, and the processed-mode demo is unchanged.

New params.metabolomics options

Option What it does
normalization tic (default), median or internal_standard. Runs separately within each value of an optional platform column. Rows with is_internal_standard true are used for normalization only and are never tested.
detection_limit Values at or below it become missing, not zero.
replicate_unit Averages log2 values within a unit (e.g. a tank) before limma. Refuses a unit that sits in both arms. Matches the RNA-seq and methylation option.
min_detected_per_arm Tests a feature only if it's detected in enough replicates per arm (default 2). Every feature, tested or not, goes in a new *_missingness.tsv with its status.
acquisition untargeted or targeted. Written to each row's analysis_method.

Other changes

  • limma now writes lfcSE (its posterior standard error). aree harmonize carries it into standard_error and reads analysis_method. Older processed tables without these columns harmonize as before; a new test covers both cases.
  • The manifest records every params.metabolomics value. Before, it recorded only mode.
  • The report template defines %||% when it's missing (R < 4.4) and summarizes normalization and the detection filter.
  • CI runs the raw DAG for real, not stubbed, on a new simulated targeted-panel fixture (tests/fixtures/metabolomics_raw/). scripts/check_metabolomics_raw_smoke.py checks three things: the planted effects come back (+2.0 → +1.98, −1.5 → −1.61, +1.0 → +0.84); internal standards and undetected features stay out of the results; and the manifest records the parameters. The CI R setup gains bioc::limma.

Verified locally: the processed demo, the raw fixture (check_metabolomics_raw_smoke.py and check_manifest_versions.py), the real DUPERRET2025_POMS_STARVE panel, the full test suite (609 passed) and ruff.

The DUPERRET study files will come in a separate study PR, once the curation decision on its batch confound is made.

🤖 Generated with Claude Code

…andards, LOD, tank units)

The raw feature-table path had never run. It fitted two groups with TIC
normalization and log2(x + 1), which suits an untargeted table but not a
targeted MRM panel like DUPERRET2025_POMS_STARVE's Table S12: four
platforms on different scales, spiked internal standards, and 0.0001
below-detection placeholders that log2(x + 1) treats as real intensities.

New params.metabolomics options, all defaulting to the old behaviour:
- normalization: tic | median | internal_standard, run within each value
  of an optional platform column; is_internal_standard rows are used only
  for normalization and never tested
- detection_limit: values at or below it become missing, not zero
- replicate_unit: average log2 values per unit (e.g. tank) before limma,
  refusing a unit in both arms, like the RNA-seq and methylation option
- min_detected_per_arm: test only features detected in enough replicates;
  every feature is listed with its status in a missingness report
- acquisition: untargeted | targeted, written to analysis_method

limma now also writes lfcSE (posterior SE), which aree harmonize carries
into standard_error, and the manifest records every params.metabolomics
value instead of only the mode. The report template defines %||% for R
< 4.4 and summarizes normalization and the detection filter.

CI runs the raw DAG for real on a simulated targeted-panel fixture and
checks that the planted effects come back and untestable features stay out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pak could not solve bioc::limma (limma suggests vsn, which imports limma),
so the whole R setup failed before any workflow ran. Install limma in its
own step with hard dependencies only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sr320
sr320 merged commit 6aafbbd into main Oct 16, 2026
6 checks passed
@sr320
sr320 deleted the workflow/metabolomics-targeted-panel branch October 16, 2026 15:30
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