extractSpectraData {MSnbase} | R Documentation

## Extract data from MSnbase objects for use in Spectra

### Description

`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.

### Usage

    extractSpectraData(x)

### Arguments

`x` | a `list` of Spectrum objects or an object extending MSnExp or a MSpectra object.

### Value

`DataFrame()` with the full spectrum data that can be passed to the `Spectra::Spectra()` function to create a `Spectra` object.

### Author(s)

Johannes Rainer

### Examples

    ## 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

    ## This can be used as an input for the Spectra constructor of the
    ## Spectra package:
    ## sps <- Spectra::Spectra(res)
    ## sps

[Package MSnbase version 2.20.1 Index]