MsBackendCompDb: CompDb-based MS spectrum backend

View source: R/MsBackendCompDb-functions.R

MsBackendCompDbR Documentation

CompDb-based MS spectrum backend

Description

The MsBackendCompDb represents MS2 spectra data from a CompDb() object/database. The object keeps only the primary keys of the spectra, the associated compound IDs and the precursor m/z values in memory and has thus only a very low memory footprint. All spectra variables, including m/z and intensity values are retrieved from the database on-demand. By extending the Spectra::MsBackendCached() class directly, MsBackendCompDb supports adding/replacing spectra variables. These values are however only cached within the object and not propagated (written) to the database.

It is not intended that users create or use instances of this class directly, the Spectra::Spectra() call on CompDb() will return a Spectra object that uses this backend.

The MsBackendCompDb does not support parallel processing because the database connection stored within the object can not be used across multiple parallel processes. The backendBpparam() method for MsBackendCompDb thus returns always SerialParam and hence any function that uses this method to check for parallel processing capability of a MsBackend will by default disable parallel processing.

Usage

MsBackendCompDb()

## S4 method for signature 'MsBackendCompDb'
backendInitialize(object, x, filter, ...)

## S4 method for signature 'MsBackendCompDb'
show(object)

## S4 method for signature 'MsBackendCompDb'
peaksData(object, columns = c("mz", "intensity"))

## S4 method for signature 'MsBackendCompDb'
peaksVariables(object)

## S4 method for signature 'MsBackendCompDb'
dataStorage(object)

## S4 replacement method for signature 'MsBackendCompDb'
intensity(object) <- value

## S4 replacement method for signature 'MsBackendCompDb'
mz(object) <- value

## S4 method for signature 'MsBackendCompDb'
spectraData(object, columns = spectraVariables(object))

## S4 method for signature 'MsBackendCompDb'
spectraNames(object)

## S4 replacement method for signature 'MsBackendCompDb'
spectraNames(object) <- value

## S4 method for signature 'MsBackendCompDb,ANY'
x[i, j, ..., drop = FALSE]

## S4 method for signature 'MsBackendCompDb,ANY'
extractByIndex(object, i)

## S4 replacement method for signature 'MsBackendCompDb'
x$name <- value

## S4 method for signature 'MsBackendCompDb'
precScanNum(object)

## S4 method for signature 'MsBackendCompDb'
tic(object, initial = TRUE)

## S4 method for signature 'MsBackendCompDb'
backendBpparam(object, BPPARAM = bpparam())

Arguments

object

an MsBackendCompDb instance.

x

an MsBackendCompDb instance.

filter

for backendInitialize(): optional filter expression to specify which elements to retrieve from the database.

...

ignored.

columns

for spectraData(): character with names of columns/spectra variables that should be returned. Defaults to spectraVariables(object). Database columns "ms_level", "precursor_mz", "precursor_intensity", "precursor_charge" are mapped to the core Spectra variables msLevel, precursorMz, precursorIntensity and precursorCharge, respectively. For peaksData: character with the names of the peaks columns to return. Use peaksVariables for supported values.

value

for ⁠$<-⁠: the replacement values.

i

For [: integer, logical or character to subset the object.

j

For [: not supported.

drop

For [: not considered.

name

for ⁠$<-⁠: the name of the spectra variable to replace.

initial

for tic(): logical(1) whether original total ion current values should be returned or if the values should be calculated based on the actual intensity values of each spectrum.

BPPARAM

for backendBpparam(): BiocParallel parallel processing setup. See BiocParallel::bpparam() for more information.

Value

See the description of the respective function.

Methods implemented for MsBackendCompDb

The methods listed here are implemented for the MsBackendCompDb. All other methods are inherited directly from the parent Spectra::MsBackendCached() class. See the help of Spectra::MsBackend() in the Spectra package for a complete listing of methods.

  • peaksData(): gets the full list of peak matrices. Returns a list(), length equal to the number of spectra and each element being a matrix with columns "mz" and "intensity" with the spectra's m/z and intensity values.

  • peaksVariables(): lists the available peaks variables in the backend (database). These can be used for parameter columns of peaksData().

  • ⁠intensity<-⁠: not supported.

  • ⁠mz<-⁠: not supported.

  • spectraData(): returns the complete spectrum data including m/z and intensity values as a S4Vectors::DataFrame().

  • ⁠$<-⁠: replace or add a spectrum variable. Note that mz, intensity and spectrum_id variables can not be replaced.

Note

For higher performance it is suggested to change the backend of the Spectra::Spectra() object to an Spectra::MsBackendMemory() backend with the Spectra::setBackend() method of Spectra objects.

Author(s)

Johannes Rainer

Examples


## MsBackendCompDb are not expected to be created/instanciated by users
## directly. Users also almost never directly interact with this type of
## object, as it is intented as a pure data backend for the `Spectra` object.
## Users will thus access MS data through such `Spectra` object, which can
## be created for `CompDb` objects using the `Spectra` method (see help
## of the `CompDb` object for more information. This examples shows how
## a `MsBackendCompDb` could be created purely from an SQLite database
## with data from a CompoundDb database.

## Connect to the SQLite database of a `CompDb` distributed via this package
library(RSQLite)
library(Spectra)
cdb <- CompDb(system.file("sql/CompDb.MassBank.sql", package = "CompoundDb"))

be <- backendInitialize(MsBackendCompDb(), cdb)
be

## Accessing m/z values
mz(be)

EuracBiomedicalResearch/CompoundDb documentation built on Dec. 18, 2024, 4:43 p.m.