View source: R/taxa_contribution_viz.R
| taxa_contribution_bar | R Documentation |
Creates a stacked bar plot showing taxa contributions to predicted functional abundances, faceted by function or sample group.
taxa_contribution_bar(
contrib_agg,
metadata,
group,
function_ids = NULL,
n_functions = 6,
facet_by = "function",
show_percentage = TRUE,
color_theme = "default",
font_size = 12,
legend_position = "right",
custom_title = NULL
)
contrib_agg |
A data.frame from |
metadata |
A data.frame containing sample metadata. |
group |
Character. Column name in |
function_ids |
Optional character vector of function IDs to plot.
If NULL (default), the top |
n_functions |
Integer. Number of functions to show when
|
facet_by |
Character. Facet by |
show_percentage |
Logical. Normalize bars to 100%? Default TRUE. |
color_theme |
Character. Color theme name, passed to
|
font_size |
Numeric. Base font size. Default 12. |
legend_position |
Character. Legend position. Default |
custom_title |
Optional character string for the plot title. |
A ggplot2 object.
# Synthetic example
agg <- data.frame(
sample = rep(c("S1", "S2", "S3", "S4"), each = 3),
function_id = rep(c("K00001", "K00002"), each = 6),
taxon_label = rep(c("Genus_A", "Genus_B", "Other"), 4),
contribution = runif(12)
)
metadata <- data.frame(
sample = c("S1", "S2", "S3", "S4"),
group = c("Control", "Control", "Treatment", "Treatment")
)
p <- taxa_contribution_bar(agg, metadata, group = "group")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.