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 输入数据
多样本变量矩阵
data=data.frame(matrix(rnorm(100, 100, 10), 10, 10))
rownames(data)=paste("sample", 1:10, sep="_")
colnames(data)=paste("var", 1:10, sep="_")
表型数据
env = data.frame(sample = paste("sample", 1:10, sep="_"),
group = c(rep("A", 5), rep("B", 5)))
2 permannova:表型与矩阵的关联
adonis(data ~ group, # 矩阵 ~ 表型变量
data = env, # 表型表格
distance = "bray", # 距离算法
permutations = 999) # 排列次数
3 提取p值
# 循环所有算法
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)
网友评论