This function computes the standard effect size of PD by correcting for changes in species richness. The novelty of this function is its ability to utilize sparse community matrix making it possible to efficiently randomize very large community matrices spanning thousands of taxa and sites.
PD_ses(
x,
phy,
model = c("tipshuffle", "rowwise", "colwise"),
reps = 10,
metric = "pd",
...
)
a (sparse) community matrix, i.e. an object of class matrix or Matrix.
a phylogenetic tree (object of class phylo).
The null model for separating patterns from processes and for contrasting against alternative hypotheses. Available null models include:
“tipshuffle”: shuffles tip labels multiple times.
“rowwise”: shuffles sites (i.e., varying richness) and keeping species occurrence frequency constant.
“colwise”: shuffles species occurrence frequency and keeping site richness constant.
Number of replications.
The phylodiversity measure to compute.
Further arguments passed to or from other methods.
A data frame of results for each community or grid cell
grids: Site identity
richness: Number of taxa in community
pd_obs: Observed PD in community
pd_rand.mean: Mean PD in null communities
pd_rand.sd: Standard deviation of PD in null communities
pd_obs.rank: Rank of observed PD vs. null communities
pd_obs.z: Standardized effect size of PD vs. null communities \(= (pd_obs - pd_rand.mean) / pd_rand_sd\)
pvalue: P-value (quantile) of observed PD vs. null communities \(= mpd_obs_rank / iter + 1\)
reps: Number of replicates
p_obs_c_lower: Number of times observed value < random value
p_obs_c_upper: Number of times observed value > random value
p_obs_p_lower: Percentage of times observed value < random value
p_obs_p_upper: Percentage of times observed value > random value
p_obs_q: Number of the non-NA random values used for comparison
Proches, S., Wilson, J.R.U. & Cowling, R.M. (2006) How much evolutionary history in a 10 x 10m plot? Proceedings of Royal Society B 273: 1143-1148.
library(ape)
library(Matrix)
tree <- read.tree(text ="((t1:1,t2:1)N2:1,(t3:1,t4:1)N3:1)N1;")
com <- sparseMatrix(c(1,3,4,1,4,5,1,2,3,4,5,6,3,4,6),
c(1,1,1,2,2,2,3,3,3,3,3,3,4,4,4),x=1,
dimnames = list(paste0("g", 1:6), tree$tip.label))
PD_ses(com, tree, model="rowwise")
#> ID pd_obs pd_rand.mean pd_rand.sd pd_obs.z pd_obs.rank pd_obs_c_upper
#> g1 g1 5 4.4 1.5055453 0.4889949 6.5 3
#> g2 g2 2 3.8 1.2292726 -1.6234855 2.0 0
#> g3 g3 5 4.1 0.7378648 1.0477414 9.5 7
#> g4 g4 6 3.7 1.6363917 1.7979773 10.5 9
#> g5 g5 4 4.4 1.3498971 -0.3442783 4.5 3
#> g6 g6 3 4.6 1.5776213 -1.2738509 3.0 1
#> pd_obs_c_lower pd_obs_q pd_obs_pvalue_upper pd_obs_pvalue_lower pd_pvalue
#> g1 2 10 0.3 0.2 0.5909091
#> g2 8 10 0.0 0.8 0.1818182
#> g3 0 10 0.7 0.0 0.8636364
#> g4 0 10 0.9 0.0 0.9545455
#> g5 6 10 0.3 0.6 0.4090909
#> g6 7 10 0.1 0.7 0.2727273
#> signif
#> g1 c_not significant
#> g2 c_not significant
#> g3 c_not significant
#> g4 c_not significant
#> g5 c_not significant
#> g6 c_not significant