Entropy similarity scoring
Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/entropy-similarity-scoring
Use when you need to quantify the degree of match between two MS/MS spectra—either to validate that a denoised spectrum remains faithful to a reference ground-truth spectrum, or to rank candidate library matches for a query spectrum.From its SKILL.md
npx -y skills add HolobiomicsLab/asb-skill-collections --skill entropy-similarity-scoringAssembled 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.5 KB, ~1.2k tokens by cl100k_base, as published. Nobody here has run it
entropy-similarity-scoring
Summary
Compute entropy similarity between a query MS/MS spectrum and a reference spectrum to quantify spectral match quality and validate the effectiveness of denoising operations. This metric integrates both peak presence and intensity distribution, providing a normalized similarity score suitable for library searching and denoising validation.
When to use
Apply this skill when you need to quantify the degree of match between two MS/MS spectra—either to validate that a denoised spectrum remains faithful to a reference ground-truth spectrum, or to rank candidate library matches for a query spectrum. Use entropy similarity in particular when you want a metric that accounts for both the presence of peaks and their relative intensities, rather than a simple presence/absence comparison.
When NOT to use
- Input spectra contain only a single peak or very few peaks (entropy metric becomes unreliable with low spectral complexity).
- You need deterministic, threshold-based binary classification of a match (entropy similarity provides a continuous score; use with a cutoff threshold if binary output is required).
- Precursor m/z is unknown or unreliable, since entropy similarity calculation depends on correct mass calibration and ion detection.
Inputs
- query_spectrum (numpy array: [m/z, intensity] columns, dtype float32)
- reference_spectrum (numpy array: [m/z, intensity] columns, dtype float32)
- precursor_mz (float: measured or theoretical m/z of the precursor ion)
Outputs
- entropy_similarity_score (float: normalized similarity metric, typically 0.0–1.0 range)
How to apply
Entropy similarity compares the spectral entropy profiles of a query spectrum against a reference spectrum using the formula and implementation provided by the ms_entropy package. Call the entropy_similairty function (note: function name has a typo in the source) with the query spectrum array (m/z and intensity columns), the reference spectrum array, and the precursor m/z value. The function computes normalized entropy for both spectra and returns a similarity score. To validate denoising, compute entropy_similarity for both the raw noisy spectrum against a reference and the denoised spectrum against the same reference; improvement in the latter score indicates successful noise removal while preserving chemically valid peaks. Typical application in library search loops through all candidate reference spectra and ranks by entropy similarity score.
Related tools
- ms_entropy (Provides entropy_similairty function to compute normalized spectral similarity using entropy-based distance metrics) — https://pypi.org/project/ms-entropy/
- spectral_denoising (Python package that wraps entropy_similairty and uses it to validate denoising results and rank denoising_search candidates) — https://github.com/FanzhouKong/spectral_denoising
- numpy (Data structure and array operations for storing and manipulating spectrum arrays)
Examples
entropy_similarity_score = entropy_similairty(peak_denoised, peak, pmz=pmz); print(f'denoised entropy similarity: {entropy_similarity_score:.2f}')
Evaluation signals
- Entropy similarity score for denoised spectrum vs. reference should be ≥ score for noisy spectrum vs. reference (denoising validation).
- Entropy similarity scores should be in a bounded, normalized range (e.g., 0.0 to 1.0 or similar), consistent across library searches.
- Top-ranked candidate from denoising_search should have entropy similarity of denoised query spectrum that correlates with manual MS/MS interpretation (e.g., correct molecular structure identified).
- Entropy similarity metric should be symmetric or quasi-symmetric: score(query, ref) should be reasonably close to score(ref, query) after normalization.
- Repeated calls with identical input spectra and precursor m/z should yield identical scores (deterministic and reproducible).
Limitations
- Entropy similarity is sensitive to precursor m/z accuracy; miscalibration or incorrect mass assignment can artificially inflate or deflate scores.
- The metric may not distinguish between spectra with similar overall entropy but very different fragmentation patterns (e.g., isomers with similar mass and intensity distributions).
- Low-intensity or noise-dominated spectra may yield uninformative entropy values; pre-filtering or normalization may be needed for robust comparisons.
- The function name in the codebase contains a typo (entropy_similairty instead of entropy_similarity), which may cause confusion or errors if not corrected.
Evidence
- [other] Compute entropy_similarity between the input noisy spectrum and reference/ground-truth spectrum, and between the denoised spectrum and reference spectrum, and report both scores for comparison.: "Compute entropy_similarity between the input noisy spectrum and reference/ground-truth spectrum, and between the denoised spectrum and reference spectrum, and report both scores for comparison."
- [readme] The entropy similarity of contaminated spectrum and the raw spectrum is {entropy_similairty(peak_with_noise,peak, pmz = pmz):.2f}: "the entropy similarity of contaminated spectrum and the raw spectrum is {entropy_similairty(peak_with_noise,peak, pmz = pmz):.2f}"
- [readme] result will return all precursor candidates of the query spectrum, each with entropy similarities of both raw and denoised spectra: "result will return all precursor candidates of the query spectrum, each with entropy similarities of both raw and denoised spectra"
- [other] Validate the denoised spectrum by calculating entropy similarity against a reference spectrum using entropy_similairty, confirming the similarity improvement.: "Validate the denoised spectrum by calculating entropy similarity against a reference spectrum using entropy_similairty, confirming the similarity improvement."
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.