save_batch_plots: Save batch correction plots

View source: R/batch_correction.R

save_batch_plotsR Documentation

Save batch correction plots

Description

Saves plots of each feature showing the effect of batch correction. Plots show QC samples and regular samples inside each batch, plus the batch mean for biological samples and QC samples as a horizontal line. The dashed line represents QC mean, the filled line represents biological sample mean. NOTE: if you change the shape variable, be sure to set a shape scale as well, the default scale only has 2 values, so it can only accomodate 2 shapes.

Usage

save_batch_plots(
  orig,
  corrected,
  file,
  width = 14,
  height = 10,
  batch = "Batch",
  color = "Batch",
  shape = "QC",
  color_scale = getOption("notame.color_scale_dis"),
  shape_scale = scale_shape_manual(values = c(15, 21))
)

Arguments

orig, corrected

MetaboSet objects before and after batch effect correction

file

path to the PDF file where the plots will be saved

width, height

width and height of the plots in inches

batch, color, shape

column names of pData for batch labels, and column used for coloring and shaping points (by default batch and QC)

color_scale, shape_scale

scales for color and scale as returned by ggplot functions.

Examples

## Not run: 
# Batch correction
batch_corrected <- normalize_batches(merged_sample, batch = "Batch", group = "QC", ref_label = "QC")
# Plots of each features
save_batch_plots(
  orig = merged_sample, corrected = batch_corrected,
  file = "batch_plots.pdf"
)

## End(Not run)

antonvsdata/notame documentation built on Sept. 14, 2024, 11:09 p.m.