adonis文檔:
https://www.rdocumentation.org/packages/vegan/versions/2.4-2/topics/adonis
vegdist文檔:
https://www.rdocumentation.org/packages/vegan/versions/2.4-2/topics/vegdist
依賴包
library("vegan")
1 輸入數(shù)據(jù)
多樣本變量矩陣
data=data.frame(matrix(rnorm(100, 100, 10), 10, 10))
rownames(data)=paste("sample", 1:10, sep="_")
colnames(data)=paste("var", 1:10, sep="_")
表型數(shù)據(jù)
env = data.frame(sample = paste("sample", 1:10, sep="_"),
group = c(rep("A", 5), rep("B", 5)))
2 permannova:表型與矩陣的關(guān)聯(lián)
adonis(data ~ group, # 矩陣 ~ 表型變量
data = env, # 表型表格
distance = "bray", # 距離算法
permutations = 999) # 排列次數(shù)
3 提取p值
# 循環(huán)所有算法
algo = c("manhattan", "euclidean", "canberra", "bray", "kulczynski", "jaccard", "gower", "altGower", "morisita", "horn", "mountford", "raup", "binomial", "chao", "cao", "mahalanobis")
p=c()
for(title in algo)
{
res = adonis(data ~ group, data = env,
distance = title, permutations = 999)
# 提取P value并保存
p = c(p, res$aov.tab$Pr[1])
print(title)
}
perm = data.frame(algo, p)