agentsclimarketplace

Entropy based spectral distance computation

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/entropy-based-spectral-distance-computation

Use when when comparing two preprocessed MS/MS spectra for compound identification and you need higher accuracy than dot product similarity provides.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill entropy-based-spectral-distance-computation

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

entropy-based-spectral-distance-computation

Summary

Compute similarity between two MS/MS spectra using entropy-based distance metrics rather than classical dot product similarity. This approach quantifies spectral complexity and comparison on information-theoretic principles, yielding improved accuracy for small-molecule compound identification.

When to use

When comparing two preprocessed MS/MS spectra for compound identification and you need higher accuracy than dot product similarity provides. Particularly valuable when spectra have sparse, noisy, or unequal peak distributions, as entropy similarity is more robust to these characteristics than classical distance metrics.

When NOT to use

  • Input spectra have not been noise-filtered or contain very low-intensity artifacts; apply noise removal first.
  • You need to compare more than two spectra simultaneously against a large library; use Flash entropy search algorithm instead for scalability.
  • Input data is not MS/MS spectral data (e.g., chromatographic, proteomics, or already aggregated feature tables).

Inputs

  • Two preprocessed MS/MS spectra (noise-filtered: peaks <1% of max intensity removed)
  • Spectral data as peak lists (m/z–intensity pairs)
  • Spectrum identifiers and metadata

Outputs

  • Entropy similarity score (scalar, range [0, 1])
  • Structured metadata table (spectrum IDs, peak counts, entropy values, similarity score)

How to apply

First, preprocess both input spectra by removing noise—specifically, filter peaks with intensity less than 1% of maximum intensity. Load the two cleaned spectra (as peak m/z and intensity pairs) into the entropy_similarity function from the spectral_similarity module or MSEntropy package. The function computes a normalized entropy distance score between the spectra by comparing their entropy profiles. Validate that the returned similarity score lies within the expected range [0, 1], where 1 indicates identical spectra and 0 indicates orthogonal spectra. Record the score alongside spectrum identifiers, peak counts, and entropy values for downstream analysis or library matching.

Related tools

Examples

import numpy as np
import ms_entropy as me

peaks_query = np.array([[69.071, 7.918], [86.066, 1.022]])
peaks_ref = np.array([[69.071, 10.0], [86.066, 2.5]])
similarity_score = me.spectral_entropy_similarity(peaks_query, peaks_ref)
print(f"Entropy similarity: {similarity_score}")

Evaluation signals

  • Returned similarity score is a scalar in range [0.0, 1.0]; scores >1.0 indicate a peak-merging error within MS2 tolerance.
  • Similarity score matches reference output for known spectrum pairs (e.g., identical spectra should score ≈1.0; unrelated spectra should score ≈0.0).
  • Output metadata table is complete and well-formed: contains spectrum IDs, peak counts, entropy values, and similarity score for audit trail.
  • Spectral entropy values are positive and finite; extreme entropy values (very low or infinite) may indicate unexpected peak distributions or empty spectra.
  • Input spectra confirm noise has been removed: no peaks with intensity <1% max intensity remain after filtering step.

Limitations

  • If entropy similarity scores exceed 1.0, this indicates an error in peak merging during MS2-tolerance alignment; use vetted implementation from MSEntropy repository to avoid this.
  • Performance scales with spectrum complexity; for searching a single spectrum against large spectral libraries (>10k entries), use Flash entropy search algorithm instead, available only in Python currently.
  • Entropy similarity assumes spectra have been preprocessed consistently (same normalization, fragmentation conditions); inconsistent preprocessing can inflate or deflate scores.
  • Method is optimized for small-molecule MS/MS data; applicability to peptide, lipid, or other specialized fragmentation modes has not been extensively validated in the original paper.

Evidence

  • [other] How does the entropy similarity calculation operate to quantify the similarity between two MS/MS spectra: "research_question: How does the entropy similarity calculation operate to quantify the similarity between two MS/MS spectra in the spectral_similarity module?"
  • [other] Noise filtering threshold and workflow: "Load two preprocessed MS/MS spectra (with noise removed: peaks <1% of maximum intensity filtered) from input files"
  • [intro] Entropy similarity outperforms dot product for identification: "Spectral entropy outperforms MS/MS dot product similarity for small-molecule compound identification"
  • [intro] Entropy similarity is a core integrated function: "Package includes spectral entropy, entropy similarity, and many other functions"
  • [other] Expected output range and validation: "Validate that the calculated entropy similarity value is within the expected range [0, 1] and matches reference output for known spectrum pairs"
  • [readme] Peak-merging error indicator: "If you encounter an entropy similarity score higher than 1 in your self-implemented code, it could be due to errors in merging peaks within MS2-tolerance"
  • [readme] Flash entropy search acceleration: "With the MSEntropy package, the method for calculating entropy similarity has been rewritten using the Flash entropy search algorithm. This has resulted in speed improvements without compromising"
  • [readme] Multiple language support and tools: "The MSEntropy package supports multiple languages, including Python, R, C/C++, and JavaScript."

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.