calculateMetricsFromMsExperiment: Calculate QC metrics from a MsExperiment object

View source: R/function_calculateMetrics_from_Spectra.R

calculateMetricsFromMsExperimentR Documentation

Calculate QC metrics from a MsExperiment object

Description

The function calculateMetricsFromMsExperiment calculates quality metrics from a MsExperiment object. Each spectra in the msexp object should refer to one mzML file/to one sample.

Usage

calculateMetricsFromMsExperiment(
  msexp,
  metrics = qualityMetrics(msexp),
  ...,
  BPPARAM = bpparam()
)

Arguments

msexp

MsExperiment object

metrics

character specifying the quality metrics to be calculated on msexp

...

arguments passed to the quality metrics functions defined in metrics

BPPARAM

Parallel processing setup. Defaults to 'BPPARAM = bpparam()'. See [bpparam()] for details on parallel processing with 'BiocParallel'.

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(MsExperiment)
library(S4Vectors)

msexp <- MsExperiment()
sd <- DataFrame(sample_id = c("QC1", "QC2"),
    sample_name = c("QC Pool", "QC Pool"), injection_idx = c(1, 3))
sampleData(msexp) <- sd

## define file names containing spectra data for the samples and
## add them, along with other arbitrary files to the experiment
fls <- dir(system.file("sciex", package = "msdata"), full.names = TRUE)
experimentFiles(msexp) <- MsExperimentFiles(
    mzML_files = fls,
    annotations = "internal_standards.txt")
## link samples to data files: first sample to first file in "mzML_files",
## second sample to second file in "mzML_files"
msexp <- linkSampleData(msexp, with = "experimentFiles.mzML_files",
    sampleIndex = c(1, 2), withIndex = c(1, 2))
msexp <- linkSampleData(msexp, with = "experimentFiles.annotations",
     sampleIndex = c(1, 2), withIndex = c(1, 1))

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

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

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

tnaake/MsQuality documentation built on April 27, 2023, 9:06 p.m.