我开始使用adonis函数通过组合级别创建PERMANOVA对比的脚本,但似乎没有使用级别矩阵与创建的adonis对象的组合,我的代码是:
require(vegan)
require(doBy)
require(wzRfun)
require(multcomp)
data(mite)
A = c(rep(c(0), 30), rep(c(1), 30))
B = rep(c(rep(c(0), 15), rep(c(1), 15)), 2)
A <- as.factor(A)
B <- as.factor(B)
species <- mite[1:60,]
man.com<-adonis(species ~ A * B, method = "jaccard",permutations=999)
man.com
A_B<- interaction(A, B)
levels(A_B)
do.call(rbind, strsplit(levels(A_B), "\\."))
g0 <- adonis(species ~ A * B, method = "jaccard",permutations=999)
g1 <- adonis(species ~ A_B, method = "jaccard",permutations=999)
M <- LSmatrix(g0, effect=c("A","B"))
data.frame(g0=M%*%coef(g0), g1=coef(g1))
str(M)
grid <- attr(M, "grid")
B <- "b"
A <- "a"
spl <- interaction(grid[,2])
i <- 1:nrow(grid)
l <- split(i, f=spl)
contr <- lapply(l,
function(row){
## Contrast matrix parwise
a <- apc(M[row,], lev=levels(d[,2]))
rownames(a) <- paste(spl[row[1]],
rownames(a), sep="/")
return(a)
})
contr <- do.call(rbind, contr)
contr
summary(glht(g0, linfct=contr),
test=adjusted(type="fdr"))
请有人帮助我,
提前致谢,