Generates a bar plot of relative abundance (%) for the most abundant taxa groups across samples or sample groups.
abundance_barplot(
table,
metadata,
taxonomy_db = "silva",
level = "genus",
x_col,
facet_col = NULL,
width_equal = FALSE,
label = "taxonomy",
top_n = 15,
x_axis_title = "Samples",
add_remained = FALSE,
save_table = TRUE,
table_filename = "relative_abundance.txt"
)A data frame with taxa in rows and samples in columns. The first column must be named taxonomy, containing full taxonomic strings.
A data frame containing sample metadata. Must include a SAMPLEID column matching sample names in table.
Character. Reference taxonomy database: "silva" (default). Affects how taxonomic names are simplified in the plot.
Character. Taxonomic level to collapse: "genus" (default) or "phylum".
Character. Column name in metadata to use for the x-axis (e.g., environment, condition).
Optional. Character. Column name in metadata to facet the plot by (e.g., treatment group). Default is NULL.
Character. Legend title for the taxa groups. Default is "taxonomy".
Integer. Number of most abundant taxa groups to display. Default is 15.
Character. The tittle that should be in the x-axis (deault = "Samples")
Logical indicating whether to include an "Other" category to sum remaining groups; default is FALSE.
A ggplot2 object showing a stacked barplot of relative abundances.
Relative abundances are calculated per sample (%).
Taxa names are collapsed to the specified taxonomic level ("genus" or "phylum").
Only the top top_n taxa are shown; others are filtered out.
Samples are grouped and ordered according to x_col.
Optional faceting by facet_col if provided.
Taxonomic strings matching "d__Bacteria;__;__;__;__;__" are automatically removed.
abundance_barplot( table = table_taxa,
metadata = metadata,
taxonomy_db = "silva",
level = "genus",
x_col = "MUESTRA",
label = "Genus",
facet_col = "SITIO",
width_equal = FALSE,
group_var = "SAMPLEID",
top_n = 30,
add_remained = TRUE)
#> Error in abundance_barplot(table = table_taxa, metadata = metadata, taxonomy_db = "silva", level = "genus", x_col = "MUESTRA", label = "Genus", facet_col = "SITIO", width_equal = FALSE, group_var = "SAMPLEID", top_n = 30, add_remained = TRUE): unused argument (group_var = "SAMPLEID")