measureSample {rtms}R Documentation

Measure peaks in an RTMS sample

Description

measureSample() extracts one or more measurements for every peak in an RTMS sample object (of class rtmsSample).

Usage

measureSample(sample, measure = "PeakIntensity")

Arguments

sample

An object of class rtmsSample

measure

A character vector of named measurements, or a list of custom measurement functions. Supported measurement names are "PeakIntensity", which takes the total of any local maxima within the peak width, "PeakArea", which takes the area under the intensity curve within the peak width, and "NumPeaks", which counts the local maxima in the peak window. If measure is a list of functions, each function must take an object of class rtmsSubsample, and return a single numeric value. If the functions are named, those names will be returned in the "measure" column of the resulting data frame; otherwise they will be identified as "Measure1", "Measure2", etc.

Value

A data frame with one row for each peak and measurement in the sample. The data.frame will have a column named "peakName" with the name of the relevant peak (if the "peaks" attribute of sample is a named list); a column named "peakValue" containing the m/z value at the center of the relevant peak; a column named "measure" containing the name of the relevant measure; and a column named "value" containing the numeric value of the particular measure for that peak.

Examples

peaks <- rtmsPeakList(c(1516.83,1530.84),peakWidth=0.2,windowWidth = c(5,10))
names(peaks) <- c("Product","Substrate")
sample <- getSample(exampleSpectrum,peaks)

measure <- measureSample(sample,c("PeakArea","PeakIntensity"))

myFunctions <- list(PeakRawIntensity = function(s) max(s$peakPiece$intensity))
myMeasures <- measureSample(sample,myFunctions)

[Package rtms version 0.2.0 Index]