R vegan 简单分析:修改距离矩阵

R vegan simper analysis: modify distance matrix

我正在使用 Vegan 包中的简单分析来确定哪些氨基酸导致不同样品之间蛋白质组成的变化。据我了解 discussion,simper() 函数使用 Bray-Curtis。我需要使用另一个相异指数,通常是欧氏指数。我如何在函数中修改它?谢谢。

只改变相异性是微不足道的,但你使用的相异性应该是这样的,你可以按物种添加和分析术语。 squared 欧几里德距离的术语是这样的。然而,simper() 使各种奇怪的技巧具有不同之处,我完全不确定这些技巧是否适用于平方欧几里得距离(我什至不确定它们是否适用于我们使用的 Bray-Curtis,但是至少他们符合公布的方法)。注意,我们警告不要使用simper。这是帮助页面的摘录——我希望你已经阅读过:

The results of ‘simper’ can be very difficult to interpret. The method very badly confounds the mean between group differences and within group variation, and seems to single out variable species instead of distinctive species (Warton et al. 2012). Even if you make groups that are copies of each other, the method will single out species with high contribution, but these are not contributions to non-existing between-group differences but to within-group variation in species abundance.

就是说,这里是您应该更改的行,以从 Bray-Curtis 切换到平方欧几里德。但是,我建议你不要使用这个功能:

diff --git a/R/simper.R b/R/simper.R
index 35fa189..f60c57f 100644
--- a/R/simper.R
+++ b/R/simper.R
@@ -13,9 +13,8 @@
         n.b <- nrow(gb)
         for(j in seq_len(n.b)) {
             for(k in seq_len(n.a)) {
-                mdp <- abs(ga[k, , drop = FALSE] - gb[j, , drop = FALSE])
-                mep <- ga[k, , drop = FALSE] + gb[j, , drop = FALSE]
-                contrp[(j-1)*n.a+k, ] <- mdp / sum(mep)
+                mdp <- (ga[k,, drop=FALSE] - gb[j,, drop = FALSE])^2
+                contrp[(j-1)*n.a+k, ] <- mdp
             }
         }
         colMeans(contrp)
@@ -53,9 +52,8 @@
         contr <- matrix(ncol = P, nrow = n.a * n.b)
         for (j in seq_len(n.b)) {
             for (k in seq_len(n.a)) {
-                md <- abs(group.a[k, , drop = FALSE] - group.b[j, , drop = FALSE])
-                me <- group.a[k, , drop = FALSE] + group.b[j, , drop = FALSE]
-                contr[(j-1)*n.a+k, ] <- md / sum(me)
+                md <- (group.a[k,,drop=FALSE] - group.b[j,,drop=FALSE])^2
+                contr[(j-1)*n.a+k, ] <- md
             }
         }
         average <- colMeans(contr)