agentsclimarketplace

Ms2 spectrum extraction and consensus building

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v1/skills/ms2-spectrum-extraction-and-consensus-building

Use when when you have DDA LC-MS/MS data (mzML format) with identified chromatographic peaks at a specific m/z (e.g., 304.1131) and multiple MS2 spectra fragmented from that precursor, and you need to produce a single high-confidence MS2 spectrum for comparison against reference databases (e.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill ms2-spectrum-extraction-and-consensus-building

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

6.8 KB, ~1.3k tokens by cl100k_base, as published. Nobody here has run it

MS2 Spectrum Extraction and Consensus Building

Summary

Extract MS2 spectra associated with chromatographic peaks detected in DDA LC-MS data, then combine multiple MS2 scans into a single consensus spectrum to improve signal-to-noise ratio and enable robust compound identification through spectral matching.

When to use

When you have DDA LC-MS/MS data (mzML format) with identified chromatographic peaks at a specific m/z (e.g., 304.1131) and multiple MS2 spectra fragmented from that precursor, and you need to produce a single high-confidence MS2 spectrum for comparison against reference databases (e.g., Metlin, GNPS) to identify the compound.

When NOT to use

  • Input is already a single, high-quality MS2 spectrum — consensus building adds no value if only one scan is available.
  • MS1-only data (no MS2 fragmentation data) — chromPeakSpectra() requires tandem data.
  • Precursor m/z is not clearly separated from interferents in the same retention time window — poor peak detection will yield unreliable consensus spectra.

Inputs

  • DDA LC-MS/MS raw data (mzML format)
  • Retention time range (seconds) containing the target chromatographic peak
  • Target precursor m/z value
  • Reference MS2 spectra in MGF format (e.g., Metlin ID 2724, 72445)

Outputs

  • Consensus MS2 spectrum (single aggregated fragmentation pattern)
  • Similarity scores from compareSpectra() (dot-product values for each reference match)
  • Mirror-plot visualization comparing consensus spectrum to reference spectra

How to apply

First, detect chromatographic peaks in MS level 1 data using findChromPeaks() with CentWaveParam (e.g., snthresh=5, noise=100, ppm=10), filtering to the retention time window containing your peak of interest (e.g., 230–610 s). Next, extract all MS2 spectra associated with the detected chromatographic peak using chromPeakSpectra(), which retrieves fragmentations triggered by that precursor. Combine the multiple MS2 spectra into a single consensus spectrum using combineSpectra() with combinePeaks(), which aggregates peak m/z and intensities across scans. Finally, match the consensus spectrum against reference spectra (in MGF format) using compareSpectra() with the normalized dot-product method at 40 ppm tolerance to evaluate similarity scores and identify the compound.

Related tools

  • xcms (Peak detection (findChromPeaks), spectral extraction (chromPeakSpectra), data loading and filtering) — https://github.com/sneumann/xcms
  • Spectra (In-memory representation, manipulation, and comparison of MS2 spectra)
  • MsBackendMgf (Loading reference spectra from MGF (Mascot Generic Format) files)
  • MetaboCoreUtils (compareSpectra() implementation with normalized dot-product similarity metric)
  • MsFeatures (General MS feature grouping and metadata management)

Examples

dda_data <- filterRt(dda_data, rt = c(230, 610)); peaks <- findChromPeaks(dda_data, CentWaveParam(snthresh=5, noise=100, ppm=10)); ms2_spec <- chromPeakSpectra(dda_data, peaks); consensus <- combineSpectra(ms2_spec, combinePeaks); similarity <- compareSpectra(consensus, reference_spectra, ppm=40)

Evaluation signals

  • Consensus MS2 spectrum contains expected fragment ions for the target compound (e.g., characteristic loss patterns for pesticides).
  • Similarity score (dot-product) to the correct reference compound is significantly higher (e.g., >0.7) than to false positives, indicating unambiguous identification.
  • Mirror plot visually shows strong peak alignment between consensus and reference spectrum, with major fragment m/z values matching within 40 ppm tolerance.
  • Number of MS2 scans combined is > 1 and reflects the signal intensity across multiple chromatographic scans at the target m/z.
  • Consensus spectrum m/z axis and intensity values are consistent with the source raw data (no NaN or negative intensities).

Limitations

  • Consensus building assumes all extracted MS2 scans derive from the same compound; co-isolation of multiple precursors in the same isolation window will produce a mixed spectrum.
  • Low signal-to-noise in individual MS2 scans may not be fully recovered by consensus averaging; weak fragments risk being lost if present in only a minority of scans.
  • Peak detection parameters (snthresh, noise, ppm) must be tuned for the specific instrument and sample matrix; suboptimal thresholds may miss genuine peaks or include noise artifacts.
  • Spectrum matching relies on the availability and quality of reference MS2 spectra in MGF; compounds absent from Metlin or GNPS cannot be identified by this approach.

Evidence

  • [intro] Extract MS2 spectra associated with chromatographic peaks using chromPeakSpectra().: "Spectra for identified chromatographic peaks can be extracted with the chromPeakSpectra() method."
  • [intro] Consensus building combines multiple MS2 scans via combineSpectra() and combinePeaks().: "We next reduce this to a single MS2 spectrum using the combineSpectra() method employing the combinePeaks() function"
  • [intro] Spectral matching uses compareSpectra() with normalized dot-product and ppm tolerance.: "we can also calculate similarities between them with the compareSpectra() method"
  • [intro] CentWaveParam used for peak detection with specific thresholds.: "findChromPeaks() method. Below we define the settings for a centWave-based peak detection"
  • [other] The article demonstrates identification of m/z 304.1131 peak as Fenamiphos via MS2 similarity.: "The consensus MS2 spectrum from the chromatographic peak at m/z 304.1131 has high similarity to Fenamiphos but not to Flumazenil when compared using the normalized dot-product method with 40 ppm"

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.