expandMzIntensity: Expand m/z and intensity values in a data.frame

Description Usage Arguments Value Author(s) Examples

View source: R/utility-functions.R

Description

expandMzIntensity expands a data.frame with m/z and/or intensity values stored as a list in columns "mz" and "intensity". The resulting data.frame has the m/z and intensity values stored as numeric in columns "mz" and "intensity", one value per row, with the content of other columns repeated as many times as there are m/z and intensity values.

Usage

1

Arguments

x

data.frame with collapsed m/z and intensity values in columns "mz" and "intensity", such as returned by msms_spectra_hmdb() with parameter collapsed = TRUE, or by spectra() or compounds() calls.

Value

data.frame with "mz" and "intensity" columns expanded. See description for details.

Author(s)

Johannes Rainer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Read a data.frame with collapsed columns mz and intensity columns
dr <- system.file("xml/", package = "CompoundDb")
msms_spctra <- msms_spectra_hmdb(dr)

msms_spctra

## Columns mz and intensity are "collased"
msms_spctra$mz

## Expand the data.frame to get one row per m/z and intensity value
spctra_exp <- expandMzIntensity(msms_spctra)
spctra_exp

michaelwitting/CompoundDb documentation built on April 29, 2020, 8:42 p.m.