View source: R/functions-MSpectra.R
extractSpectraData | R Documentation |
The Spectra package provides a more robust and efficient infrastructure for mass spectrometry data handling and analysis. So, wherever possible, the newer Spectra package should be used instead of the MSnbase. The functions listed here allow to convert between objects from the MSnbase and Spectra packages.
extractSpectraData
extracts the spectra data (m/z and intensity values
including metadata) from MSnExp, OnDiskMSnExp,
Spectrum1, Spectrum2 objects (or list
of such objects) and
returns these as a DataFrame
that can be used to create a
Spectra::Spectra object.This function enables thus
to convert data from the old MSnbase
package to the newer Spectra
package.
To convert a Spectra
object to a MSpectra
object use
as(sps, "MSpectra")
where sps
is a Spectra
object.
extractSpectraData(x)
x |
a |
extracSpectraData()
returns a DataFrame()
with the full spectrum data
that can be passed to the Spectra::Spectra()
function to create a
Spectra
object.
as(x, "MSpectra")
returns a MSpectra
object with the content of the
Spectra
object x
.
Coercion from Spectra
to a MSpectra
will only assign values to the
contained Spectrum1
and Spectrum2
objects, but will not add all
eventually spectra variables present in Spectra
.
Johannes Rainer
## Read an mzML file with MSnbase
fl <- system.file("TripleTOF-SWATH", "PestMix1_SWATH.mzML",
package = "msdata")
data <- filterRt(readMSData(fl, mode = "onDisk"), rt = c(1, 6))
## Extract the data as a DataFrame
res <- extractSpectraData(data)
res
library(Spectra)
## This can be used as an input for the Spectra constructor of the
## Spectra package:
sps <- Spectra::Spectra(res)
sps
## A Spectra object can be coerced to a MSnbase MSpectra object using
msps <- as(sps, "MSpectra")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.