前情回顾
方差分析基本概念:方差分析中的“元”和“因素”是什么?
PERMANOVA原理解释:这个统计检验可用于判断PCA/PCoA等的分群效果是否显著!
实战1:画一个带统计检验的PCoA分析结果
配对检验:画一个带统计检验的PcOA分析结果 (再进一步,配对比较)
新问题来了?
假如我们关注不同的管理风格 (Management
)和土壤厚度 (A1
)对物种组成是否有显著影响?,应该怎么检验呢?
library(vegan)
# 数据的解释和准备见前面的推文
data(dune)
data(dune.env)
A1
在前,Moisture
在后。这个情况下,A1
和Moisture
都与群体结构有显著关系。A1
可以解释16.8%
的总体差异,Moisture
解释27.6%
的总体差异。
adonis(dune ~ A1 + Moisture, data=dune.env, permutations=9999)
##
## Call:
## adonis(formula = dune ~ A1 + Moisture, data = dune.env, permutations = 9999)
##
## Permutation: free
## Number of permutations: 9999
##
## Terms added sequentially (first to last)
##
## Df SumsOfSqs MeanSqs F.Model R2 Pr(>F)
## A1 1 0.7230 0.72295 4.5393 0.16817 0.0003 ***
## Moisture 3 1.1871 0.39569 2.4845 0.27613 0.0061 **
## Residuals 15 2.3890 0.15927 0.55571
## Total 19 4.2990 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Moisture
在前,A1
在后。这个情况下,只有Moisture
与群体结构有显著关系。Moisture
可以解释40.2%
的总体差异,A1
解释0.04%
的总体差异。
For
adonis
and sequential tests in general, the order of terms should be meaningful. If it is not meaningful, the tests are hardly meaningful.
adonis(dune ~ Moisture + A1, data=dune.env, permutations=9999)
##
## Call:
## adonis(formula = dune ~ Moisture + A1, data = dune.env, permutations = 9999)
##
## Permutation: free
## Number of permutations: 9999
##
## Terms added sequentially (first to last)
##
## Df SumsOfSqs MeanSqs F.Model R2 Pr(>F)
## Moisture 3 1.7282 0.57606 3.6169 0.40199 0.0002 ***
## A1 1 0.1819 0.18186 1.1419 0.04230 0.3181
## Residuals 15 2.3890 0.15927 0.55571
## Total 19 4.2990 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
输出结果中Terms added sequentially (first to last)
这一句话很关键,表明环境因子的顺序对结果是有影响的,尤其是环境因子之间存在相关性时。
As there is some linear dependency, which ones goes into the model first determines how much variation is left to be explained by the second of the pair of covariates.
这时可以使用dbrda
(基于距离的冗余分析),或者通过adonis2
计算边缘概率 (by="margin"
)。
adonis2(dune ~ Moisture + A1, data=dune.env, permutations=9999, by="margin")
## Permutation test for adonis under reduced model
## Marginal effects of terms
## Permutation: free
## Number of permutations: 9999
##
## adonis2(formula = dune ~ Moisture + A1, data = dune.env, permutations = 9999, by = "margin")
## Df SumOfSqs R2 F Pr(>F)
## Moisture 3 1.1871 0.27613 2.4845 0.0052 **
## A1 1 0.1819 0.04230 1.1419 0.3228
## Residual 15 2.3890 0.55571
## Total 19 4.2990 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
adonis2(dune ~ A1 + Moisture, data=dune.env, permutations=9999, by="margin")
## Permutation test for adonis under reduced model
## Marginal effects of terms
## Permutation: free
## Number of permutations: 9999
##
## adonis2(formula = dune ~ A1 + Moisture, data = dune.env, permutations = 9999, by = "margin")
## Df SumOfSqs R2 F Pr(>F)
## A1 1 0.1819 0.04230 1.1419 0.3257
## Moisture 3 1.1871 0.27613 2.4845 0.0066 **
## Residual 15 2.3890 0.55571
## Total 19 4.2990 1.00000
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
ord F)
## A1 1 0.18186 1.1419 0.329
## Moisture 3 1.18708 2.4845 0.009 **
## Residual 15 2.38899
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
在控制A1
的情况下,Moisture
对菌群的影响是显著的。反之,在控制Moisture
的情况下,A1
对菌群的影响是不显著的。
adonis和adonis2的区别
vegan
包提供了两个函数adonis
和adonis2
来进行PERMANOVA
分析,这两个函数有什么区别呢?
-
adonis
函数对提供的变量执行的是序贯检验 (sequential test)。也就是说变量的顺序会对结果有影响(尤其是变量之间存在相关时)。系统会先评估第一个变量解释的差异比例,再评估后续变量解释的剩余总体差异的比例。后面会有一个例子展示差异。这等同于adonis2
使用参数by="terms" (默认参数)
。这通常被称为I型误差平方和 (Type I sums of squares
),此时,
- 对于模型
Y ~ A + B
来讲,变量A
的误差平方和为SS(A)
;
变量B
的误差平方和是在给定A
的基础上的平方和SS(B|A) = SS(A, B) - SS(A)
。 - 对于模型
Y ~ B + A
来讲,变量B
的误差平方和为SS(B)
;
变量A
的误差平方和是在给定B
的基础上的平方和SS(A|B) = SS(A, B) - SS(B)
。
- 如果你希望变量的顺序不影响结果,那么需要使用
adonis2
,并且设置参数by="margin"
。这时计算显著性时会考虑公式中其它所有变量,而不只是当前变量前面的那些变量。这通常被称为II型误差平方和 (Type II sums of squares
),此时
- 对于模型
Y ~ A + B
来讲,变量A
的误差平方和为SS(A|B) = SS(A, B) - SS(B)
;
变量B
的误差平方和SS(B|A) = SS(A, B) - SS(A)
。 - 对于模型
Y ~ B + A
来讲,变量A
的误差平方和为SS(A|B) = SS(A, B) - SS(B)
;
变量B
的误差平方和SS(B|A) = SS(A, B) - SS(A)
。
- 或者你想看整体模型是否显著,也需要使用
adonis2
,并且设置参数by="null"
。
Order does not matter when
by="margin"
because the significance is tested against a model that includes all other variables not just the ones preceding it in the formula. It seems thatstrata
is now deprecated in favor of defining blocks in the permutations argument now (see adonis help). Anyway, these arguments allow you to specify how to restrict which rows can be exchanged during the permutation procedure used to calculate p values.
adonis
performs a sequential test of terms。adonis2
can perform sequential, marginal and overall tests. Function adonis2 also allows using additive constants or squareroot of dissimilarities to avoid negative eigenvalues,but both functions can handle semimetric indices (such as Bray-Curtis) that produce negative eigenvalues. Functionadonis2
can be much slower thanadonis
, in particular with several terms.
参考
- https://www.scribbr.com/frequently-asked-questions/one-way-vs-two-way-anova/
- MANOVA的前提假设 https://www.real-statistics.com/multivariate-statistics/multivariate-analysis-of-variance-manova/manova-assumptions/ https://www.statology.org/manova-assumptions/
- https://statistics.laerd.com/statistical-guides/one-way-anova-statistical-guide.php
- https://www.yunbios.net/h-nd-570.html
- https://mp.weixin.qq.com/s/v_k4Yhe9rBWM9y9A3P3wQw
- https://mp.weixin.qq.com/s?__biz=MzUzMjA4Njc1MA==&mid=2247484678&idx=1&sn=f95418a311e639704e9848545efc7fd7&scene=21#wechat_redirect
- https://chrischizinski.github.io/rstats/vegan-ggplot2/
- https://chrischizinski.github.io/rstats/adonis/
- https://chrischizinski.github.io/rstats/ordisurf/
- https://www.rdocumentation.org/packages/vegan/versions/1.11-0/topics/adonis
- https://www.jianshu.com/p/dfa689f7cafd
- https://stats.stackexchange.com/questions/312302/adonis-in-vegan-order-of-variables-non-nested-with-one-degree-of-freedom-for
- https://stats.stackexchange.com/questions/188519/adonis-in-vegan-order-of-variables-or-use-of-strata?noredirect=1
- https://github.com/vegandevs/vegan/issues/229
- https://stats.stackexchange.com/questions/476256/adonis-vs-adonis2
- 清晰解释Type I, Type II, Type III https://mcfromnz.wordpress.com/2011/03/02/anova-type-iiiiii-ss-explained/
- 清晰解释Type I, Type II, Type III https://stats.stackexchange.com/questions/60362/choice-between-type-i-type-ii-or-type-iii-anova
- https://thebiobucket.blogspot.com/2011/08/two-way-permanova-adonis-with-custom.html#more
- adonis的前提条件 https://thebiobucket.blogspot.com/2011/04/assumptions-for-permanova-with-adonis.html#more
- 作者的论文 https://static1.squarespace.com/static/580e3c475016e191c523a0e2/t/5813ba8b5016e1a5b61f454a/1477687949842/Anderson_et_al-2013-ANOSIM+vs.+PERMANOVA.pdf
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.e1idc.net