[R-sig-eco] PERMANOVA contrasts by combination of levels
ASANTOS
alexandresantosbr at yahoo.com.br
Thu Feb 11 15:00:40 CET 2016
Dear Members,
I started to creat a script for a PERMANOVA contrasts by combination of
levels using adonis function, but doesn't seem to be working a
combination of levels matrix with adonis object created, my code was:
#Packages
require(vegan)
require(doBy)
require(wzRfun)
require(multcomp)
#Data set
data(mite)
A = c(rep(c(0), 30), rep(c(1), 30))
B = rep(c(rep(c(0), 15), rep(c(1), 15)), 2)
#Create data frame
A <- as.factor(A)
B <- as.factor(B)
species <- mite[1:60,]
#PERMANOVA with Jaccard index
man.com<-adonis(species ~ A * B, method = "jaccard",permutations=999)
man.com
#Two-Way PERMANOVA Contrasts
#Interaction
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"))
#Mean estimation
data.frame(g0=M%*%coef(g0), g1=coef(g1))
#Combination of levels
str(M)
grid <- attr(M, "grid")
#Matrix of contrasts between levels of treatement
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
#Constrasts
summary(glht(g0, linfct=contr),
test=adjusted(type="fdr"))
#
Someone could you please help me,
Thanks,
--
======================================================================
Alexandre dos Santos
Proteção Florestal
IFMT - Instituto Federal de Educação, Ciência e Tecnologia de Mato Grosso
Campus Cáceres
Caixa Postal 244
Avenida dos Ramires, s/n
Bairro: Distrito Industrial
Cáceres - MT CEP: 78.200-000
Fone: (+55) 65 8132-8112 (TIM) (+55) 65 9686-6970 (VIVO)
alexandre.santos at cas.ifmt.edu.br
Lattes: http://lattes.cnpq.br/1360403201088680
OrcID: orcid.org/0000-0001-8232-6722
Researchgate: https://www.researchgate.net/profile/Alexandre_Santos10
LinkedIn: https://br.linkedin.com/in/alexandre-dos-santos-87961635
More information about the R-sig-ecology
mailing list