Learn R Programming

PNC (version 0.1.0)

compnc_robustness: Test Robustness of Phylogenetic Niche Conservatism Analysis Across Multiple Communities

Description

This function evaluates the robustness of phylogenetic signal estimates across multiple communities by simulating trait data with the same phylogenetic signal strength as observed, applying the original missing data pattern, and testing how consistently the statistical significance is recovered across multiple simulations for each community.

Usage

compnc_robustness(
  com,
  trait_data,
  phylo_tree,
  methods = "lambda",
  pca_axes = c("PC1", "PC2"),
  sig_levels = c(0.001, 0.01, 0.05),
  min_abundance = 0,
  n_simulations = 100,
  alpha_level = 0.05,
  tolerance = 0.05,
  verbose = TRUE
)

Value

A data frame containing the original phylogenetic signal results with additional columns:

  • robustness: Percentage of simulations that maintain the same statistical significance conclusion as the original analysis

  • signal_sd: Standard deviation of phylogenetic signal values across successful simulations

Arguments

com

A community matrix with sites as rows and species as columns

trait_data

A data frame or matrix containing trait data with species as rows

phylo_tree

A phylogenetic tree object of class "phylo"

methods

Character string specifying method to use. Options: "lambda" or "K". Default is "lambda"

pca_axes

Character vector specifying which PCA axes to include (e.g., c("PC1", "PC2")). Default is c("PC1", "PC2")

sig_levels

Numeric vector of significance levels for marking results

min_abundance

Minimum abundance threshold for including species

n_simulations

Integer. Number of simulations to run for robustness testing. Default is 100

alpha_level

Numeric. Significance level for statistical testing. Default is 0.05

tolerance

Numeric. Acceptable difference between target and estimated signal values during trait simulation. Default is 0.05

verbose

Logical indicating whether to show progress and warnings

Examples

Run this code
# \donttest{
# Load example data
data("HimalayanBirds")
str(HimalayanBirds)
data("AVONET")
head(AVONET)

# species level
sp <- colnames(HimalayanBirds$com)
sp
subtraits <- extract_traits(sp, AVONET, rank = "species")
head(subtraits)
coverage(subtraits)
pnc(subtraits, HimalayanBirds$phy_species, methods = "lambda", pca_axes = c("PC1", "PC2"))

compnc(com = HimalayanBirds$com, subtraits, HimalayanBirds$phy_species,
       methods = "lambda", pca_axes = NULL)

# Test robustness of phylogenetic signal analysis
# This function's runtime is long
compnc_robustness(HimalayanBirds$com,
                  subtraits,
                  HimalayanBirds$phy_species,
                  methods = "lambda",
                  pca_axes = NULL,
                  n_simulations = 5)
# }

Run the code above in your browser using DataLab