Plot a stacked area chart of microbial relative abundance
Source:R/plot_stacked_area.R
plot_stacked_area.RdThis function takes a MultiAssayExperiment object and returns a
stacked area chart of microbe relative abundances. The function takes a single
covariate as an optional variable by which to create a grid of multiple
plots.
Usage
plot_stacked_area(
dat,
taxon_level,
covariate_1 = NULL,
covariate_time,
palette_input = NULL,
title = paste("Relative abundance at", taxon_level, "level"),
subtitle = NULL
)Arguments
- dat
A
MultiAssayExperimentobject 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 isNULLand 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_area(in_dat, taxon_level = "phylum", covariate_1 = "Group",
covariate_time = "Month",
palette_input = rainbow(25))