calculateMetricsFromSpectra: Calculate QC metrics from a Spectra object

View source: R/function_calculateMetrics_from_Spectra.R

calculateMetricsFromSpectraR Documentation

Calculate QC metrics from a Spectra object

Description

The function calculateMetricsFromSpectra calculates quality metrics from a Spectra object. The function will calculate the metrics per sample according to the grouping parameter f, e.g. dataOrigin information.

Usage

calculateMetricsFromSpectra(
  spectra,
  metrics = qualityMetrics(spectra),
  f = spectra$dataOrigin,
  ...
)

Arguments

spectra

Spectra object

metrics

character specifying the quality metrics to be calculated on spectra

f

character, grouping parameter for spectra

...

arguments passed to the quality metrics functions defined in metrics

Details

The metrics are defined by the argument metrics. Further arguments passed to the quality metric functions can be specified by the params argument. params can contain named entries which are matched against the formal arguments of the quality metric functions.

Value

data.frame containing in the columns the metrics for the different spectra (in rows)

Author(s)

Thomas Naake, thomasnaake@googlemail.com

Examples

library(msdata)
library(Spectra)

## define file names containing spectra data for the samples
fls <- dir(system.file("sciex", package = "msdata"), full.names = TRUE)

## import the data and add it to the spectra object
spectra <- Spectra(fls, backend = MsBackendMzR())

## define the quality metrics to be calculated
metrics <- c("areaUnderTic", "rtDuration", "msSignal10xChange")

## calculate the metrics
## additional parameters passed to the quality metrics functions
## (msLevel is an argument of areaUnderTic and msSignal10xChange,
## relativeTo is an argument of msSignal10xChange) passed to ...
calculateMetricsFromSpectra(spectra = spectra, metrics = metrics, 
    msLevel = 1, change = "jump", relativeTo = "Q1")
calculateMetricsFromSpectra(spectra = spectra, metrics = metrics, 
    msLevel = 1, change = "fall", relativeTo = "previous")

tnaake/MsQuality documentation built on Dec. 1, 2022, 10:01 p.m.