library(vegan)
## 载入需要的程辑包:permute
## 载入需要的程辑包:lattice
## This is vegan 2.5-7
data(varespec)
data(varechem)
tax.dist <- vegdist(varespec, method = "bray") # Bray-Curtis
# spec
ph.dist <- vegdist(scale(varechem$pH), method = "euclid")
mantel(tax.dist, ph.dist, method="spear", permutations = 1000)
##
## Mantel statistic based on Spearman's rank correlation rho
##
## Call:
## mantel(xdis = tax.dist, ydis = ph.dist, method = "spear", permutations = 1000)
##
## Mantel statistic r: 0.06857
## Significance: 0.20979
##
## Upper quantiles of permutations (null model):
## 90% 95% 97.5% 99%
## 0.114 0.147 0.173 0.208
## Permutation: free
## Number of permutations: 1000
#spec vs all
env.dist <- vegdist(scale(varechem), method = "euclid") # Euclidean Distance
mantel(tax.dist, env.dist, method="spear", permutations = 1000)
##
## Mantel statistic based on Spearman's rank correlation rho
##
## Call:
## mantel(xdis = tax.dist, ydis = env.dist, method = "spear", permutations = 1000)
##
## Mantel statistic r: 0.2838
## Significance: 0.002997
##
## Upper quantiles of permutations (null model):
## 90% 95% 97.5% 99%
## 0.121 0.158 0.176 0.211
## Permutation: free
## Number of permutations: 1000
#
#ref https://zouhua.top/archives/d4c96916.html