SpectraToQueries 
Repository to translate spectra to queries.
Requirements
Here is what you minimally need:
- A file containing MS/MS spectra with associated skeleton information (or any other relevant chemical classification) provided as metadata. This structure information, stored in the metadata field “skeleton”, allows the generation of queries specific to a given skeleton by extracting repetitive skeleton-specific fragmentation patterns. The MIADB file is provided as an example.
Installation
As the package is not (yet) available on CRAN, you will need to install with:
install.packages(
"SpectraToQueries",
repos = c(
"https://spectra-to-knowledge.r-universe.dev",
"https://cran.r-universe.dev",
"https://bioc.r-universe.dev"
)
)Use
To run the default example with raw spectra from the Monoterpene Indole Alkaloids Database (MIADB):
SpectraToQueries::spectra_to_queries()To run with grouped spectra (pre-combined by skeleton classification):
SpectraToQueries::spectra_to_queries(spectra = "grouped")To generate diagnostic ions queries from your own spectra:
SpectraToQueries::spectra_to_queries(
spectra = "yourAwesomeSpectra.mgf",
export = "path/yourEvenBetterResults.tsv"
)Viewing all parameters
SpectraToQueries::spectra_to_queries(
spectra = NULL,
export = "data/interim/queries.tsv",
dalton = 0.01,
decimals = 4L,
intensity_min = 0.0,
ions_max = 10L,
n_skel_min = 5L,
n_spec_min = 3L,
ppm = 30.0,
mcc_min = 0.0,
precision_min = 0.0,
recall_min = 0.0,
zero_val = 0.0
)Example data
The package includes two example datasets from MIADB:
mia_spectra_df— Raw spectra (321 spectra)mia_spectra_grouped_df— Pre-grouped spectra (321 spectra)
These are stored as portable data.frames (with mz and intensity as list columns) and automatically converted to Spectra objects when loaded.
To access them directly:
utils::data(mia_spectra_df, package = "SpectraToQueries")
utils::data(mia_spectra_grouped_df, package = "SpectraToQueries")Main Citations
Translating community-wide spectral library into actionable chemical knowledge: a proof of concept with monoterpene indole alkaloids: https://doi.org/10.1186/s13321-025-01009-0
Additional software credits
| Package | Version | Citation |
|---|---|---|
| base | 4.6.1 | R Core Team (2026) |
| BiocManager | 1.30.27 | Morgan and Ramos (2025) |
| BiocVersion | 3.23.1 | Morgan (2025) |
| knitr | 1.51 | Xie (2014); Xie (2015); Xie (2025) |
| MsBackendMgf | 1.20.1 | Gatto et al. (2026) |
| rmarkdown | 2.31 | Xie et al. (2018); Xie et al. (2020); Allaire et al. (2026) |
| Spectra | 1.22.2 | Rainer et al. (2022) |
| SpectraToQueries | 0.0.0.9002 | Rutz and Szwarc (2025); Szwarc et al. (2025) |
| testthat | 3.3.2 | Wickham (2011) |
| tidytable | 0.11.2 | Fairbanks (2024) |
