agentsclimarketplace

Least squares optimization spectral deconvolution

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/least-squares-optimization-spectral-deconvolution

Curated, evidence-grounded skill and software-tool collections for scientific AI agents, generated by the AgenticScienceBuilder

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill least-squares-optimization-spectral-deconvolution

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

  • 14 stars14 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 author says it does

Copied from the file, not written here

Use when after GCMSFormer has predicted the pure mass spectral matrix S from overlapped GC-MS peaks.

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

6.2 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it

least-squares-optimization-spectral-deconvolution

Summary

Solves for the concentration distribution matrix C in GC-MS peak deconvolution by minimizing the reconstruction error between predicted mass spectra and observed overlapped peak intensities. This step follows Transformer-based pure spectrum prediction to obtain quantitative abundance estimates for each resolved component.

When to use

Apply this skill after GCMSFormer has predicted the pure mass spectral matrix S from overlapped GC-MS peaks. Use it when you have resolved mass spectra and need to recover the concentration (abundance) distribution of each component across the chromatographic profile to reconstruct the original overlapped peak data.

When NOT to use

  • Mass spectral matrix S is not yet available or contains unresolved/overlapping peaks
  • Input overlapped peak data is already deconvolved into pure component spectra (concentration matrix already solved)
  • The least squares problem is underdetermined (fewer time points than components) without regularization

Inputs

  • Predicted mass spectral matrix S (m × n, where m = mass bins, n = number of components)
  • Observed overlapped peak intensity data (m × t, where m = mass bins, t = time points)
  • Pure mass spectra from GCMSFormer model output

Outputs

  • Concentration distribution matrix C (n × t, where n = components, t = time points)
  • Reconstructed overlapped peak matrix (S·C)
  • Residuals from reconstruction (||overlapped_peaks - S·C||²)

How to apply

Formulate a least squares optimization problem: minimize ||overlapped_peaks - S·C||² where S is the m×n resolved mass spectral matrix (m mass bins, n components), C is the n×t unknown concentration matrix (n components, t time points), and overlapped_peaks is the m×t observed intensity matrix. Solve using numpy.linalg.lstsq or PyTorch optimization routines to obtain C. Validate by computing the reconstruction S·C and comparing against the input overlapped peak data using residual magnitude and spectral fidelity metrics; solutions should recover the overlapped data to high precision if the pure spectra are well-resolved.

Related tools

  • PyTorch (Solves least squares optimization to compute concentration matrix C using GPU-accelerated tensor operations) — https://pytorch.org/
  • numpy.linalg.lstsq (CPU-based least squares solver for reconstructing concentration distribution)
  • GCMSFormer (Produces the resolved mass spectral matrix S that serves as input to the least squares deconvolution) — https://github.com/zxguocsu/GCMSFormer

Examples

import numpy as np; S = np.array([[...], [...]]);  overlapped_peaks = np.array([[...], [...]); C, residuals, rank, s = np.linalg.lstsq(S, overlapped_peaks, rcond=None); reconstructed = S @ C

Evaluation signals

  • Reconstruction error (||overlapped_peaks - S·C||²) is minimized and smaller than input noise level
  • Reconstructed peaks S·C visually and numerically match the original overlapped peak data within measurement precision
  • Concentration matrix C is non-negative (abundance constraints) and physically interpretable
  • Residual distribution is white/random (not structured), indicating full spectrum capture
  • Solution is stable across multiple runs or different initialization conditions

Limitations

  • Requires accurate pure mass spectra from GCMSFormer; errors in S directly propagate to C
  • Least squares solution is sensitive to ill-conditioning when components have highly similar mass spectra
  • No explicit regularization (L1/L2) is mentioned; may require Tikhonov or similar if the problem is underdetermined or noisy
  • Assumes linear mixing model (overlapped_peaks = S·C); deviations from linearity are not modeled

Evidence

  • [other] minimize ||overlapped_peaks - S·C||² where C is the unknown concentration distribution: "Formulate the least squares problem: minimize ||overlapped_peaks - S·C||² where C is the unknown concentration distribution."
  • [other] Solve for C using a least squares solver (e.g., numpy.linalg.lstsq or PyTorch optimization): "Solve for C using a least squares solver (e.g., numpy.linalg.lstsq or PyTorch optimization) to obtain the concentration matrix."
  • [intro] GCMSFormer can predict the pure mass spectra of all components in overlapped peaks (mass spectral matrix S), and then use the least squares method to find the concentration distribution matrix C: "GCMSFormer can predict the pure mass spectra of all components in overlapped peaks (mass spectral matrix S), and then use the least squares method to find the concentration distribution matrix C"
  • [other] Validate the solution by reconstructing the overlapped peaks as S·C and comparing with the input overlapped data: "Validate the solution by reconstructing the overlapped peaks as S·C and comparing with the input overlapped data."
  • [readme] The automatic resolution of the overlapped peaks can be easily achieved.: "then use the least squares method to find the concentration distribution matrix C. The automatic resolution of the overlapped peaks can be easily achieved."

What ships with it

Read from the repository

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

Keep looking

Skills are one crate of 328,083. 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.