Repository to translate spectra to queries.
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.
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"
)
)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"
)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
)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")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
| 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) |
Allaire, JJ, Yihui Xie, Christophe Dervieux, et al. 2026. rmarkdown: Dynamic Documents for r. https://github.com/rstudio/rmarkdown.
Fairbanks, Mark. 2024. tidytable: Tidy Interface to “data.table”. https://doi.org/10.32614/CRAN.package.tidytable.
Gatto, Laurent, Johannes Rainer, and Sebastian Gibb. 2026. MsBackendMgf: Mass Spectrometry Data Backend for Mascot Generic Format (Mgf) Files. https://github.com/RforMassSpectrometry/MsBackendMgf.
Morgan, Martin. 2025. BiocVersion: Set the Appropriate Version of Bioconductor Packages.
Morgan, Martin, and Marcel Ramos. 2025. BiocManager: Access the Bioconductor Project Package Repository. https://doi.org/10.32614/CRAN.package.BiocManager.
R Core Team. 2026. R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing. https://doi.org/10.32614/R.manuals.
Rainer, Johannes, Andrea Vicini, Liesa Salzer, et al. 2022. “A Modular and Expandable Ecosystem for Metabolomics Data Annotation in r.” Metabolites 12: 173. https://doi.org/10.3390/metabo12020173.
Rutz, Adriano, and Sarah Szwarc. 2025. SpectraToQueries: SpectraToQueries Provides the Infrastructure to Translate Spectra to Queries.
Szwarc, Sarah, Adriano Rutz, Kyungha Lee, et al. 2025. “Translating Community-Wide Spectral Library into Actionable Chemical Knowledge: A Proof of Concept with Monoterpene Indole Alkaloids.” J. Cheminform. 17. https://doi.org/10.1186/s13321-025-01009-0.
Wickham, Hadley. 2011. “testthat: Get Started with Testing.” The R Journal 3: 5–10. https://journal.r-project.org/articles/RJ-2011-002/.
Xie, Yihui. 2014. “knitr: A Comprehensive Tool for Reproducible Research in R.” In Implementing Reproducible Computational Research, edited by Victoria Stodden, Friedrich Leisch, and Roger D. Peng. Chapman; Hall/CRC.
Xie, Yihui. 2015. Dynamic Documents with R and Knitr. 2nd ed. Chapman; Hall/CRC. https://yihui.org/knitr/.
Xie, Yihui. 2025. knitr: A General-Purpose Package for Dynamic Report Generation in R. https://yihui.org/knitr/.
Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Chapman; Hall/CRC. https://yihui.org/rmarkdown/.
Xie, Yihui, Christophe Dervieux, and Emily Riederer. 2020. R Markdown Cookbook. Chapman; Hall/CRC. https://yihui.org/rmarkdown-cookbook.
