This is an alternative to plot_boxplot() using base R. This function
should work with most matrix or matrix-like objects (which is especially
useful for DelayedArray objects). The function also includes an
option for computing the relative-log-expression of the input data, given the
input data is on the log-scale.
Usage
plot_boxplot2(
  x,
  metadata = NULL,
  fill_by = NULL,
  rle = FALSE,
  hcl_palette = "Zissou",
  plot_title = NULL,
  x_label = NULL,
  y_label = NULL,
  show_outliers = TRUE,
  legend_position = "top",
  ...
)Arguments
- x
 feature x sample matrix or matrix-like object.
- metadata
 data.frame containing metadata per sample. rownames of metadata must match the colnames of the input matrix. Default NULL, each sample in the matrix will be plotted.
- fill_by
 metadata column used to color boxplots by the grouping variable. Default NULL, each sample in the matrix will be plotted
- rle
 should the relative-log-expression value be plotted. Requires input matrix to be on the log-scale. Default = FALSE
- hcl_palette
 color palette applied to 'fill_by' variable. One of the
hcl.pals(). Default "Zissou"- plot_title
 title of the plot. Default NULL
- x_label
 title of th x-axis. Default NULL
- y_label
 title of the y-axis. Default NULL
- show_outliers
 should boxplot outliers be shown. Default TRUE
- legend_position
 location keyword for the legend. One of "bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", "right" and "center". Default "topright"
- ...
 additional arguments passed to
bxp()
Examples
# Create metadata for plotting
metadata <- data.frame(row.names = colnames(GSE161650_lc))
metadata$Group <- rep(c("DMSO", "THZ1"), each = 3)
# Plot the boxplot by sample
plot_boxplot2(GSE161650_lc)
# Plot the boxplot by coloring each Group and transforming values
#  to relative-log-expression
plot_boxplot2(
  GSE161650_lc,
  metadata,
  fill_by = "Group",
  rle = TRUE,
  plot_title = "Relative log-expression",
  y_label = "RLE",
  show_outliers = FALSE
  )