MsBackendMassbank: MS data backend for mgf files

View source: R/MsBackendMassbank.R

MsBackendMassbankR Documentation

MS data backend for mgf files

Description

The MsBackendMassbank class supports import of MS/MS spectra data from MS/MS spectrum data from Massbank files. After initial import, the full MS data is kept in memory. MsBackendMassbank extends the MsBackendDataFrame() backend directly and supports thus the applyProcessing() function to make data manipulations persistent.

New objects are created with the MsBackendMassbank function. The backendInitialize method has to be subsequently called to initialize the object and import MS/MS data from (one or more) MassBank files. Optional parameter nonStop allows to specify whether the import returns with an error if one of the text files lacks required data, such as mz and intensity values (default nonStop = FALSE), or whether only affected file(s) is(are) skipped and a warning is shown (nonStop = TRUE). Note that any other error will abort import regardless of parameter nonStop.

Usage

## S4 method for signature 'MsBackendMassbank'
backendInitialize(
  object,
  files,
  metaBlocks = metaDataBlocks(),
  nonStop = FALSE,
  ...,
  BPPARAM = bpparam()
)

MsBackendMassbank()

## S4 method for signature 'MsBackendMassbank'
spectraVariableMapping(object, format = c("Massbank"))

## S4 method for signature 'MsBackendMassbank'
export(
  object,
  x,
  file = tempfile(),
  mapping = spectraVariableMapping(MsBackendMassbank()),
  ...
)

Arguments

object

Instance of MsBackendMassbank class.

files

character with the (full) file name(s) of the MassBank file(s) from which MS/MS data should be imported.

metaBlocks

data.frame indicating which metadata shall be imported. Default is metaDataBlocks().

nonStop

logical(1) whether import should be stopped if an xml file does not contain all required fields. Defaults to nonStop = FALSE.

...

Currently ignored.

BPPARAM

Parameter object defining the parallel processing setup to import data in parallel. Defaults to BPPARAM = bpparam(). See bpparam() for more information.

format

for spectraVariableMapping: character(1) defining the format to be used. Currently only format = "Massbank" is supported.

x

Spectra() object that should be exported.

file

for export: character(1) defining the output file.

mapping

for export: named character vector allowing to specify how fields from the Massbank file should be renamed. Names are supposed to be the spectra variable name and values of the vector the field names in the Massbank file. See output of spectraVariableMapping(MsBackendMassbank()) for the expected format.

Value

backendInitialize and MsBackendMassbank return an instance of MsBackendMassbank-class.

Author(s)

Michael Witting

Examples


## Create an MsBackendMassbank backend and import data from a test file.
fls <- dir(system.file("extdata", package = "MsBackendMassbank"),
    full.names = TRUE, pattern = "txt$")
be <- backendInitialize(MsBackendMassbank(), fls)
be

be$msLevel
be$intensity
be$mz

## Initializing a backend reading additional metadata columns/information
mb <- metaDataBlocks()
mb
mb[1, 2] <- TRUE

be <- backendInitialize(MsBackendMassbank(), fls, metaBlocks = mb)
spectraVariables(be)
be$instrument

rformassspectrometry/MsBackendMassbank documentation built on Sept. 28, 2024, 5:42 a.m.