agentsclimarketplace

Spectral noise classification

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/spectral-noise-classification

Use when you have MS/MS spectra contaminated with noise ions and need to improve compound identification accuracy.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill spectral-noise-classification

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

spectral-noise-classification

Summary

Categorize and remove noise ions from MS/MS spectra by distinguishing electronic noise (instrumental artifacts with identical intensities) from chemical noise (implausible fragment ions). This skill integrates molecular structure and adduct information to enable high-confidence compound identification.

When to use

Apply this skill when you have MS/MS spectra contaminated with noise ions and need to improve compound identification accuracy. Specifically, use it when you have: (1) a query MS/MS spectrum with precursor m/z and suspect noise contamination, (2) the compound's SMILES string or molecular formula, and (3) the ionization adduct type. The skill is especially valuable before spectral matching against reference libraries, where noise ions reduce entropy similarity scores and produce false negatives.

When NOT to use

  • Input spectrum is already confirmed to be noise-free or from a clean analytical source with inherently low artifact levels.
  • Compound's SMILES or molecular formula is unknown or unreliable, as chemical noise classification depends critically on accurate molecular structure.
  • Spectrum is from a non-MS/MS data type (e.g., full-scan MS1 or chromatographic data) where the fragmentation logic does not apply.

Inputs

  • MS/MS spectrum (numpy array with m/z and intensity columns)
  • Compound SMILES string or molecular formula
  • Ionization adduct type (e.g., '[M+H]+', '[M+Na]+')
  • Precursor m/z (optional; can be calculated from SMILES and adduct)

Outputs

  • Denoised MS/MS spectrum (numpy array with m/z and intensity columns)
  • Noise classification labels (valid vs. noise) for each ion
  • Entropy similarity score (denoised spectrum vs. reference spectrum)

How to apply

Classify and remove noise in two sequential stages: (1) Electronic denoising: identify and remove ions with identical intensities that occur ≥4 times in the spectrum, as this pattern is empirically rare in authentic MS/MS data (verified on NIST23 database). (2) Formula-based chemical denoising: extract the master molecular formula from the SMILES and adduct using prep_formula, enumerate all possible subformulas via get_all_subformulas, then for each fragment ion use check_candidates to test whether it could arise from a chemically plausible subformula loss. Tag ions as valid or noise via get_denoise_tag, retain only valid ions, and restore the precursor region. Validate denoising success by computing entropy_similarity between the denoised spectrum and a ground-truth reference spectrum; a higher score indicates effective noise removal.

Related tools

  • spectral_denoising (Python package) (Primary implementation of electronic_denoising and formula_denoising functions for noise classification and removal) — https://github.com/FanzhouKong/spectral_denoising
  • RDkit (Parses SMILES strings and extracts molecular structure to derive formulas and subformula losses)
  • molmass (Computes molecular weights and mass offsets for formula-based candidate validation)
  • ms_entropy (Calculates entropy_similarity metric to evaluate denoising quality relative to reference spectra)
  • chemparse (Parses and manipulates chemical formula strings for formula_denoising workflow)

Examples

import spectral_denoising as sd; import numpy as np; peak_with_noise = sd.read_msp('sample_data/noisy_spectra.msp').iloc[0]['peaks']; peak_denoised = sd.spectral_denoising(peak_with_noise, 'O=c1nc[nH]c2nc[nH]c12', '[M+Na]+'); print(sd.entropy_similairty(peak_denoised, peak, pmz=pmz))

Evaluation signals

  • Electronic denoising removes all ions with identical intensities occurring ≥4 times; confirm removal by counting duplicate intensity values pre- and post-denoising.
  • Chemical denoising removes only ions that cannot be explained by any subformula loss from the master formula; validate by checking that all retained ions have corresponding candidate losses in check_candidates output.
  • Entropy similarity score between denoised spectrum and ground-truth reference is higher than between raw (noisy) spectrum and reference, indicating noise removal improved spectral match quality.
  • Denoised spectrum retains the precursor ion region (verified by add_spectra function), maintaining biological relevance.
  • Denoised spectrum has no zero-intensity ions and is sorted by m/z (confirmed by sanitize_spectrum wrapper).

Limitations

  • Electronic denoising threshold (≥4 identical intensities) is empirically derived from NIST23 and may not generalize to all instrumental platforms or noise regimes.
  • Chemical denoising accuracy depends on the completeness and correctness of the master formula; errors in SMILES parsing or adduct specification propagate downstream.
  • The algorithm assumes all chemically plausible subformula losses should be retained; spectra with unusual or instrument-specific fragmentation patterns may be over-denoised.
  • Python version must be ≥3.8 and <3.13 due to RDkit compatibility constraints; deployment on other Python versions may fail.

Evidence

  • [intro] Noise ions in MS/MS spectra are largely categorized as 1. electronic noises and 2. chemical noises.: "Noise ions in MS/MS spectra are largely categorized as 1. electronic noises and 2. chemical noises."
  • [other] The electronic_denoising function removes obvious electronic noise ions in MS/MS spectra: "The electronic_denoising function removes obvious electronic noise ions in MS/MS spectra"
  • [other] The formula_denoising function removes chemical noise ions in MS/MS spectra by evaluating if it could be formed from a chemically plausible subformula loss: "The formula_denoising function removes chemical noise ions in MS/MS spectra by evaluating if it could be formed from a chemically plausible subformula loss"
  • [other] Apply electronic_denoising to remove ions with identical intensities (≥4 occurrences): "apply electronic_denoising to remove ions with identical intensities (≥4 occurrences)"
  • [other] According to empiracally tested on NIST23 database, in a given spectrum, the number of ions with identical intensities more than 4 is extremely unlikely: "According to empiracally tested on NIST23 database, in a given spectrum, the number of ions with identical intensities more than 4 is extremely unlikely"
  • [other] For any given fragment ion, the algorithm will try to find a plausible subformula loss that could form this ion (function check_cnadidates): "For any given fragment ion, the algorithm will try to find a plausible subformula loss that could form this ion"
  • [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] Please use Python version between 3.8 to 3.12 for this package to work. RDkit currently does not have a distribution compitable to python 3.13: "Please use Python version between 3.8 to 3.12 for this package to work. RDkit currently does not have a distribution compitable to python 3.13"

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.