agentsclimarketplace

Mass spectral similarity scoring across samples

Skill HolobiomicsLab/asb-skill-collections/collections/metabolomics/v2/skills/mass-spectral-similarity-scoring-across-samples

Use when after XCMS feature detection, grouping, and retention time correction when you have aligned features with consistent retention times and intensity patterns across samples.From its SKILL.md

Install
npx -y skills add HolobiomicsLab/asb-skill-collections --skill mass-spectral-similarity-scoring-across-samples

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

mass-spectral-similarity-scoring-across-samples

License: restricted — no clear open-source license detected for the underlying tool; verify licensing before commercial use or redistribution. <!-- asb-license-banner -->

Summary

Compute combined retention time and intensity-correlation similarity scores to group mass spectrometry features derived from the same compound. This skill combines approximate retention time matching with quantitative trend correlation across samples to identify co-eluting, co-varying features that represent isotopes, adducts, and fragments of a single metabolite.

When to use

Apply this skill after XCMS feature detection, grouping, and retention time correction when you have aligned features with consistent retention times and intensity patterns across samples. Use it to disambiguate which features belong to the same molecular entity before molecular weight inference or spectral matching—especially in non-targeted LC-MS or GC-MS metabolomics where each compound produces multiple signals (isotopes, [M+H]+, [M+Na]+, fragments).

When NOT to use

  • Input features have not undergone retention time correction or regrouping; clustering will be misled by drift.
  • Feature table is already clustered or de-isotoped by another method; re-clustering risks fragmentation or over-merging.
  • Samples have highly variable chromatographic performance (e.g., very long or very short runs); intensity correlation becomes unreliable.

Inputs

  • XCMS xcmsSet object (post-grouping, retention-time-corrected, filled peaks)
  • Experiment design metadata (sample-to-batch/group assignments)
  • Feature abundance matrix with aligned m/z and retention time

Outputs

  • RC object (RAMClustR clustering result) with cluster assignments for each feature
  • Spectral abundance matrix (RC$SpecAbund) with cluster-level intensities
  • .msp format spectral file (one entry per cluster, suitable for MSFinder/Sirius import)
  • Cluster annotations and molecular weight inferences

How to apply

For each pair of XCMS features, compute a retention time similarity score (e.g., Euclidean distance or correlation of retention times across replicates) and an intensity correlation score (Pearson or Spearman correlation of quantitative abundance across all samples). Multiply the two scores to obtain a combined similarity metric that requires both conditions (similar RT and correlated intensity) to be satisfied simultaneously. Submit this scored feature-pair matrix to hierarchical clustering (e.g., Euclidean or average linkage), then apply dynamic tree cutting to partition the dendrogram into clusters. Each cluster represents features inferred to derive from one compound. The rationale is that true co-features must co-elute (RT proximity) AND co-vary quantitatively (intensity correlation), whereas false positives violate one or both conditions.

Related tools

  • XCMS (Performs initial feature detection, grouping by m/z and RT, retention time correction, and regrouping to produce the aligned feature set that is input to similarity scoring.)
  • dynamicTreeCut (Cuts the hierarchical clustering dendrogram into clusters based on branch structure, avoiding arbitrary height thresholds and automatically merging or splitting branches to define cluster boundaries.)
  • RAMClustR (Orchestrates similarity scoring, hierarchical clustering, and dynamic tree cutting; outputs RC object with cluster assignments, spectral abundance matrix, and .msp exports.) — https://github.com/cbroeckl/RAMClustR
  • InterpretMSSpectrum (Provides findMain function adapted within RAMClustR to infer molecular weight from cluster mass values using multiple scoring methods.)
  • MSFinder (External software that imports .mat or .msp spectral output from RAMClustR for spectral matching and structural annotation.)
  • Sirius (External software that imports .ms spectral output from RAMClustR for spectral matching and structural annotation.)

Examples

RC <- ramclustR(xcmsObj = xset, ExpDes = experiment); RC <- do.findmain(RC, mode = "positive", mzabs.error = 0.02, ppm.error = 10)

Evaluation signals

  • Each cluster contains features with approximately equal retention times (within instrument drift tolerance, typically <1–2 min).
  • Features within a cluster show strong Pearson/Spearman correlation (r > 0.7–0.9) of intensity across samples.
  • Cluster mass values form isotopic or adduct patterns (e.g., M, M+1, M+2 for 12C/13C; M+23 for sodium adduct) consistent with known ionization rules.
  • .msp spectral file is generated with one entry per cluster; each entry contains aggregated spectra suitable for library matching.
  • Downstream molecular weight inference (via do.findmain) converges on a single inferred mass per cluster with ~90% agreement between independent scoring methods.

Limitations

  • Algorithm assumes features from the same compound have approximately equal retention times; early/late-eluting isomers or chromatographic anomalies may fragment a single compound into multiple clusters.
  • Intensity correlation requires sufficient sample-to-sample variation; uniform or very low-variance samples reduce discriminative power.
  • No changelog or version history available; breaking changes between releases are undocumented, potentially affecting reproducibility.
  • Scoring method combines RT and correlation via multiplication, which is heuristic; edge cases (e.g., near-zero RT distance + high correlation) may produce unintuitive boundary behavior.
  • Dynamic tree cutting is automatic; no manual post-hoc validation or expert curation of clusters is provided.

Evidence

  • [intro] Two-condition requirement for co-features: "two features derived from the same compound with have (approximately) the same retention time. The second is that two features derived from the same compound will have (approximately) the same"
  • [intro] Product scoring rationale: "Since both conditions must be met, the product of the two similarity scores provides the best approximatio of the total similarity score"
  • [intro] Hierarchical clustering and dynamic tree cutting: "submitting this score matrix for heirarchical clustering, and then cutting the resulting dendrogram into neat chunks using the dynamicTreeCut package"
  • [intro] Unsupervised, platform-agnostic approach: "RAMClustR was designed to group features designed from the same compound using an approach which is 1. unsupervised, 2. platform agnosic, and 3. devoid of curated rules"
  • [intro] RC object outputs and SpecAbund matrix: "Running ramclustR on an XCMS xcmsSet object produces: (1) an RC object with each XCMS feature assigned to a cluster, (2) a new 'spectra' directory containing a .msp file named after the project with"
  • [readme] README: stepwise workflow and cluster inspection: "ramclustObj <- rc.ramclustr(ramclustObj = ramclustObj); ramclustObj <- do.findmain(ramclustObj = ramclustObj); print(ramclustobj$ann); print(ramclustobj$nfeat); print(ramclustobj$SpecAbund[,1:6])"

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.