Title: | Mass Spectrometry Data Backend for NIST msp Files |
---|---|
Description: | Mass spectrometry (MS) data backend supporting import and handling of MS/MS spectra from NIST MSP Format (msp) files. Import of data from files with different MSP *flavours* is supported. Objects from this package add support for MSP files to Bioconductor's Spectra package. This package is thus not supposed to be used without the Spectra package that provides a complete infrastructure for MS data handling. |
Authors: | Neumann Steffen [aut] , Johannes Rainer [aut, cre] , Michael Witting [ctb] |
Maintainer: | Johannes Rainer <[email protected]> |
License: | Artistic-2.0 |
Version: | 1.11.0 |
Built: | 2024-12-19 03:22:36 UTC |
Source: | https://github.com/bioc/MsBackendMsp |
The MsBackendMsp
class supports import of MS/MS spectra data from
files in NIST MSP file format. MsBackendMsp
extends the
MsBackendDataFrame()
backend directly and supports thus the
applyProcessing()
function to make data manipulations persistent.
New objects are created with the MsBackendMsp()
function. The
backendInitialize()
method has to be subsequently called to
initialize the object and import MS/MS data from (one or more) msp
files.
The MsBackendMsp
backend provides an export()
method that allows to
export the data from the Spectra
object (parameter x
) to a file in
MSP format.
Parameters to this function are:
x
: the Spectra
object that should be exported.
file
: character(1)
with the desired file name.
mapping
: named character
providing the mapping between spectra
variables and MSP data fields. Defaults to
mapping = spectraVariableMapping(MsBackendMsp())
.
allVariables
: logical(1)
whether all spectra variables in x
should be
exported or only those defined with mapping
.
exportName
: logical(1)
whether a NAME
field should always be exported
even if not provided in x
.
See the package vignette for details and examples.
The spectraVariableMapping()
function allows to provide the mapping between
spectra variable names (i.e. the names that will be used for the spectra
variables in the Spectra()
object) and the data field names of the
MSP file. Parameter format
allows to select pre-defined mappings. Currently
supported mapping flavors are:
format = "msp"
: default MSP field names. Should work with standard NIST
MSP files or MSP files exported from MS-DIAL.
format = "mona"
: MSP file format from MoNA including LipidBlast.
## S4 method for signature 'MsBackendMsp' backendInitialize( object, file, mapping = spectraVariableMapping(object), ..., BPPARAM = SerialParam() ) MsBackendMsp() ## S4 method for signature 'MsBackendMsp' spectraVariableMapping(object, format = c("msp", "mona")) ## S4 method for signature 'MsBackendMsp' export( object, x, file = tempfile(), mapping = spectraVariableMapping(MsBackendMsp()), allVariables = TRUE, exportName = TRUE, ... )
## S4 method for signature 'MsBackendMsp' backendInitialize( object, file, mapping = spectraVariableMapping(object), ..., BPPARAM = SerialParam() ) MsBackendMsp() ## S4 method for signature 'MsBackendMsp' spectraVariableMapping(object, format = c("msp", "mona")) ## S4 method for signature 'MsBackendMsp' export( object, x, file = tempfile(), mapping = spectraVariableMapping(MsBackendMsp()), allVariables = TRUE, exportName = TRUE, ... )
object |
Instance of |
file |
|
mapping |
named |
... |
Currently ignored. |
BPPARAM |
Parameter object defining the parallel processing
setup to import data in parallel. Defaults to |
format |
For |
x |
For |
allVariables |
|
exportName |
|
MsBackendMsp()
and backendInitialize()
return an instance of a
MsBackendMsp
class. spectraVariableMapping()
a named character
vector with the mapping between spectra variables and MSP data fields.
Format requirements/assumptions of MSP files:
Comment lines are expected to start with a #
.
Multiple spectra within the same MSP file are separated by an empty line.
The first n lines of a spectrum entry represent metadata.
Metadata is provided as "name: value" pairs (i.e. name and value separated by a ":").
One line per mass peak, with values separated by a whitespace or tabulator.
Each line is expected to contain at least the m/z and intensity values (in that order) of a peak. Additional values are currently ignored.
Steffen Neumann, Michael Witting, Laurent Gatto and Johannes Rainer
## Import spectra from a MSP file from LipidBlast f <- system.file("extdata", "small-export-LipidBlast.msp", package = "MsBackendMsp") be <- backendInitialize(MsBackendMsp(), f) be be$msLevel be$intensity be$mz ## precursor m/z are however all missing be$precursorMz ## Default spectra variable mapping spectraVariableMapping(MsBackendMsp()) ## In fact, to read MSP files in "LipidBlast flavour" (same as MoNA) we ## should use a different spectra variable mapping spectraVariableMapping(MsBackendMsp(), "mona") ## Importing the data with this will correctly retrieve data be <- backendInitialize(MsBackendMsp(), f, mapping = spectraVariableMapping(MsBackendMsp(), "mona")) be$precursorMz ## Other fields are also correctly mapped, but might need to be converted ## to e.g. numeric, such as "exactmass" be$exactmass be$exactmass <- as.numeric(be$exactmass) be$adduct be$formula ## Exporting Spectra objects in MSP format. sps <- Spectra(be) export(MsBackendMsp(), sps, file = stdout())
## Import spectra from a MSP file from LipidBlast f <- system.file("extdata", "small-export-LipidBlast.msp", package = "MsBackendMsp") be <- backendInitialize(MsBackendMsp(), f) be be$msLevel be$intensity be$mz ## precursor m/z are however all missing be$precursorMz ## Default spectra variable mapping spectraVariableMapping(MsBackendMsp()) ## In fact, to read MSP files in "LipidBlast flavour" (same as MoNA) we ## should use a different spectra variable mapping spectraVariableMapping(MsBackendMsp(), "mona") ## Importing the data with this will correctly retrieve data be <- backendInitialize(MsBackendMsp(), f, mapping = spectraVariableMapping(MsBackendMsp(), "mona")) be$precursorMz ## Other fields are also correctly mapped, but might need to be converted ## to e.g. numeric, such as "exactmass" be$exactmass be$exactmass <- as.numeric(be$exactmass) be$adduct be$formula ## Exporting Spectra objects in MSP format. sps <- Spectra(be) export(MsBackendMsp(), sps, file = stdout())
The readMsp()
function imports the data from a file in MGF format reading
all specified fields and returning the data as a DataFrame()
.
Format constraints for MSP files:
Comment lines are expected to start with a #
.
Multiple spectra within the same MSP file are separated by an empty line.
The first n lines of a spectrum entry represent metadata.
Metadata is provided as "name: value" pairs (i.e. name and value separated by a ":").
One line per mass peak, with values separated by a whitespace or tabulator.
Each line is expected to contain at least the m/z and intensity values (in that order) of a peak. Additional values are currently ignored.
readMsp( f, msLevel = 2L, mapping = spectraVariableMapping(MsBackendMsp()), BPPARAM = SerialParam(), ... )
readMsp( f, msLevel = 2L, mapping = spectraVariableMapping(MsBackendMsp()), BPPARAM = SerialParam(), ... )
f |
|
msLevel |
|
mapping |
named |
BPPARAM |
parallel processing setup. See |
... |
Additional parameters, currently ignored. |
A DataFrame
with each row containing the data from one spectrum
in the MSP file. m/z and intensity values are available in columns "mz"
and "intensity"
in a list representation.
Laurent Gatto, Steffen Neumann, Johannes Rainer
f <- system.file("extdata", "minimona.msp", package = "MsBackendMsp") readMsp(f)
f <- system.file("extdata", "minimona.msp", package = "MsBackendMsp") readMsp(f)