agentsclimarketplace

Compound abundance quantification from flow

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/compound-abundance-quantification-from-flow

Use when you have an NMR mixture spectrum (1D or 2D) and a library of reference spectra for pure compounds, and you need to identify which compounds are present and in what proportions.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill compound-abundance-quantification-from-flow

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 15 stars15 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as CC-BY-4.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

8.7 KB, ~1.5k tokens by cl100k_base, as published. Nobody here has run it

Compound-Abundance Quantification from Flow

Summary

Extract compound identities and their fractional abundances from an NMR mixture spectrum by solving a minimum-cost flow optimization problem that reconstructs the mixture as a linear combination of single-compound library spectra. The method optimizes flow assignments to minimize the Earth Mover's Distance between reconstructed and observed spectra.

When to use

You have an NMR mixture spectrum (1D or 2D) and a library of reference spectra for pure compounds, and you need to identify which compounds are present and in what proportions. Use this skill when you want to avoid peak-by-peak assignment and instead solve for the compound composition that best reconstructs the observed mixture spectrum as a weighted linear combination of library members.

When NOT to use

  • The mixture spectrum contains peaks from compounds not present in your reference library; the MCF formulation requires library coverage to reconstruct the mixture accurately.
  • You already have reliable manual peak assignments or independent quantification data; MCF is an assignment-free approach and adds complexity where direct measurement suffices.
  • Your input spectra are not properly normalized or aligned (e.g., different calibration references); MCF depends on consistent coordinate systems and intensity scales across library and target.

Inputs

  • NMR mixture spectrum (CSV or gzipped CSV with columns: peak coordinates in 1H/13C dimensions, optional intensity weights)
  • Single-compound reference spectral library (CSV or gzipped CSV with columns: compound name, peak coordinates, peak weights)
  • Configuration file (TOML) specifying: library path, target path, assignment_radius, detection_threshold, and optional fit parameters

Outputs

  • List of identified compounds with their fractional abundances (CSV format)
  • Reconstructed mixture spectrum (peak list with predicted intensities)
  • Reconstruction error metric (Earth Mover's Distance or residual norm)
  • Optional visualization: matched compounds plotted on top of target spectrum (SVG/PNG/EPS/JPG)

How to apply

Load the NMR mixture spectrum and single-compound reference spectral library (both as CSV files with peak coordinates and intensities). Compute pairwise Earth Mover's Distance scores between the mixture and each library spectrum to establish edge costs. Formulate a minimum-cost flow (MCF) problem where nodes represent spectral bins, edges represent possible compound contributions, and arc costs derive from EMD; set flow conservation constraints at each bin and supply/demand constraints at source/sink nodes. Solve the MCF problem using a successive shortest-paths or cost-scaling algorithm to identify the minimum-cost flow that reconstructs the mixture. Extract compound identities and fractional abundances from the optimal flow solution. Reconstruct the approximated mixture spectrum by computing the linear combination of selected library spectra weighted by their identified abundances. Validate by computing reconstruction error (EMD or residual norm) and confirming it meets the specified tolerance threshold.

Related tools

Examples

python -m mcfnmr -c config.toml
or
mcfNMR -c config.toml

Evaluation signals

  • Reconstruction error (EMD or residual norm) falls below the specified detection_threshold, confirming the linear combination of identified compounds accurately approximates the observed mixture.
  • All identified compounds have fractional abundances in the interval [0, 1] and sum to ≤ 1.0 (accounting for noise or unidentified components).
  • The MCF solution respects flow conservation: total flow into each spectral bin matches total flow out, with no accumulation or loss at intermediate nodes.
  • Visual inspection (if plot=true): the reconstructed spectrum aligns visibly with the target spectrum across all major peaks; systematic deviations suggest missing library members or spectral misalignment.
  • Reproducibility check: re-running with the same configuration and cached results (load=true) yields identical compound assignments and abundances.

Limitations

  • Requires complete or near-complete coverage of compounds present in the mixture by the reference library; compounds absent from the library cannot be identified and may inflate reconstruction error or absorb their signal into partial identifications of similar library members.
  • Assumes linear additivity of spectra (no nonlinear peak interactions, matrix effects, or solvent shifts between pure compounds and mixture); significant deviations invalidate the reconstruction assumption.
  • Performance scales with library size and spectral resolution; very large libraries or high-resolution 2D grids may increase computational cost of EMD and MCF solving.
  • Earth Mover's Distance calculation is sensitive to peak alignment; misalignment of coordinate systems between library and target spectra (e.g., different chemical shift references) can degrade reconstruction quality.
  • Isolated_fit=true (independent fitting) may overestimate abundances if compound spectra overlap significantly; joint_fit (default) is more conservative but slower.

Evidence

  • [intro] mcfNMR is a tool for recovering constituent compounds from an NMR spectrum of a mixture sample.: "mcfNMR is a tool for recovering constituent compounds from an NMR spectrum of a mixture sample."
  • [intro] It constructs an optimal approximation (in terms of the Earth Mover's Distance) of the mixture spectrum by combining single compound spectra from a library.: "It constructs an optimal approximation (in terms of the Earth Mover's Distance) of the mixture spectrum by combining single compound spectra from a library."
  • [other] Extract the compound identities and their fractional abundances from the optimal flow solution.: "Extract the compound identities and their fractional abundances from the optimal flow solution."
  • [other] nodes represent spectral bins, edges represent compound contributions, and arc costs are derived from EMD; set flow conservation constraints at each bin and supply/demand constraints for source and sink nodes: "nodes represent spectral bins, edges represent compound contributions, and arc costs are derived from EMD; set flow conservation constraints at each bin and supply/demand constraints for source and"
  • [other] Validate: compute reconstruction error (EMD or residual norm) and confirm it meets the reported tolerance threshold.: "Validate: compute reconstruction error (EMD or residual norm) and confirm it meets the reported tolerance threshold."
  • [readme] Library- and target files must be csv-files, with columns '1H', '13C', and optionally 'weights'.: "Library- and target files must be csv-files, with columns '1H', '13C', and optionally 'weights'."
  • [readme] Although developed with the goal of processing 2D spectra, it is possible to analyze 1D spectra. To represent a 1D-spectrum, simply set the second coordinate to zero (or any fixed, identical value).: "Although developed with the goal of processing 2D spectra, it is possible to analyze 1D spectra. To represent a 1D-spectrum, simply set the second coordinate to zero (or any fixed, identical value)."

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.