## ----setup, include=FALSE----------------------------------------------------- library(EcoNiche) ## ----input-data--------------------------------------------------------------- data("plant_otu") data("plant_env") data("plant_group") dim(plant_otu) dim(plant_env) table(plant_group)[1:5] ## ----filter-taxa-------------------------------------------------------------- otu_ex <- plant_otu[rowSums(plant_otu > 0) >= 15, ] dim(otu_ex) ## ----cca-workflow------------------------------------------------------------- cca_res <- cca_workflow_gradient( otu = otu_ex, env = plant_env, sel = c("AMP", "Moisture", "AP", "pH"), covariates = "AMT", var = "AMT", method = "loess", galaxy_colnum = FALSE, make_plot = FALSE, top_node = 20 ) names(cca_res) head(cca_res$step3$species) ## ----group-workflow----------------------------------------------------------- group_res <- cca_workflow_group( otu = otu_ex, env = plant_env, group = plant_group, sel = c("AMP", "Moisture", "AP", "pH"), covariates = "AMT", var = "AMT", choice = "all", method = "loess", plot_type = "sample", galaxy_colnum = FALSE, make_plot = FALSE ) names(group_res) head(group_res$step6$data) ## ----gam-workflow------------------------------------------------------------- otu_gam <- plant_otu[rowSums(plant_otu > 0) >= 20, ] gam_res <- gam_fit_model( otu = otu_gam, env = plant_env, env_var = "AMT", data_type = "count", count_family = "nb", use_offset = TRUE, min_prev = 0.10, min_total = 20, k_spline = 5, n_grid = 100, verbose = FALSE ) head(gam_res) ## ----levins-workflow---------------------------------------------------------- levins_res <- levins_calc_binned( otu = otu_ex, env = plant_env, axis_var = "AMT", nbin = 8, bin_method = "equal_freq", min_occ = 3, min_abund = 5 ) head(levins_res)