[R-sig-eco] Two-way contrasts with adonis()

microbiomics microbiomics at mytng.de
Wed Mar 9 15:30:07 CET 2016


Hi Alexandre,

On 09.03.2016 12:34, ASANTOS wrote:
[the code above is OK]

> #Comparisons
> impyes:treatt1_impno:treatt1<- Treat_Imp[, 1] - Treat_Imp[, 2]
> impyes:treatt2_impno:treatt2<- Treat_Imp[, 2] - Treat_Imp[, 3]
> impyes:treatt3_impno:treatt3<- Treat_Imp[, 3] - Treat_Imp[, 4]
>

First, variable names cannot contain ":", so you need to replace the 
colon with a period. Also, it looks like you mixed up column indices of 
Treat_Imp, so my suggestion is:

impyes.treatt1_impno.treatt1<- Treat_Imp[, 1] - Treat_Imp[, 2]
impyes.treatt2_impno.treatt2<- Treat_Imp[, 3] - Treat_Imp[, 4]
impyes.treatt3_impno.treatt3<- Treat_Imp[, 5] - Treat_Imp[, 6]




To simply make the code run as per your request, try this:

adonis(sp ~ impyes.treatt1_impno.treatt1
       + impyes.treatt2_impno.treatt2
       + impyes.treatt3_impno.treatt3,
       method = "euclidean")



One problem with this approach is that terms are added sequentially to 
the test, so "impyes.treatt1_impno.treatt1" is tested alone, while 
"impyes.treatt2_impno.treatt2" is tested in presence of 
"impyes.treatt1_impno.treatt1" and so on. Thus, your result depends on 
the input order of your terms, which might not be what you expect or 
even want.

A better alternative to the above code would thus involve function 
rda(), followed by its anova() method:


rdaModel <- rda(sp ~ impyes.treatt1_impno.treatt1
                + impyes.treatt2_impno.treatt2
                + impyes.treatt3_impno.treatt3)

anova(rdaModel, by = "terms")



Still, it looks like you are trying to construct a "Swiss Army knife" to 
do ANOVA and multiple pairwise tests at the same time. IMHO, you need to 
perform the pairwise comparisons one by one, each with its respective 
subset of data - and appropriate p-value adjustment for multiple testing.



Best,
Sven



More information about the R-sig-ecology mailing list