Performs Canonical Correspondence Analysis (CCA) or Redundancy Analysis (RDA) based on a species abundance table and selected environmental variables, returning a biplot with ggplot2 that visualizes sample scores and environmental vectors.
cca_rda_biplot(
table,
env_data,
env_vars,
method = "hell",
metadata = NULL,
group_col = NULL,
group_colors = NULL,
legend_title = NULL,
scale_env = TRUE,
pval_threshold = 0.05,
show_all_env_vectors = FALSE,
analysis = "CCA",
seed = 126,
scale_arrows = 1,
title = NULL
)A data frame or matrix of species abundances (samples as rows, species as columns).
A data frame of environmental variables (rows must match table).
A character vector with the names of environmental variables to include in the analysis.
Transformation method passed to decostand (default is "hell" for Hellinger).
Optional data frame with sample metadata for grouping in the plot.
Optional name of the column in metadata used to define sample groups.
Optional named vector of colors to use for each group.
Optional custom title for the group legend.
Logical; whether to scale environmental variables (default is TRUE).
P-value threshold for selecting significant environmental variables (default is 0.05).
Logical; if TRUE, plot all environmental vectors regardless of significance.
Either "CCA" or "RDA" (default is "CCA").
Random seed for reproducibility (default is 126).
Numeric value to scale environmental vectors in the plot.
Optional plot title.
A ggplot object displaying the biplot with sample scores and environmental vectors.
cca_rda_biplot(table = table,
env_data = env_data,
env_vars = c("pH", "Nitrogen", "Calcium"),
metadata = metadata ,
group_col = "metodo",
analysis = "RDA",
show_all_env_vectors = TRUE,
legend_title = "Método",
group_colors = c("red", "blue"),
title = "title")
#> Loading required package: ggplot2
#> Warning: package 'ggplot2' was built under R version 4.4.3
#> Loading required package: dplyr
#> Warning: package 'dplyr' was built under R version 4.4.3
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
#> Error in cca_rda_biplot(table = table, env_data = env_data, env_vars = c("pH", "Nitrogen", "Calcium"), metadata = metadata, group_col = "metodo", analysis = "RDA", show_all_env_vectors = TRUE, legend_title = "Método", group_colors = c("red", "blue"), title = "title"): There is no taxonomy column in the table