Adonis(vegan) in R with Strata

1,254 views
Skip to first unread message

Daiv9

unread,
Mar 24, 2016, 10:37:40 AM3/24/16
to qiime...@googlegroups.com
Hi,
I have paired samples, so I cannot use compare_categories.py - Adonis code given by qiime directly. I have to use R Adonis with strata function to identify paired samples as a block variable. 

Can anyone guide me how to write the code in R for that ? Can i use "unweighted_unifrac_dm.txt" directly in R Adonis package ?

I have attached both the files, distance matrix file and Map file. Strata, block variable will be Patients and I want to run Adonis to find difference between Stage (S,L)

Thanks
Daiv
unweighted_unifrac_dm.txt
S1L2Map.txt

Aditya Bandla

unread,
Mar 25, 2016, 7:11:36 PM3/25/16
to qiime...@googlegroups.com
Hi Daiv

I propose the following code to answer your question

dist = read.table("unweighted_unifrac_dm.txt", header=T)
result = adonis(dist ~ Patients + Stage, data=S1L2)

I generally use the OTU table as the input and make use of the dist option. However, I understand vegan does not support unifrac as a distance measure. So I am a bit doubtful whether one can use the distance file directly as the dependent variable.

Further, I have experimented with the strata function in Adonis. The order of the variables in the function call is important. With the above function call, Patients will be treated as a blocking variable and thus there is no need to use the strata option. Even if you did use the strata option, the outcome would be the same

Cheers,
Aditya

Daiv9

unread,
Mar 25, 2016, 10:23:36 PM3/25/16
to Qiime 1 Forum
Hi Aditya,
That's awesome, it worked. You made my day !!!

Though, with strata argument, it did not give me the same results. see below,

Without Strata,

Call:
adonis(formula = dist ~ Patients + Stage, data = read.table("C:\\Share\\Qiime\\S1L2Map.txt",      header = T)) 

Permutation: free
Number of permutations: 999

Terms added sequentially (first to last)

          Df SumsOfSqs MeanSqs F.Model      R2 Pr(>F)   
Patients   1    0.1943 0.19433 0.94012 0.02385  0.634   
Stage      1    0.3054 0.30537 1.47730 0.03748  0.010 **
Residuals 37    7.6483 0.20671         0.93867          
Total     39    8.1480                 1.00000          
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

With Strata

Call:
adonis(formula = dist ~ Stage, data = data, strata = data$Patients) 

Blocks:  strata 
Permutation: free
Number of permutations: 999

Terms added sequentially (first to last)

          Df SumsOfSqs MeanSqs F.Model      R2 Pr(>F)  
Stage      1    0.3054 0.30537  1.4796 0.03748  0.027 *
Residuals 38    7.8426 0.20638         0.96252         
Total     39    8.1480                 1.00000         
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Thanks a ton !
Daiv

Daiv9

unread,
Mar 25, 2016, 11:17:04 PM3/25/16
to Qiime 1 Forum
Hi Aditya,
how do you use the OTU table as the input and make use of the dist option ? Do you use the otu_table.biom file or you use the summarized taxa otu table?

Best
Daiv
Reply all
Reply to author
Forward
0 new messages