agentsclimarketplace

Spectral similarity scoring

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v1/skills/spectral-similarity-scoring

Use when when you have extracted low-resolution mass spectra from individual chromatographic peaks in GC-MS data and need to match them against a spectral library (e.g., PNNLMetV20191015.MSL) to identify the unknown compound.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill spectral-similarity-scoring

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

7.0 KB, ~1.2k tokens by cl100k_base, as published. Nobody here has run it

spectral-similarity-scoring

Summary

Quantify the similarity between an experimental mass spectrum and library reference spectra using cosine similarity and retention-index proximity metrics. This skill is essential for automated compound identification in GC-MS workflows where multiple spectral candidates must be ranked and selected.

When to use

When you have extracted low-resolution mass spectra from individual chromatographic peaks in GC-MS data and need to match them against a spectral library (e.g., PNNLMetV20191015.MSL) to identify the unknown compound. Use this skill after peak detection and retention index calibration, when you have both experimental m/z intensities and retention index values ready for comparison.

When NOT to use

  • Input spectrum is high-resolution (e.g., FT-ICR or Orbitrap data) — use fine isotopic structure and molecular formula assignment instead of library matching.
  • Reference library is unavailable or does not cover the expected compound class — consider manual annotation or alternative identification strategies.
  • Retention index calibration has failed or produced unreliable RI values — the secondary RI filtering criterion will be uninformative and may exclude correct matches.

Inputs

  • Low-resolution mass spectrum (m/z–intensity pairs) extracted from a single GC-MS peak
  • Retention index value (RI) for the detected peak
  • Reference spectral library in MSL format (e.g., PNNLMetV20191015.MSL) with library entries containing m/z–intensity spectra, CAS numbers, compound names, and reference retention indices

Outputs

  • Match result table with columns: compound name, CAS number, retention index, spectral match score (cosine similarity), and match rank
  • Ranked list of candidate compounds sorted by score (highest similarity first)
  • Exported results in CSV or HDF format for downstream curation

How to apply

Apply the LowResMassSpectralMatch class from CoreMS, which scores candidate matches by computing cosine similarity between the experimental spectrum and each library reference spectrum, then filters and ranks candidates using retention-index proximity as a secondary criterion. The workflow loads the reference spectral library, iterates through each detected peak's mass spectrum, performs the cosine similarity calculation across all library entries, and aggregates results into a structured table with compound name, CAS number, spectral match score, and match rank. The cosine similarity metric weights both m/z values and their corresponding intensities, penalizing candidates whose retention indices deviate significantly from the experimental value.

Related tools

  • CoreMS (Provides LowResMassSpectralMatch class for spectral library matching and cosine similarity scoring against reference MSL databases) — https://github.com/EMSL-Computing/CoreMS
  • pandas (Structures and exports match results (compound name, CAS, RI, score, rank) to CSV and tabular formats)
  • numpy (Performs cosine similarity vector calculations between experimental and library spectra)

Examples

from corems.encapsulation.factory.parameters import MSParameters; from corems.gcms import GCMSData; gc_data = GCMSData('sample.cdf'); gc_data.calibrate_ri(); results = gc_data.spectral_match(library='PNNLMetV20191015.MSL'); results.to_csv('matches.csv')

Evaluation signals

  • Output table has same number of rows as input peaks, with no null compound names or scores for high-confidence matches (top rank).
  • Cosine similarity scores are bounded in [0, 1] with top-ranked match having score ≥ 0.7 (typical threshold for GC-MS matches).
  • Retention index difference between experimental and matched library entry is within tolerance (typically ±5 RI units for well-calibrated systems).
  • Spot-check: for a known compound standard, verify that the correct library entry appears at or near rank 1 with highest score.
  • Compare match scores across all candidates for each peak; verify score distribution is not uniform (indicating discriminative power of the metric).

Limitations

  • Cosine similarity alone does not account for spectral noise, baseline artifacts, or peak deconvolution errors — poor spectrum quality degrades match confidence.
  • Library matching is fundamentally limited by reference library completeness; unknown or new compounds will not match, and novel isomers cannot be distinguished if their spectra are identical.
  • Retention index calibration errors or use of different RI standards (Kovats vs. van den Dool) between experiment and library can cause false-negative matches despite high spectral similarity.
  • Low-resolution GC-MS spectra often contain multiple isobaric fragments, reducing specificity compared to high-resolution or MS/MS approaches; multiple library candidates may have similar scores.

Evidence

  • [other] Extract low-resolution mass spectra from each peak and perform LowResMassSpectralMatch against the PNNLMetV20191015.MSL spectral library, scoring matches by cosine similarity and retention-index proximity.: "Extract low-resolution mass spectra from each peak and perform LowResMassSpectralMatch against the PNNLMetV20191015.MSL spectral library, scoring matches by cosine similarity and retention-index"
  • [other] Aggregate results into a structured table with compound name, CAS number, retention index, spectral match score, and match rank.: "Aggregate results into a structured table with compound name, CAS number, retention index, spectral match score, and match rank."
  • [readme] Automatic molecular match algorithm with all spectral similarity methods: "Automatic molecular match algorithm with all spectral similarity methods"
  • [readme] CoreMS is a comprehensive mass spectrometry framework for software development and data analysis of small molecules analysis.: "CoreMS is a comprehensive mass spectrometry framework for software development and data analysis of small molecules analysis."

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.