knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This vignette demonstrates the capabilities of the BetaStability package using
the varespec and varechem datasets from the vegan package.
First, install the package from GitHub:
# Install from GitHub # install.packages("devtools") # devtools::install_github("gaoyu19920914/betaStability") # OR install from BioConductor (in the future when it's available) # if (!requireNamespace("BiocManager", quietly = TRUE)) # install.packages("BiocManager") # BiocManager::install("betaStability")
Load the BetaStability package and the vegan package for test data:
library(betaStability) library(vegan) library(ggplot2)
Load the varespec (community data) and varechem (environmental metadata)
datasets from the vegan package:
data(varespec) data(varechem) # Inspect the data head(varespec) head(varechem) # Dimensions of the datasets cat("Dimensions of varespec:", dim(varespec), "\n") cat("Dimensions of varechem:", dim(varechem), "\n")
Calculate stability using a single prediction method (linearPred):
# Calculate stability with linearPred result_linear <- betaStability( comtable = varespec, envmeta = varechem, method = "linearPred" ) # Inspect the result head(result_linear) length(result_linear)
Calculate stability using multiple prediction methods:
# Calculate stability with multiple methods results_multi <- betaStability( comtable = varespec, envmeta = varechem, method = c("linearPred", "mlPred", "glmPred") ) # Inspect the result head(results_multi) dim(results_multi)
Calculate stability using all available prediction methods:
# Calculate stability with all methods results_all <- betaStability( comtable = varespec, envmeta = varechem, method = "all" ) # Inspect the result head(results_all) dim(results_all) colnames(results_all)
Visualize the stability results using the plotStability function:
# Plot stability results for single method p1 <- plotStability(result_linear) p1
# Plot stability results for multiple methods p2 <- plotStability(results_multi) p2
# Plot stability results for all methods p3 <- plotStability(results_all) p3
You can also customize the site names in the plot:
# Create custom site names custom_sitenames <- paste("Site", seq_len(nrow(varespec))) # Plot with custom site names p4 <- plotStability(results_multi, sitenames = custom_sitenames) p4
The BetaStability package provides a comprehensive framework for calculating and visualizing site stability using various prediction methods. Key features include:
plotStability function creates informative
plots of stability results.This package is designed to help researchers and ecologists assess site stability based on the beta stability of communities, providing valuable insights for ecosystem management.
print(sessionInfo())
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.