Plot a stacked bar chart of microbial relative abundance
Source:R/plot_stacked_bar.R
plot_stacked_bar.Rd
This function takes a MultiAssayExperiment
object and returns a
stacked bar plot of microbe relative abundances. The function takes a single
covariate as an optional variable by which to create multiple gridded plots.
Usage
plot_stacked_bar(
dat,
taxon_level,
covariate_1 = NULL,
covariate_time,
palette_input = NULL,
title = paste("Relative abundance at", taxon_level, "level"),
subtitle = NULL
)
Arguments
- dat
A
MultiAssayExperiment
object specially formatted as an animalcules output.- taxon_level
Character string indicating the level of taxonomy to aggregate the counts data. Must be the name of a column in
MultiAssayExperiment::rowData(dat)
.- covariate_1
Character string giving the name of a column in
MultiAssayExperiment::colData(dat)
on which to create multiple plots. The default isNULL
.- covariate_time
Character string giving the name of the discrete time-based covariate in the metadata to group abundances by.
- palette_input
A character vector of colors that is at minimum the same length of the number of taxa (specified with
taxon_level
). The default isNULL
and relies onggplot2
's default scheme.- title
A character string providing the plot title.
- subtitle
A character string providing the plot subtitle. The default is
NULL
.
Details
If further manipulation of specific parameters is desired, users can add
ggplot2
function calls to the output of the function.
Examples
in_dat <- system.file("extdata/MAE_small.RDS", package = "LegATo") |> readRDS()
plot_stacked_bar(in_dat, taxon_level = "family", covariate_1 = "Group",
covariate_time = "Month",
palette_input = rainbow(25))