View source: R/function_visualizations.R
plotMetric | R Documentation |
The function plotMetric
visualizes the metric values per sample. The
function accepts the output of calculateMetrics
or,
calculateMetricsFromSpectra
, or
calculateMetricsFromMsExperiment
and a vector specifying the metric
to display.
plotMetric(qc, metric = "areaUnderTic", plotly = TRUE)
qc |
|
metric |
|
plotly |
|
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 chromatographyDuration
only the column chromatographyDuration
will
be selected), the name
column will include the metric
(chromatographyDuration
).
gg
plotly
Thomas Naake, thomasnaake@googlemail.com
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)
library(Spectra)
## import the data and add it to the msexp object
spectra(msexp) <- 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)
qc <- calculateMetricsFromMsExperiment(msexp = msexp, 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.