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

View source: R/utility-functions.R

expandMzIntensityR Documentation

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

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

expandMzIntensity(x)

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


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

rformassspectrometry/CompoundDb documentation built on Dec. 20, 2024, 10:46 a.m.