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,
  x_v,
  stat_v = "count",
  position_v = "stack",
  fill_v,
  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

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

Value

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


weshorton/wrh.rUtils documentation built on Feb. 6, 2025, 5:30 a.m.