plotMetric: Visualize a quality metric

View source: R/function_visualizations.R

plotMetricR Documentation

Visualize a quality metric

Description

The function 'plotMetric' visualizes the metric values per sample. The function accepts the output of 'calculateMetrics' or, 'calculateMetricsFromSpectra' and a vector specifying the metric to display.

Usage

plotMetric(qc, metric = "areaUnderTic", plotly = TRUE)

Arguments

qc

'matrix'/'data.frame'

metric

'character'

plotly

logical(1)

Details

'plotMetric' will select all columns that start with 'metric'. The different levels in the 'name' column in the returned tibble correspond to the columns that were selected and do not contain the 'metric' prefix. In case there is no additional specification (e.g. for the metric 'rtDuration' only the column 'rtDuration' will be selected), the 'name' column will include the 'metric' ('rtDuration').

Value

'gg' 'plotly'

Author(s)

Thomas Naake, thomasnaake@googlemail.com

Examples

library(msdata)

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

library(Spectra)
## import the data
sps <- 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)
qc <- calculateMetricsFromSpectra(spectra = sps, metrics = metrics, 
    msLevel = 1, relativeTo = "Q1", change = "jump")
rownames(qc) <- c("Sample 1", "Sample 2")

## do the actual plotting
plotMetric(qc, metric = "areaUnderTic", plotly = TRUE)

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