agentsclimarketplace

Spectral intensity normalization

Skill HolobiomicsLab/asb-skill-collections/packs/metabolomics/ion-mobility/skills/spectral-intensity-normalization

Use when after removing precursor and noise peaks from an MsmsSpectrum object when the spectrum contains peaks with highly variable intensities (e.g., one or two dominant peaks with many weaker fragments).From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill spectral-intensity-normalization

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

spectral-intensity-normalization

Summary

Normalize peak intensities in tandem mass spectrometry spectra by applying scaling transformations (e.g., square-root scaling) to de-emphasize overly intense peaks and improve downstream spectral comparison and matching. This is a critical preprocessing step that follows noise removal and precedes spectral annotation or database matching.

When to use

Apply this skill after removing precursor and noise peaks from an MsmsSpectrum object when the spectrum contains peaks with highly variable intensities (e.g., one or two dominant peaks with many weaker fragments). Intensity scaling is particularly needed before spectral similarity computations, database searches, or when feeding spectra to machine learning pipelines that assume normalized feature ranges.

When NOT to use

  • The spectrum has already been normalized or intensity-scaled by upstream preprocessing.
  • Your analysis requires raw, unnormalized intensities for absolute quantitation or ion current measurements.
  • You are working with ion mobility or retention time data where intensity normalization is not applicable.

Inputs

  • MsmsSpectrum object (filtered for m/z range, with precursor peak removed and noise-filtered)
  • Peak intensity array with peaks at ≥5% base peak intensity

Outputs

  • MsmsSpectrum object with square-root-scaled peak intensities
  • Normalized intensity array suitable for spectral similarity and matching workflows

How to apply

After loading an MsmsSpectrum and applying precursor peak removal and intensity filtering (retaining peaks ≥5% base peak intensity and the top 50 most intense peaks), call the scale_intensity() method with the 'root' parameter to apply square-root scaling. This transformation compresses the dynamic range by taking the square root of each peak intensity, which reduces the influence of the most intense peaks while preserving the relative ordering of smaller peaks. The choice of 'root' scaling is motivated by the goal of de-emphasizing overly intense peaks that would otherwise dominate spectral matching metrics. Apply this normalization consistently across all spectra in a cohort to ensure fair comparison.

Related tools

  • spectrum_utils (Provides the MsmsSpectrum.scale_intensity() method with 'root' parameter and the complete spectrum preprocessing pipeline (precursor/noise removal, intensity filtering, and scaling).) — https://github.com/bittremieux/spectrum_utils
  • NumPy (Underlying computational library used by spectrum_utils to implement intensity scaling operations efficiently.) — https://www.numpy.org/
  • Numba (JIT compiler used to optimize intensity normalization computations for large-scale spectral datasets.) — http://numba.pydata.org/

Examples

spectrum.scale_intensity('root')

Evaluation signals

  • Verify that the scaled spectrum has intensities in the range [0, sqrt(base_peak_intensity)], with the base peak scaled to its square root.
  • Confirm that peak intensity ordering is preserved after scaling (if peak A > peak B before scaling, then scaled(A) > scaled(B) after).
  • Check that the spectrum object retains all fragment peak annotations (m/z, intensity, and any peptide fragment labels) after scaling.
  • Validate that the normalized spectrum can be successfully used in downstream spectral similarity calculations (e.g., cosine similarity with reference spectra) without producing NaN or Inf values.
  • Ensure that the number of peaks in the spectrum remains ≤50 after scaling (i.e., no peaks are added or removed by the normalization step).

Limitations

  • Square-root scaling assumes that peak intensity follows a power-law or log-normal distribution; this may not hold for spectra with unusual intensity distributions or very weak signals.
  • The 'root' scaling method is one of several possible normalization approaches; alternative scaling functions (e.g., log, arcsinh, or z-score normalization) may be more appropriate for certain spectral types or downstream analyses.
  • Intensity normalization is applied uniformly across all peaks regardless of their mass-to-charge ratio; this does not account for m/z-dependent systematic biases in mass spectrometer ion detection efficiency.
  • The normalization step does not correct for charge state, fragmentation efficiency, or other physical properties that affect absolute peak intensities; it is a relative, not absolute, normalization.

Evidence

  • [other] Scale the peak intensities by their square root to de-emphasize overly intense peaks: "Scale the peak intensities by their square root to de-emphasize overly intense peaks"
  • [intro] Common spectrum processing operations (precursor & noise peak removal, intensity filtering, and intensity scaling) optimized for computational efficiency: "Common spectrum processing operations (precursor & noise peak removal, intensity filtering, and intensity scaling) optimized for computational efficiency."
  • [other] Remove low-intensity noise peaks by retaining peaks at least 5% of base peak intensity and restrict to 50 most intense peaks: "Remove low-intensity noise peaks by only retaining peaks that are at at least 5% of the base peak intensity and restrict the total number of peaks to the 50 most intense peaks"
  • [other] Spectrum processing in spectrum_utils optimized using NumPy and Numba: "Spectrum processing in spectrum_utils has been optimized for computational efficiency using NumPy and Numba"
  • [other] Call scale_intensity with root parameter as part of sequential preprocessing workflow: "Call scale_intensity('root') to scale peak intensities by their square root to de-emphasize overly intense peaks"

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.