agentsclimarketplace

Pairwise spectrum comparison

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/pairwise-spectrum-comparison

Use when you have a collection of cleaned mass spectrometry spectra (in mzML, mzXML, msp, MGF, or JSON format) and need to identify spectral similarities, find related compounds, or generate a comprehensive similarity matrix for downstream analysis such as spectral library matching or clustering.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill pairwise-spectrum-comparison

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.3 KB, ~1.3k tokens by cl100k_base, as published. Nobody here has run it

pairwise-spectrum-comparison

Summary

Compute pairwise similarity scores across a collection of mass spectrometry spectra using Cosine-related measures to generate a scored matrix. This skill enables large-scale spectral comparisons and identification of similar spectra or compounds within a dataset.

When to use

Apply this skill when you have a collection of cleaned mass spectrometry spectra (in mzML, mzXML, msp, MGF, or JSON format) and need to identify spectral similarities, find related compounds, or generate a comprehensive similarity matrix for downstream analysis such as spectral library matching or clustering.

When NOT to use

  • Input spectra have not yet been cleaned or processed—apply data cleaning and peak filtering first before pairwise comparison.
  • You require non-spectral similarity measures (e.g., only metadata-based or molecular fingerprint-based comparisons) without peak-level spectral comparison.
  • Raw, uncalibrated spectra in unsupported formats—first convert to mzML, mzXML, msp, MGF, or JSON and apply matchms processing steps.

Inputs

  • Collection of cleaned mass spectrometry spectra (MS/MS)
  • Spectral data in supported formats: mzML, mzXML, msp, MGF, or JSON
  • Spectrum identifiers (for indexing output matrix)

Outputs

  • Pairwise similarity scores matrix (sparse format, rows and columns indexed by spectrum identifiers)
  • Similarity scores (Cosine-related values, typically 0–1 range)
  • Pre-selected spectrum pairs above similarity threshold (optional, for downstream workflows)

How to apply

Load cleaned spectral data using the matchms Python API in a supported format (mzML, mzXML, msp, MGF, JSON). Select an appropriate pairwise similarity measure—most commonly Cosine-related scores, which compare peak m/z values and intensities between spectra pairs. Apply the similarity function across all spectra in the collection to compute pairwise comparisons. Store results in a sparse scores matrix (indexed by spectrum identifiers, with cells containing similarity scores) to optimize memory efficiency, especially for large datasets with hundreds of thousands of spectra. The choice of Cosine-related measures is grounded in their effectiveness for comparing spectral peak patterns and their computational efficiency for initial pre-selection workflows.

Related tools

  • matchms (Core library providing pairwise Cosine-related similarity computation, spectrum I/O, and sparse scores matrix generation) — https://github.com/matchms/matchms
  • Python (Programming language and runtime for executing matchms workflows and custom similarity pipelines)
  • Spec2Vec (Optional extensible similarity measure tailored for matchms that can complement or replace Cosine-related scores) — https://github.com/iomega/spec2vec
  • MS2DeepScore (Optional deep-learning-based similarity measure compatible with matchms for advanced spectral comparison) — https://github.com/matchms/ms2deepscore

Examples

from matchms import calculate_scores
from matchms.similarity import CosineGreedy
scores = calculate_scores(spectra, spectra, CosineGreedy())
# spectra is a list of cleaned Spectrum objects; scores is a sparse scores matrix

Evaluation signals

  • Scores matrix dimensions match the number of input spectra (N × N for all-vs-all comparison).
  • Similarity scores fall within expected range (0–1 for normalized Cosine measures); diagonal elements (self-similarity) equal or near 1.0.
  • Sparse matrix storage format reduces memory footprint compared to dense matrix; only non-null computed scores are retained.
  • Spectrum identifiers in matrix rows and columns match input spectrum identifiers and metadata.
  • Reproducibility: repeated runs on the same cleaned input spectra produce identical scores (deterministic computation).

Limitations

  • Cosine-related measures compare only peak m/z and intensity patterns; they do not account for differences in metadata, molecular structure, or retention time unless explicitly combined with metadata or fingerprint-based measures.
  • Pairwise comparison computational cost scales as O(N²) for N spectra; very large datasets (millions of spectra) may require computational optimization or iterative pre-filtering.
  • Sparse scores matrix storage omits zero or null scores; downstream analyses must handle sparse data structures appropriately.
  • Similarity scores depend critically on prior spectral cleaning and normalization; poorly cleaned data (e.g., uncalibrated m/z, noisy peaks) will degrade score reliability.

Evidence

  • [other] Matchms applies pairwise Cosine-related similarity measures for comparing extensive amounts of spectra to produce similarity scores across spectral collections.: "Matchms applies pairwise Cosine-related similarity measures for comparing extensive amounts of spectra to produce similarity scores across spectral collections."
  • [other] Load cleaned spectral data (in supported formats: mzML, mzXML, msp, MGF, JSON) using matchms Python API. Apply Cosine-related similarity measure to compute pairwise comparisons across all spectra in the collection using matchms similarity functions. Generate and export scores matrix (rows and columns indexed by spectrum identifiers, cells containing similarity scores).: "Load cleaned spectral data (in supported formats: mzML, mzXML, msp, MGF, JSON) using matchms Python API. Apply Cosine-related similarity measure to compute pairwise comparisons across all spectra."
  • [readme] A key feature of matchms is its ability to apply various pairwise similarity measures for comparing extensive amounts of spectra. This encompasses not only common Cosine-related scores but also molecular fingerprint-based comparisons and other metadata-related assessments.: "A key feature of matchms is its ability to apply various pairwise similarity measures for comparing extensive amounts of spectra. This encompasses not only common Cosine-related scores but also"
  • [readme] Matchms enhances efficiency by using faster similarity measures for initial pre-selection and supports storing results in sparse data formats, enabling the comparison of several hundred thousands of spectra.: "supports storing results in sparse data formats, enabling the comparison of several hundred thousands of spectra."
  • [readme] One of the strengths of matchms is its extensibility, allowing users to integrate custom similarity measures. Notable examples of spectrum similarity measures tailored for Matchms include Spec2Vec and MS2DeepScore.: "Notable examples of spectrum similarity measures tailored for Matchms include Spec2Vec and MS2DeepScore."

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.