peak-and-neutral-loss-counting
Summary
Counts occurrences of MS2 peaks and neutral losses (to precursor) within individual samples to generate sample-level MS2 fingerprints. This quantitative summarization enables retention-time-agnostic sample comparison and alignment in metabolomics workflows.
When to use
When you have matchms-processed MS2 spectra from multiple samples and need to create comparable sample-level signatures for cross-sample analysis, particularly when samples are chemodiverse, have poor feature overlap, or exhibit strong retention time shifts across LC methods or MS technologies.
When NOT to use
- Input spectra have not been preprocessed through matchms (data quality and metadata standardization cannot be assumed).
- Retention-time information is critical for your analysis; MEMO is explicitly RT-agnostic and discards RT.
- You require feature-by-sample matrices with exact m/z alignment; MEMO fingerprints are sample-level aggregate counts, not individual spectral features.
Inputs
- Per-sample MS2 spectra (matchms Spectrum objects)
- Precursor m/z values for each spectrum
- spec2vec document representations
Outputs
- Per-sample MS2 fingerprint vectors (occurrence counts)
- MemoMatrix: unified fingerprint alignment matrix (numpy array)
How to apply
Load per-sample MS2 spectra processed through matchms and extract spec2vec document representations. For each sample, systematically count the frequency of each unique MS2 fragment peak m/z value and neutral loss mass (calculated relative to precursor m/z). Aggregate these counts into a fingerprint vector where each element represents the occurrence frequency of a specific m/z or loss. The counting is performed independently per sample before aggregation; no cross-sample normalization occurs at this stage. Fingerprints are then assembled into a unified matrix via numpy array operations to enable downstream alignment and filtering.
Related tools
- matchms (Processes and standardizes MS2 spectra; provides metadata cleaning and peak filtering for input to fingerprinting) — https://github.com/matchms/matchms
- spec2vec (Generates spectral embeddings and document representations from MS2 fragmentation relationships for fingerprint construction) — https://github.com/iomega/spec2vec
- numpy (Aggregates per-sample fingerprint vectors into unified MemoMatrix alignment arrays)
- MEMO (Complete framework implementing peak/neutral-loss counting and sample vectorization for metabolomics) — https://github.com/mandelbrot-project/memo
Evaluation signals
- Fingerprint vector length matches the total number of unique MS2 m/z values and neutral losses observed across all samples.
- All occurrence counts are non-negative integers; no negative or fractional counts are present.
- MemoMatrix dimensions are (n_samples, n_features) where n_features is constant across all rows, confirming feature alignment consistency.
- Sum of counts per sample correlates with the total number of MS2 spectra in that sample, validating exhaustive counting.
- Fingerprints from blank/control samples show predictably low or sparse counts compared to active samples before filtering.
Limitations
- Fingerprints discard spectral intensity and fragmentation fragmentation pathway information; only presence/absence frequency is retained.
- MS2 peak clustering or tolerance-based grouping is not applied; each distinct m/z is counted separately, potentially inflating feature dimensionality in high-resolution instruments.
- Neutral loss calculation depends on accurate precursor m/z assignment; errors propagate into incorrect loss counts.
- Very small samples or samples with few MS2 spectra may produce sparse, uninformative fingerprints with high noise-to-signal ratio.
Evidence
- [intro] MS2 fingerprints are generated by counting occurrences of MS2 peaks and neutral losses in each sample: "The occurence of MS2 peaks and neutral losses (to the precursor) in each sample is counted and used to generate an MS2 fingerprint"
- [intro] Fingerprints are aligned in a second stage to enable cross-sample comparison: "These fingerprints can in a second stage be aligned to compare different samples"
- [readme] MEMO is built on matchms and spec2vec for MS2 handling: "MEMO is mainly built on
matchms_ andspec2vec_ packages for handling the MS2 spectra" - [other] Fingerprint aggregation uses numpy array operations to ensure consistent feature alignment: "Aggregate fingerprint vectors across all samples into a unified matrix using numpy array operations, ensuring consistent feature alignment"
- [readme] MEMO suits chemodiverse samples with poor feature overlap or strong RT shift: "MEMO suits particularly well to compare chemodiverse samples, ie with a poor features overlap, or to compare samples with a strong RT shift"