Ms ms similarity metric comparison
Use when when you have MS/MS spectra from both query compounds and a reference library and need to decide which similarity metric will maximize identification accuracy (true positive rank, precision@k) or when benchmarking a new compound identification workflow against a known-good reference.From its SKILL.md
npx -y skills add HolobiomicsLab/asb-skill-collections --skill ms-ms-similarity-metric-comparisonAssembled 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
9.2 KB, ~1.6k tokens by cl100k_base, as published. Nobody here has run it
ms-ms-similarity-metric-comparison
Summary
Compare MS/MS spectral similarity scores computed via multiple distance metrics (entropy-based and classical) to identify which metric best ranks reference compounds for a given identification task. This skill enables evidence-based selection of the appropriate similarity algorithm—e.g., entropy similarity vs. dot product—for your spectral library search or compound validation workflow.
When to use
When you have MS/MS spectra from both query compounds and a reference library and need to decide which similarity metric will maximize identification accuracy (true positive rank, precision@k) or when benchmarking a new compound identification workflow against a known-good reference dataset.
When NOT to use
- When spectral data is already heavily pre-filtered or normalized by external tools (similarity matrix or feature tables are pre-computed and not reproducible from raw peak lists).
- When only a single similarity metric is required and the metric choice is already validated for your specific sample type or mass spectrometer.
- When computational cost is prohibitive: computing 43+ similarity metrics on very large libraries (>1 million spectra) may require sampling or approximation strategies not covered by this skill.
Inputs
- MS/MS spectral peaks (m/z and intensity pairs) for query spectra
- MS/MS spectral peaks for reference library spectra
- Reference annotations linking query spectra to ground-truth library compounds
Outputs
- Similarity score matrix (query × reference, per metric)
- Ranked candidate lists per query spectrum (sorted by similarity, per metric)
- Comparison metrics table (accuracy, precision, recall, rank position statistics per metric)
- Performance summary quantifying the advantage of entropy similarity over dot product similarity
How to apply
First, prepare input MS/MS spectral data by removing spectral noise—specifically, filter peaks with intensity less than 1% of maximum intensity to improve identification performance. Next, compute spectral similarity scores between query and reference spectra using at least two contrasting metrics: (1) entropy similarity (the primary metric) and (2) MS/MS dot product similarity (or another classical metric such as cosine, Euclidean, or Manhattan distance). Apply these calculations via the math_distance, ms_distance, or spectral_similarity modules. Then, for each query spectrum, rank the reference library by descending similarity score and measure the ranking performance: record the rank position of the true reference compound, compute recall (fraction of true matches ranked in top-k), and tabulate accuracy metrics. Finally, compare the metrics side-by-side using the same test set; entropy similarity should show higher ranking accuracy and lower false discovery rate than dot product similarity for small-molecule compound identification.
Related tools
- SpectralEntropy (Primary package for computing spectral entropy, entropy similarity, and 43+ alternative distance metrics for MS/MS spectral comparison) — https://github.com/YuanyueLi/SpectralEntropy
- MSEntropy (Current recommended package integrating spectral entropy functions and the Flash entropy search algorithm; supports Python, R, C/C++, JavaScript) — https://github.com/YuanyueLi/MSEntropy
- spectral_similarity module (Module within SpectralEntropy/MSEntropy for computing pairwise spectral similarities across multiple metrics) — https://github.com/YuanyueLi/SpectralEntropy
- math_distance module (Module providing distance metric implementations (Euclidean, Manhattan, Chebyshev, etc.) used in spectral comparison) — https://github.com/YuanyueLi/SpectralEntropy
- ms_distance module (Module containing MS/MS-specific distance calculations including entropy similarity and dot product similarity) — https://github.com/YuanyueLi/SpectralEntropy
- Entropy Search GUI (Standalone graphical tool for querying spectral files against spectral libraries using entropy similarity; supports .mgf, .msp, .mzML, .lbm2 formats) — https://github.com/YuanyueLi/EntropySearch
- MS Viewer web app (Web-based real-time visualization and entropy similarity calculation for two MS/MS spectra) — https://yuanyueli.github.io/MSViewer
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, 5.0], [86.066, 3.0]]); entropy_sim = me.entropy_similarity(peaks_query, peaks_ref); dot_product_sim = me.dot_product_similarity(peaks_query, peaks_ref); print(f'Entropy: {entropy_sim}, Dot product: {dot_product_sim}')
Evaluation signals
- True reference compound is ranked at a higher position (lower rank index) by entropy similarity than by dot product similarity, across ≥80% of query spectra in the test set.
- Entropy similarity achieves higher recall@k (e.g., recall@10, recall@100) than dot product similarity when evaluating prediction accuracy against the reference compound identification dataset.
- Entropy similarity scores lie in the valid range [0, 1] with no anomalous values >1, indicating correct peak merging and normalization within MS2-tolerance windows.
- Spectral noise removal (filtering peaks <1% max intensity) produces a measurable improvement in ranking metrics for at least one metric, confirming correct preprocessing.
- Similarity score distributions (entropy vs. dot product) are visibly distinct and entropy shows lower overlap between true-match and false-match score distributions, indicating better separability.
Limitations
- Entropy similarity computation requires correct implementation of peak merging within MS2-tolerance; self-implemented code risks producing scores >1 due to merging errors—use the provided SpectralEntropy/MSEntropy repository code to avoid this.
- Comparison results are specific to small-molecule compounds and MS/MS spectra; applicability to other analyte classes (peptides, glycans) or ionization methods not directly established by this benchmark.
- The Flash entropy search algorithm (in MSEntropy) significantly accelerates entropy similarity computation but is currently available only in Python; R, C/C++, and JavaScript users must use the classical (slower) entropy similarity implementation.
- Benchmark conclusions assume a representative reference spectral library; biased or incomplete library coverage may alter the relative ranking performance of similarity metrics.
Evidence
- [intro] Spectral entropy outperforms MS/MS dot product similarity for small-molecule compound identification: "Spectral entropy outperforms MS/MS dot product similarity for small-molecule compound identification"
- [other] Noise removal via intensity threshold improves identification: "peaks have intensity less than 1% maximum intensity can be removed to improve identificaiton performance"
- [other] Multiple tools/modules used for similarity calculation: "These are all integrated into the MSEntropy package (https://github.com/YuanyueLi/MSEntropy)"
- [other] 43 spectral similarity algorithms available for comparison: "The code in this repository provides 43 different spectral similarity algorithms for MS/MS spectral comparison."
- [readme] Risk of entropy similarity >1 from implementation errors: "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. Use the code provided in our repository to"
- [readme] Flash entropy search improves speed without losing accuracy: "With the
MSEntropypackage, the method for calculating entropy similarity has been rewritten using the Flash entropy search algorithm. This has resulted in speed improvements without compromising"
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.