vegandevs / vegan

R package for community ecologists: popular ordination methods, ecological null models & diversity analysis
https://vegandevs.github.io/vegan/
GNU General Public License v2.0
449 stars 96 forks source link

Random effect factors and mixed models in adonis(2) #429

Closed farhadm1990 closed 2 years ago

farhadm1990 commented 3 years ago

Currently, I am working with a dataset of gut microbiota from an experiment on pigs tested with three treatments (red meat, dss, and read meat+dss) against control group. The experiment was done in three complete rounds (each round was completed independently from each other). In each round, we have tested our treatments on 8 pigs divided on 4 pens (each pen included 2 pigs). The pigs in each round are the offspring of 2 different sows (6 sows in total for the three rounds). In each pen of each round, we placed 2 pigs coming from two different litters. Therefore, 2 pigs (non-littermate) in pen 1 received no treatment (control group; ct), 2 pigs in pen 2 received red meat treatment (gb), 2 pigs in pen 3 received red an inflammation-inducing substance called DSS (dss), and 2 pigs in pen 4 received combination of red meat and dss treatments (gbdss). This goes on for two other rounds, with the exception that the individual pigs were the offspring of two different sows in round 2 and two other different sows in round 3. We have taken digesta samples from three points (segments) in the colon of each pig as well as their fecal samples. Since for each round we have different litters, I should nest the random effect of pen within random effect of sow and also consider the individual pig’s effects as random effect. I am considering the effects of round, treatment and segment as fixed effect factors. In order to see if any of upper-mentioned factors have effects on my beta diversity metrics (e.g. bray-curtis and jaccard dissimilarity matrices, and unifrac and wunifrac distances), I am using permutation analysis by Adonis in vegan package. Before that, I did a homogeneity of variance test on these distance matrices to see if the differences came from the distance between the centroids of the factors or they were due to the dispersion around the centroid within the groups.
For example you can see the code for Bray-Curtis dissimilarity matrix:

bray.dist = phyloseq::distance(pst.digf1, method = "bray") _vegan::betadisper(bray.dist, group = sampledata(pst.digf1)$treatment, type = "centroid")

below is the anova results of this dispersion test: image

The low p-value is also confirmed by the pcoa plot in this PCoA plot: image

In a case like this, can I say that the results of my Adonis model are not reliable anymore? Then, how can I use Adonis here? Or maybe better to ask, which other methods PERMANOVA do you recommend to account for random effects in the model? Here is my Adonis model input and I have trouble assigning the random effects of pigs nested into the random effect of sows.

vegan::adonis(t(otu_table(pst.digf1)) ~ blok treatment + treatment segment + sows + pig, data=pst.metadat, method="bray", permutations = 999)

I will be very appreciated if someone could help me with this problem! I am looking forward to hearing from you

Bests, Farhad

gavinsimpson commented 2 years ago

@farhadm1990 and I have conversed offline about this.

An option is to use restricted permutation test: see ?permute::how for details on how to define restricted permutation tests. One can pass the output from how() to the permutations argument of adonis2().

adonis2() should be used in place of adonis() as the latter is deprecated. If you come across this issue please use adonis2() not adonis(). Pretty please!

That said, also consider dbrda() as it allows Condition in the model formula which can be needed for some of the model and design-based Monte Carlo or restricted permutation tests we might want to use for experimental designs like the one describe above.

farhadm1990 commented 2 years ago

Thanks a lot Gavin got it solved 🙂