[R-sig-Geo] adonis2 in vegan (distance or abundance matrix)

Tim Richter-Heitmann trichter @ending from uni-bremen@de
Tue Jun 19 15:38:50 CEST 2018


Der list,

i have came across this interesting feature of vegan's adonis2.

The example in ?adonis2 shows that adonis2takes an abundance matrix, and 
converts it to a distance matrix, as given in "method":

library(vegan)
data(dune)
data(dune.env)

ad1 <- adonis2(dune ~ Management*A1, data = dune.env, method="bray")

Permutation test for adonis under reduced model Terms added sequentially 
(first to last) Permutation: free Number of permutations: 999 
adonis2(formula = dune ~ Management * A1, data = dune.env, method = 
"bray") Df SumOfSqs R2 F Pr(>F) Management 3 1.4686 0.34161 3.2629 0.003 
** A1 1 0.4409 0.10256 2.9387 0.022 * Management:A1 3 0.5892 0.13705 
1.3090 0.228 Residual 12 1.8004 0.41878 Total 19 4.2990 1.00000 --- 
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

However, it can also handle the direct input of the distance matrix:
dune.dist <- vegdist(dune, method="bray")
ad2 <- adonis2(dune.dist~Management*A1, data = dune.env, method="bray")

Permutation test for adonis under reduced model Terms added sequentially 
(first to last) Permutation: free Number of permutations: 999 
adonis2(formula = dune.dist ~ Management * A1, data = dune.env, method = 
"bray") Df SumOfSqs R2 F Pr(>F) Management 3 1.4686 0.34161 3.2629 0.001 
*** A1 1 0.4409 0.10256 2.9387 0.009 ** Management:A1 3 0.5892 0.13705 
1.3090 0.213 Residual 12 1.8004 0.41878 Total 19 4.2990 1.00000 --- 
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Apparently, method="bray" is ignored. Here i thought, because dune.dist 
is a already dist-class object, adonis2 abandons the step of creating a 
distance matrix. However, if i convert the dist-object into a dataframe, 
the output is still the same!

dune.df <- as.data.frame(as.matrix(vegdist(dune, method="bray")))
str(dune.df)

ad3 <- adonis2(dune.df~Management*A1, data = dune.env, method="bray")

Permutation test for adonis under reduced model Terms added sequentially 
(first to last) Permutation: free Number of permutations: 999 
adonis2(formula = dune.df ~ Management * A1, data = dune.env, method = 
"bray") Df SumOfSqs R2 F Pr(>F) Management 3 1.4686 0.34161 3.2629 0.004 
** A1 1 0.4409 0.10256 2.9387 0.016 * Management:A1 3 0.5892 0.13705 
1.3090 0.221 Residual 12 1.8004 0.41878 Total 19 4.2990 1.00000

Even though, method="bray" is specified, dune.df is not converted to a 
dist-object. How is it possible that dune, dune.dist, and dune.df all 
give the same result, despite having different dimensions and classes?

> ad1 == ad2 Df SumOfSqs R2 F Pr(>F) Management TRUE TRUE TRUE TRUE FALSE 
A1 TRUE TRUE TRUE TRUE FALSE Management:A1 TRUE TRUE TRUE TRUE FALSE 
Residual TRUE TRUE TRUE NA NA Total TRUE TRUE TRUE NA NA > ad2 == ad3 Df 
SumOfSqs R2 F Pr(>F) Management TRUE TRUE TRUE TRUE FALSE A1 TRUE TRUE 
TRUE TRUE FALSE Management:A1 TRUE TRUE TRUE TRUE FALSE Residual TRUE 
TRUE TRUE NA NA Total TRUE TRUE TRUE NA NA

Thank you!

-- 
Dr. Tim Richter-Heitmann

University of Bremen
Microbial Ecophysiology Group (AG Friedrich)
FB02 - Biologie/Chemie
Leobener Straße (NW2 A2130)
D-28359 Bremen
Tel.: 0049(0)421 218-63062
Fax: 0049(0)421 218-63069


	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list