R/beta_div_plot.R
beta_div_plot.RdThis function computes beta diversity using several distance metrics and ordination methods (PCA, PCoA, NMDS). It requires an abundance table with taxonomy, metadata, and allows customization of color and shape aesthetics. It also supports compositional transformation via ALDEx2.
beta_div_plot(
table,
metadata,
distance = "compositional",
ordination = "PCA",
group_col = NULL,
group_colors = NULL,
shape_col = NULL,
legend_title = NULL,
arrows_size = 10,
top_n = 5
)A data frame with abundances. The last column must contain taxonomy information.
A data frame with sample metadata. The first column must contain the sample IDs.
Distance method: one of "euclidean", "bray", "jaccard", "sorensen", "compositional" (default), "aitchison", or "robust.aitchison".
Ordination method: one of "PCA" (default), "PCoA", or "NMDS".
Column in metadata to fill color points.
Optional named vector of colors.
Optional column in metadata to shape points.
Optional legend title.
Number of top contributing taxa to display as arrows in PCA.
A ggplot2 object.
beta_div_plot(table = table_taxa,
metadata = metadata1,
distance = "aitchison",
ordination = "NMDS",
group_col = "SITIO",
top_n = 5,
arrows = 100)
#> Loading required namespace: ggrepel
#> Error: object 'table_taxa' not found