metabolomics-quantification
Load when imputing missing values (min / median / KNN) and normalising (TIC / median / log) a feature × sample metabolomics CSV. Skip when only normalisation is needed (use metabolomics-normalization); the input is raw spectra (use metabolomics-xcms-preprocessing).
- License 许可
- Apache-2.0
- 最近更新
- 2026-10-08
- Stars
- ★ 161
- Forks
- 27
01 前言 Front Matter
- name
- metabolomics-quantification
- tags
- [ "metabolomics", "quantification", "imputation", "normalization", "knn", "tic" ]
- trigger
- metabolomics quantification, imputation, feature quantification, missing values
- description
- Load when imputing missing values (min / median / KNN) and normalising (TIC / median / log) a feature × sample metabolomics CSV. Skip when only normalisation is needed (use metabolomics-normalization); the input is raw spectra (use metabolomics-xcms-preprocessing).
02 资源文件 7
- 脚本_api.py2.0 KB
- 脚本examples/example_step.py478 B
- 脚本met_quantify.py5.6 KB
- 参考文档references/methodology.md493 B
- 参考文档references/output_contract.md509 B
- 参考文档references/parameters.md450 B
- 脚本tests/test_api.py1.2 KB
03 SKILL.md 正文
metabolomics-quantification
When to use
Impute zeros/NaNs and normalize sample intensities while keeping feature metadata. Use metabolomics-normalization for normalization alone.
Use from a step
import pandas as pd
from skills._sdk.notebook import load_skill, read_input, write_output
library = load_skill("metabolomics-quantification")
data = read_input('features.csv', reader=pd.read_csv)
result = library.quantify(data)
write_output(result, 'tables/result.csv')
examples/example_step.py runs a seeded synthetic
example through the step runner and writes a table and Figure. Computations
return new DataFrames, leave the input unchanged and expose diagnostics through
run_info(result). Plotting functions write no files.
API
<!-- api:begin generated from _api.py; regenerate with run.py api <skill dir> --write -->
quantify(data, *, impute='min', normalize='tic')
Return imputed and normalized intensities with metadata preserved.
:param data: Feature table with sample/intensity columns; zeros and NaNs are missing. :param impute: CLI default min (half global positive minimum); median or knn also work. :param normalize: CLI default tic; median or log are alternatives. :returns: A new DataFrame with missing-value counts in attrs['run_info']. :raises ValueError: Samples are absent, have no positive observations or a method is unknown. :raises ImportError: KNN requires scikit-learn; use install_skill_deps.
run_info(data, *, keep=True)
Read diagnostics attached to a returned table.
:param data: DataFrame returned by this library. :param keep: Default True; use False in the CLI to remove diagnostics. :returns: An independent dictionary describing the run. :raises ValueError: The table carries no run_info.
distribution_figure(data)
Plot sample intensities, excluding numeric feature metadata.
:param data: The input or quantified feature table. :returns: A matplotlib Figure. :raises ValueError: No numeric sample columns are available.
<!-- api:end -->
Methods and parameters
Min imputation uses half the global positive minimum, median uses each column positive median, and KNN uses neighbouring feature rows with up to five neighbours. TIC scales column sums to their median; median scales column medians; log computes log2(x+1).
Gotchas
quantifydetects sample/intensity prefixes, then numeric columns excluding feature_id, mz, rt, name and id. Every sample needs a positive observed intensity; completely missing samples raise ValueError for all methods.
Inputs and outputs
CSV input; tables/quantified_features.csv, report.md and result.json. Demo mode also writes its synthetic input CSV at the output root.
The function library returns objects; the CLI and step own file writes.
CLI
python skills/metabolomics/metabolomics-quantification/met_quantify.py --demo --output /tmp/metabolomics_quantification
See also
Dependencies
numpy, pandas, scikit-learn, matplotlib
04 同仓库更多 Skills
demo-skill
A fixture skill for the skill environment tests. Use it for nothing else.
fake-domains
Test fixture for the golden deployment in tests/entry. Load never; it has no script.
replace-me-skill
Load when copying this directory to bootstrap a new OmicsClaw skill. Skip when an existing skill already covers the request.
spatial-velocity
Load when estimating RNA velocity on a spatial AnnData with `layers["spliced"]` + `layers["unspliced"]` via scVelo (stochastic / deterministic / dynamical) or veloVI (deep generative). Skip when input lacks the spliced/unspliced layers (must be quantified upstream by velocyto / kb-python / STARsolo); non-spatial scRNA velocity (use sc-velocity).
spatial-trajectory
Load when inferring pseudotime / lineage trajectories on a preprocessed spatial AnnData via DPT (default — diffusion pseudotime), CellRank (terminal-state + fate-probability), or Palantir (waypoint branch probabilities). Skip when the data has spliced/unspliced layers and you want velocity-driven dynamics (use spatial-velocity); non-spatial scRNA pseudotime (use sc-pseudotime).
spatial-statistics
Load when running spatial autocorrelation / hotspot / co-occurrence / neighbourhood-enrichment / Ripley K stats on a clustered spatial AnnData via squidpy. Skip when ranking spatially variable genes (use spatial-genes); tissue domain detection (use spatial-domains).