你的adonis用对了吗?不同因素的顺序竟然对结果有很大影响
前情回顧
方差分析基本概念:方差分析中的“元”和“因素”是什么?
PERMANOVA原理解釋:這個統(tǒng)計檢驗可用于判斷PCA/PCoA等的分群效果是否顯著!
實戰(zhàn)1:畫一個帶統(tǒng)計檢驗的PCoA分析結(jié)果
配對檢驗:畫一個帶統(tǒng)計檢驗的PcOA分析結(jié)果 (再進一步,配對比較)
新問題來了?
假如我們關(guān)注不同的管理風格 (Management)和土壤厚度 (A1)對物種組成是否有顯著影響?,應該怎么檢驗呢?
A1在前,Moisture在后。這個情況下,A1和Moisture都與群體結(jié)構(gòu)有顯著關(guān)系。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 ' ' 1Moisture在前,A1在后。這個情況下,只有Moisture與群體結(jié)構(gòu)有顯著關(guān)系。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輸出結(jié)果中Terms added sequentially (first to last)這一句話很關(guān)鍵,表明環(huán)境因子的順序?qū)Y(jié)果是有影響的,尤其是環(huán)境因子之間存在相關(guān)性時。
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 ' ' 1adonis2(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 ' ' 1ord <- dbrda(dune ~ A1 + Moisture, data = dune.env, dist = 'bray') anova(ord, by = 'margin')## Permutation test for dbrda under reduced model ## Marginal effects of terms ## Permutation: free ## Number of permutations: 999 ## ## Model: dbrda(formula = dune ~ A1 + Moisture, data = dune.env, distance = "bray") ## Df SumOfSqs F Pr(>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的區(qū)別
vegan包提供了兩個函數(shù)adonis和adonis2來進行PERMANOVA分析,這兩個函數(shù)有什么區(qū)別呢?
adonis函數(shù)對提供的變量執(zhí)行的是序貫檢驗 (sequential test)。也就是說變量的順序會對結(jié)果有影響(尤其是變量之間存在相關(guān)時)。系統(tǒng)會先評估第一個變量解釋的差異比例,再評估后續(xù)變量解釋的剩余總體差異的比例。后面會有一個例子展示差異。這等同于adonis2使用參數(shù)by="terms" (默認參數(shù))。這通常被稱為I型誤差平方和 (Type I sums of squares),此時,
對于模型Y ~ A + B來講,變量A的誤差平方和為SS(A);
變量B的誤差平方和是在給定A的基礎(chǔ)上的平方和SS(B|A) = SS(A, B) - SS(A)。
對于模型Y ~ B + A來講,變量B的誤差平方和為SS(B);
變量A的誤差平方和是在給定B的基礎(chǔ)上的平方和SS(A|B) = SS(A, B) - SS(B)。
如果你希望變量的順序不影響結(jié)果,那么需要使用adonis2,并且設(shè)置參數(shù)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,并且設(shè)置參數(shù)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 that strata 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 than adonis, in particular with several terms.
參考
https://www.scribbr.com/frequently-asked-questions/one-way-vs-two-way-anova/
MANOVA的前提假設(shè) 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
往期精品(點擊圖片直達文字對應教程)
機器學習
后臺回復“生信寶典福利第一波”或點擊閱讀原文獲取教程合集
總結(jié)
以上是生活随笔為你收集整理的你的adonis用对了吗?不同因素的顺序竟然对结果有很大影响的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: xwindow
- 下一篇: 监督学习 | ID3 C4.5 决策树