plotMetric: Visualize a quality metric

Description Usage Arguments Details Value Author(s) Examples

View source: R/function_visualizations.R

Description

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

Usage

1
plotMetric(qc, metric = "areaUnderTic")

Arguments

qc

'matrix'/'data.frame'

metric

'character'

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

'plotly'

Author(s)

Thomas Naake, thomasnaake@googlemail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
library(msdata)
library(MsExperiment)
library(S4Vectors)
mse <- MsExperiment()
sd <- DataFrame(sample_id = c("QC1", "QC2"),
    sample_name = c("QC Pool", "QC Pool"), injection_idx = c(1, 3))
sampleData(mse) <- 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(mse) <- 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"
mse <- linkSampleData(mse, with = "experimentFiles.mzML_files",
    sampleIndex = c(1, 2), withIndex = c(1, 2))
mse <- linkSampleData(mse, with = "experimentFiles.annotations",
                      sampleIndex = c(1, 2), withIndex = c(1, 1))

library(Spectra)
## import the data and add it to the mse object
spectra(mse) <- 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 <- calculateMetricsFromMsExperiment(msexp = mse, metrics = metrics, 
    msLevel = 1, relativeTo = "Q1", change = "jump")
rownames(qc) <- c("Sample 1", "Sample 2")
plotMetric(qc, metric = "areaUnderTic") 

tnaake/MsQuality documentation built on Jan. 14, 2022, 7:34 p.m.