| name | bioconductor-msbackendmassbank |
| description | Mass spectrometry (MS) data backend supporting import and export of MS/MS library spectra from MassBank record files. Different backends are available that allow handling of data in plain MassBank text file format or allow also to interact directly with MassBank SQL databases. Objects from this package are supposed to be used with the Spectra Bioconductor package. This package thus adds MassBank support to the Spectra package. |
MsBackendMassbank
Workflows
Standard Workflow
Mass spectrometry (MS) data backend supporting import and export of MS/MS library spectra from MassBank record files. Different backends are available that allow handling of data in plain MassBank text file format or allow also to interact directly with MassBank SQL databases. Objects from this package are supposed to be used with the Spectra Bioconductor package. This package thus adds MassBank support to the Spectra package.
library(Spectra)
library(MsBackendMassbank)
fls <- dir(system.file("extdata", package = "MsBackendMassbank"), full.names = TRUE, pattern = "txt$")
sps <- Spectra(fls, source = MsBackendMassbank(), backend = MsBackendDataFrame(), nonStop = TRUE)
sps <- dropNaSpectraVariables(sps)
Input: A character vector of paths to MassBank text files. Output: A Spectra object containing the imported mass spectrometry data.
When to Use
- Importing and exporting MS/MS library spectra from MassBank record files (plain text format) into
Spectra objects.
- Querying and interacting directly with a local MassBank SQL database (MySQL or SQLite) using
MsBackendMassbankSql.
- Comparing spectra similarity and generating mirror plots using
compareSpectra and plotSpectraMirror.
When NOT to Use
- For raw LC-MS data processing (e.g., peak picking, retention time correction), use
xcms.
- For handling non-MassBank formats like mzML or mzXML without MassBank metadata, use standard
Spectra backends like MsBackendMzR.
Data Requirements
- Plain text files in MassBank record format (one file per spectrum), or a local SQL database containing MassBank release dumps.
Key Parameters
- source: An instance of
MsBackendMassbank() or MsBackendMassbankSql() specifying the data source.
- backend: An instance of
MsBackendDataFrame() or other Spectra backends to store the imported data.
- nonStop (FALSE): If
TRUE, prevents the import from stopping when problematic MassBank files are encountered.
- metaBlock: Configured blocks of metadata fields to import, generated by
metaDataBlocks(ac = TRUE, ms = TRUE).
- ppm (40): Parts-per-million tolerance for m/z matching in
compareSpectra or plotSpectraMirror.
Best Practices
- Set
nonStop = TRUE when importing a large number of MassBank files to prevent a single malformed file from crashing the process.
- Use
dropNaSpectraVariables to remove imported spectra variables that contain only missing values across all spectra.
- Use
MsBackendMassbankSql for large-scale analyses to fetch data on demand from a local SQL database instead of loading thousands of text files into memory.
Common Pitfalls
- Attempting parallel processing with
MsBackendMassbankSql: The database connection cannot be shared across parallel processes, so parallel processing is silently disabled.
- Slow import times: Importing all metadata blocks can be slow; customize the imported blocks using
metaDataBlocks or use the SQL backend.
Alternatives
Spectra with MsBackendDataFrame for in-memory generic spectrum handling.
MsCoreUtils for low-level mass spectrometry helper functions.
Citations
- Witting, Rainer, Stravs 2026, MsBackendMassbank (vignette documentation)
References