calculateMetricsFromOneSampleSpectra: Calculate QC metrics from a Spectra object containing only...

View source: R/function_calculateMetrics_from_Spectra.R

calculateMetricsFromOneSampleSpectraR Documentation

Calculate QC metrics from a Spectra object containing only spectral data from one sample

Description

The function calculateMetricsFromOneSampleSpectra calculates quality metrics from a Spectra containing spectral data from one sample.

Usage

calculateMetricsFromOneSampleSpectra(
  spectra,
  metrics = qualityMetrics(spectra),
  filterEmptySpectra = FALSE,
  f = spectra$dataOrigin,
  ...
)

Arguments

spectra

Spectra object

metrics

character specifying the quality metrics to be calculated on spectra

filterEmptySpectra

logical(1) specifying if empty entries and entries with intensity zero or Inf of the Spectra object will be removed

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.

The Spectra object will only contain spectral data from one data origin (e.g. spectra$dataOrigin is of length 1). The grouping is specified by the argument f.

Setting the argument filterEmptySpectra to TRUE will remove zero-length entries, zero-intensity entries, and entries with intensities that are Inf from the Spectra object.

Value

named numeric vector

Author(s)

Thomas Naake

Examples

library(msdata)
library(Spectra)
fls <- dir(system.file("sciex", package = "msdata"), full.names = TRUE)[1]
spectra <- Spectra(fls, backend = MsBackendMzR())

## define the quality metrics to be calculated
metrics <- c("areaUnderTic", "chromatographyDuration", "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 ...
MsQuality:::calculateMetricsFromOneSampleSpectra(spectra = spectra, 
    metrics = metrics, msLevel = 1, change = "jump", relativeTo = "Q1")
MsQuality:::calculateMetricsFromOneSampleSpectra(spectra = spectra, 
    metrics = metrics, msLevel = 1, change = "fall", relativeTo = "previous")

tnaake/msQC documentation built on Feb. 25, 2024, 7:33 p.m.