qc_plot: Create QC plots

View source: R/qc_plot.R

qc_plotR Documentation

Create QC plots

Description

Create Shewhary Chart like QC plots for our metabolomics workflow.

Usage

qc_plot(data, x, y, color_by, avg, stdev, rsd, xlabel = "", ylabel = "")

Arguments

data

Dataframe containing all information. See details for more information on the structure.

x

what to plot on the x-axis, in general something with a time component in it.

y

what to plot on the y-axis, in general something like peak area or signal height.

color_by

color the lines and facet according to this column.

avg

the column with the average per compound.

stdev

the column with the standard deviation per compound.

rsd

the column with the RSD / CV per compound, this will be used in the title of the facets.

xlabel

set the label of the x-axis.

ylabel

set the label of the y-axis.

Details

data should be data frame which contains at least all the parameters as columns.

Value

A ggplot2 plot is returned.

Author(s)

Rico Derks

Examples

require(dplyr)
set.seed(11)
# create a dummy frame 
my_data <- data.frame(x = rep(1:8, 5),
                      y = rnorm(40, mean = 10),
                      group = as.factor(rep(1:5, 8)))
# calculate average / sd / rsd                       
my_data <- my_data %>%
  group_by(group) %>%
  mutate(avg = mean(y),
         stdev = sd(y),
         rsd = stdev / avg * 100)
# make the QC plot          
p <- qc_plot(data = my_data,
             x = x,
             y = y,
             color_by = group,
             avg = avg,
             stdev = stdev,
             rsd = rsd,
             xlabel = "Measurement index",
             ylabel = "peak area")

ricoderks/Rcpm documentation built on May 18, 2022, 7:49 a.m.