agentsclimarketplace

Spectral noise synthesis poisson distribution

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/spectral-noise-synthesis-poisson-distribution

Use when when you have clean, baseline MS/MS spectra and need to create test datasets with known noise characteristics to benchmark denoising algorithms, compare denoising search performance, or validate that electronic and chemical noise removal functions correctly identify and remove injected.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill spectral-noise-synthesis-poisson-distribution

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

  • 14 stars14 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.8 KB, ~1.5k tokens by cl100k_base, as published. Nobody here has run it

spectral-noise-synthesis-poisson-distribution

Summary

Synthesize electronic and chemical noise ions for MS/MS spectra using Poisson-distributed intensities to create realistic noisy test datasets for benchmarking denoising and spectral matching algorithms. This skill enables controlled injection of known noise types into clean baseline spectra to evaluate robustness of compound identification workflows.

When to use

When you have clean, baseline MS/MS spectra and need to create test datasets with known noise characteristics to benchmark denoising algorithms, compare denoising search performance, or validate that electronic and chemical noise removal functions correctly identify and remove injected noise while preserving true fragment ions.

When NOT to use

  • Spectrum already contains real experimental noise that you wish to preserve or analyze—this skill replaces the spectrum with synthetic noise rather than augmenting real noise.
  • You need to model noise characteristics from an existing contaminated spectrum—use denoising search or entropy similarity instead to reverse-engineer noise patterns.
  • Input spectrum is in an unsupported format (not numpy array with [m/z, intensity] pairs)—convert or validate format first.

Inputs

  • clean spectrum (numpy array: shape [n, 2], dtype float32, columns [m/z, intensity])
  • precursor m/z (float)
  • lambda parameter for Poisson distribution (float, intensity scaling factor)
  • number of electronic noise ions to inject (integer)
  • number of chemical noise ions to inject (integer)
  • formula database (pre-sorted by mass, list or array of molecular formulas)

Outputs

  • noisy spectrum (numpy array: shape [m, 2], dtype float32, merged and deduplicated [m/z, intensity] pairs)
  • noise ion count validation report (integer: total ions after deduplication)

How to apply

Generate electronic noise by uniformly sampling m/z values between 50 and the precursor m/z, drawing intensities from a Poisson distribution with a specified lambda parameter, and creating a user-defined number of noise ion pairs. For chemical noise, randomly sample m/z values from a pre-sorted formula database (sorted by mass) and assign intensities from the same Poisson distribution. Merge the generated noise arrays with the clean spectrum peak array, then remove duplicate m/z entries by keeping only the highest intensity for each m/z position. Validate the synthetic dataset by confirming the output arrays contain the expected total ion count (original + injected noise ions) and that m/z ranges match the specified bounds (50 to precursor_mz for electronic noise, formula_db range for chemical noise).

Related tools

  • spectral-denoising (Python package) (Host library containing generate_noise, generate_chemical_noise, and add_noise functions; also provides read_msp, write_msp, spectral_entropy, and normalized_entropy utilities for I/O and validation of synthetic datasets.) — https://github.com/FanzhouKong/spectral_denoising
  • numpy (Array creation, Poisson sampling (numpy.random.poisson), uniform sampling (numpy.random.uniform), and array merging for noise synthesis and deduplication.)
  • scipy (Statistical distributions and array operations for Poisson parameter validation and optional intensity transformation.)
  • RDkit (Optional: chemical formula parsing and validation if formula database requires on-the-fly structure checks.)

Examples

import numpy as np
import spectral_denoising as sd
from spectral_denoising.noise import *
peak_clean = np.array([[48.99, 154.0], [63.01, 265.0]], dtype=np.float32)
electronic_noise = sd.generate_noise(precursor_mz=200.0, lambda_param=5.0, num_ions=10)
chemical_noise = sd.generate_chemical_noise(lambda_param=3.0, num_ions=15)
peak_noisy = sd.add_noise(peak_clean, electronic_noise + chemical_noise)

Evaluation signals

  • Output spectrum m/z range for electronic noise exactly matches [50, precursor_mz]; no synthetic ions fall outside this range.
  • Output spectrum m/z range for chemical noise exactly matches the min and max masses in the pre-sorted formula_db.
  • Output ion count equals input ion count plus the number of injected noise ions (after deduplication); deduplication removes fewer ions than the number of duplicate m/z keys introduced.
  • Spectrum entropy of synthetic noisy spectrum is measurably higher than the clean baseline spectrum (entropy_similarity < 1.0); entropy_similarity(noisy, clean, pmz) < entropy_similarity(denoised, clean, pmz) after denoising.
  • No duplicate m/z values remain in the output array; each m/z entry retains the highest intensity among collisions.

Limitations

  • Poisson distribution assumes random, uncorrelated intensity fluctuations; real electronic noise may show temporal correlations or systematic bias that this model does not capture.
  • Chemical noise depends entirely on the completeness and accuracy of the pre-sorted formula_db; missing or incorrect formulas will not be represented in synthetic noise.
  • Uniform m/z sampling for electronic noise does not account for instrument detection sensitivity variations across the m/z range.
  • The deduplication step (keeping max intensity per m/z) may underestimate noise severity if real spectra exhibit m/z collisions with lower total intensity; use with caution for very high-noise benchmarking.

Evidence

  • [other] Define generate_noise function to synthesize electronic noise: sample m/z values uniformly between 50 and precursor m/z, generate intensities from Poisson distribution with parameter lambda, and create specified number of noise ion pairs.: "Define generate_noise function to synthesize electronic noise: sample m/z values uniformly between 50 and precursor m/z, generate intensities from Poisson distribution with parameter lambda, and"
  • [other] Define generate_chemical_noise function to synthesize chemical noise: randomly sample m/z values from a pre-sorted formula database (formula_db), generate corresponding intensities from Poisson distribution with given lambda parameter, and create specified number of chemical noise ions.: "Define generate_chemical_noise function to synthesize chemical noise: randomly sample m/z values from a pre-sorted formula database (formula_db), generate corresponding intensities from Poisson"
  • [other] Define add_noise function to combine clean spectrum with generated noise by merging peak arrays and removing duplicate m/z entries (keeping highest intensity).: "Define add_noise function to combine clean spectrum with generated noise by merging peak arrays and removing duplicate m/z entries (keeping highest intensity)."
  • [other] Validate both functions by creating test spectra with known baseline, adding noise, and confirming output arrays contain expected ion counts and m/z ranges.: "Validate both functions by creating test spectra with known baseline, adding noise, and confirming output arrays contain expected ion counts and m/z ranges."
  • [other] The formula_db can be found at: Formula_db. It is already sorted by mass.: "The formula_db can be found at: Formula_db. It is already sorted by mass."
  • [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."

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 326,861. 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.