annotatedBar: Annotated Bar Plot

View source: R/annotatedBar.R

annotatedBarR Documentation

Annotated Bar Plot

Description

Standard bar-plot with heatmap-like x-axis annotations

Usage

annotatedBar(
  data_dt = NULL,
  plot_gg = NULL,
  x_v,
  stat_v = "count",
  position_v = "stack",
  fill_v = NULL,
  fillColors_v = NULL,
  title_v = NULL,
  annot_lsv = NULL,
  annotColors_lsv,
  testTime_v = F,
  backgroundCol_v = "white"
)

Arguments

data_dt

melted data table for plotting (see details. Must supply this or plot_gg)

plot_gg

ggplot to annotate (see details. Must supply this or data_dt)

x_v

name of x-axis variable (usually Sample_ID, Treatment, etc.). Must be column in data_dt

stat_v

argument to 'stat' parameter of geom_bar. Haven't played around with having this be anything but 'count'

position_v

argument to 'position' parameter of geom_bar. 'stack' (default) is counts; 'fill' turns to percentage by filling out of 1.

fill_v

name of fill variable. Must be column in data_dt

fillColors_v

optional named color vector. Values are colors, names are values of data_dt[[fill_v]]

title_v

optional plot title

annot_lsv

list of annotations to add below the plot. e.g. annot_lsv = list("outName1" = "colName1", "outName2" = "colName2")

annotColors_lsv

list of colors for annotations. list element names are same as annot_lsv names; list elements are named color vectors, names are values of annot_lsv colNames in data_dt

testTime_v

logical indicating whether to see how long it takes to plot

backgroundCol_v

sent to panel.background element of ggplot theme. Needs to be white for a specific use case where I want to plot a percentage using fill_v = "fill", but I only want a subset of the identities to be shown.

Details

make a standard ggplot bar plot with extra annotations. Can provide a pre-existing plot instead of data. If a plot is provided, the x_v variable is still required, along with annot_lsv and annotColors_lsv. Not required if plot is given: stat_v, position_v, fill_v, fillColors_v Note that data_dt overrules plot_gg. If both are provided, plot_gg is ignored

Value

list of gg objects output by ggarrange. Combo plot, data only, annotations only.


weshorton/wrh.rUtils documentation built on June 15, 2025, 1:10 a.m.