batchBoxplot: Boxplot for Batch Effects

View source: R/batchBoxplot.R

batchBoxplotR Documentation

Boxplot for Batch Effects

Description

batchBoxplot function will plot residuals of linear mixed effects model for a single feature by batch to visualize additive and multiplicative batch effects. Data should be in "long" format. Depends on lme4 package.

Usage

batchBoxplot(
  idvar,
  batchvar,
  feature,
  formula,
  ranef,
  data,
  adjustBatch = FALSE,
  orderby = "mean",
  plotMeans = TRUE,
  colors = "grey",
  xlabel = "batch",
  ylabel = "residuals",
  title = "",
  verbose = TRUE,
  ...
)

Arguments

idvar

character string that specifies name of ID variable. ID variable can be factor, numeric, or character.

batchvar

character string that specifies name of the batch variable. Batch variable should be a factor.

feature

character string that specifies name of the numeric feature variable, or the numeric index of the corresponding column.

formula

character string representing all fixed effects on the right side of the formula for the linear mixed effects model. This should be in the notation used by lme4 and include covariates, time, and any interactions. For example, "age + sex + diagnosis*time" fits model with fixed effects age, sex, diagnosis, time, and the diagnosis*time interaction. Formula should NOT include batchvar and should NOT include random effects.

ranef

character string representing formula for the random effects in the notation used by lme4. For example, "(1|subid)" fits a random intercept for each unique idvar subid, and "(1 + time|subid)" fits a random intercept and random slope for each unique subid.

data

name of the data frame that contains the variables above. Rows are different observations (subject/timepoints), columns are different variables.

adjustBatch

should residuals be adjusted for the fixed effect of batch? Logical TRUE or FALSE. Use FALSE to illustrate additive (and multiplicative) batch effects. Use TRUE to illustrate only multiplicative batch effects. Default is FALSE.

orderby

'mean' orders boxplots by increasing mean; best for illustrating additive batch effects (use with adjustBatch=FALSE). 'var' orders boxplots by increasing variance; best for illustrating multiplicative batch effects. Default is 'mean'.

plotMeans

should batch means be plotted on top of the boxplots? Logical TRUE or FALSE. Default is TRUE.

colors

vector of colors the same length and order as levels(as.factor(data[,batchvar])) that determines the colors of the boxplots (character string of color names or hexadecimal codes). Default is "grey" for all.

xlabel

x-axis label (character string). Default is 'batch'.

ylabel

y-axis label (character string). Default is 'residuals'.

title

main title for the plot, default is no title (character string).

verbose

prints messages. Logical TRUE or FALSE. Default is TRUE.

...

other graphical parameter arguments passed to par.

Value

Creates a boxplot.


jcbeer/longCombat documentation built on June 26, 2022, 6:47 p.m.