pairwiseAdonis error In if (class(x) == "dist")

pairwiseAdonis error In if (class(x) == "dist")

我为标签道歉,但 Whosebug 不允许我为 pairwiseAdonis 创建新标签,所以我不得不使用 vegan,因为这在技术上涉及 post-hoc 测试。

我下载了 pairwiseAdonis 来做一些 PERMANOVA(素食主义者)post-hoc 测试,它似乎有效。但是,每次我 运行 测试时,我都会针对每一行数据收到以下警告之一:

In if (class(x) == "dist") { :
  the condition has length > 1 and only the first element will be used

我不确定这意味着什么,而且我没有足够的经验来开始拆包的代码来弄清楚发生了什么。我主要担心的是这个错误是否意味着我得到的所有结果都毫无意义?如果是这样,你能推荐任何其他我可以用来代替的 PERMANOVA post-hoc 测试吗?

这是我的一部分数据(通过 dput(lengths_year))和代码,如果您想自己尝试一下。

structure(list(method = c("GEMAX", "GEMAX", "GEMAX", "GEMAX", 
"GEMAX", "GEMAX", "GEMAX", "GEMAX", "GEMAX", "GEMAX", "GEMAX", 
"GEMAX", "GEMAX", "GEMAX", "GEMAX", "GEMAX", "GEMAX", "GEMAX", 
"GEMAX", "GEMAX"), method_year = c("GE_2017", "GE_2017", "GE_2017", 
"GE_2017", "GE_2017", "GE_2017", "GE_2017", "GE_2017", "GE_2017", 
"GE_2017", "GE_2017", "GE_2017", "GE_2017", "GE_2017", "GE_2017", 
"GE_2017", "GE_2017", "GE_2017", "GE_2017", "GE_2017"), season_year = c("summer 2017", 
"summer 2017", "summer 2017", "summer 2017", "summer 2017", "summer 2017", 
"summer 2017", "summer 2017", "summer 2017", "summer 2017", "summer 2017", 
"summer 2017", "summer 2017", "summer 2017", "summer 2017", "summer 2017", 
"summer 2017", "summer 2017", "summer 2017", "summer 2017"), 
    station = c("1", "1", "1", "1", "1", "3", "3", "3", "3", 
    "3", "5", "5", "5", "5", "5", "6", "6", "6", "6", "6"), sample = c("1", 
    "2", "3", "4", "5", "1", "2", "3", "4", "5", "1", "2", "3", 
    "4", "5", "1", "2", "3", "4", "5"), `1` = c(0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), `1.5` = c(0, 
    25, 0, 0, 23.0769230769231, 0, 16.6666666666667, 50, 14.2857142857143, 
    0, 0, 50, 0, 40, 0, 0, 30, 15.3846153846154, 9.09090909090909, 
    7.69230769230769), `2` = c(0, 12.5, 22.2222222222222, 0, 
    38.4615384615385, 20, 16.6666666666667, 0, 28.5714285714286, 
    0, 0, 0, 0, 0, 0, 18.1818181818182, 30, 7.69230769230769, 
    45.4545454545455, 15.3846153846154), `2.5` = c(0, 0, 11.1111111111111, 
    33.3333333333333, 7.69230769230769, 0, 33.3333333333333, 
    0, 0, 0, 0, 0, 0, 0, 0, 9.09090909090909, 10, 15.3846153846154, 
    9.09090909090909, 15.3846153846154), `3` = c(0, 0, 0, 16.6666666666667, 
    7.69230769230769, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9.09090909090909, 
    0, 15.3846153846154, 0, 15.3846153846154), `3.5` = c(0, 25, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15.3846153846154, 
    0, 7.69230769230769), `4` = c(0, 0, 0, 16.6666666666667, 
    7.69230769230769, 0, 0, 0, 0, 0, 50, 25, 0, 0, 0, 0, 0, 0, 
    0, 0), `4.5` = c(16.6666666666667, 0, 11.1111111111111, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), `5` = c(16.6666666666667, 
    12.5, 0, 0, 7.69230769230769, 0, 0, 50, 0, 0, 0, 0, 0, 0, 
    0, 9.09090909090909, 10, 0, 0, 7.69230769230769), `5.5` = c(16.6666666666667, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 7.69230769230769
    ), `6` = c(0, 12.5, 0, 0, 7.69230769230769, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 7.69230769230769, 9.09090909090909, 
    0), `6.5` = c(16.6666666666667, 0, 0, 0, 0, 20, 0, 0, 0, 
    0, 0, 0, 0, 20, 0, 9.09090909090909, 0, 0, 0, 0), `7` = c(16.6666666666667, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9.09090909090909, 
    0, 0, 0, 0), `7.5` = c(0, 0, 11.1111111111111, 16.6666666666667, 
    0, 0, 16.6666666666667, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 
    0, 7.69230769230769), `8` = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 9.09090909090909, 0), `8.5` = c(0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 
    `9` = c(0, 12.5, 11.1111111111111, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 10, 15.3846153846154, 0, 0), `9.5` = c(0, 
    0, 0, 0, 0, 0, 0, 0, 0, 33.3333333333333, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0), `10` = c(16.6666666666667, 0, 11.1111111111111, 
    0, 0, 0, 0, 0, 28.5714285714286, 0, 0, 0, 0, 0, 0, 9.09090909090909, 
    0, 0, 9.09090909090909, 0), `10.5` = c(0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 9.09090909090909, 0, 0, 0, 0), 
    `11` = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0), `11.5` = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 7.69230769230769, 9.09090909090909, 0), 
    `12` = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0), `12.5` = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0), `13` = c(0, 0, 0, 0, 0, 0, 0, 
    0, 14.2857142857143, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7.69230769230769
    ), `13.5` = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0), `14` = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0), `14.5` = c(0, 0, 0, 16.6666666666667, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), `15` = c(0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 0, 0, 0), 
    `15.5` = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0), `16` = c(0, 0, 11.1111111111111, 0, 0, 0, 16.6666666666667, 
    0, 0, 33.3333333333333, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0), `16.5` = c(0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 0, 20, 0, 50, 0, 0, 0, 0, 
    0), `17` = c(0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 
    0, 0, 0, 0, 0, 0), `17.5` = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), `18` = c(0, 0, 11.1111111111111, 
    0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 9.09090909090909, 0, 
    0, 0, 0), `18.5` = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 33.3333333333333, 
    0, 25, 0, 0, 0, 9.09090909090909, 10, 0, 0, 0), `19` = c(0, 
    0, 0, 0, 0, 20, 0, 0, 14.2857142857143, 0, 0, 0, 20, 0, 0, 
    0, 0, 0, 0, 0), `19.5` = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0), `20` = c(0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7.69230769230769), 
    `20.5` = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0), `21` = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0), `21.5` = c(0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), `22` = c(0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), year_station = c("summer 2017 1", 
    "summer 2017 1", "summer 2017 1", "summer 2017 1", "summer 2017 1", 
    "summer 2017 3", "summer 2017 3", "summer 2017 3", "summer 2017 3", 
    "summer 2017 3", "summer 2017 5", "summer 2017 5", "summer 2017 5", 
    "summer 2017 5", "summer 2017 5", "summer 2017 6", "summer 2017 6", 
    "summer 2017 6", "summer 2017 6", "summer 2017 6")), row.names = c(NA, 
-20L), class = c("tbl_df", "tbl", "data.frame"), .Names = c("method", 
"method_year", "season_year", "station", "sample", "1", "1.5", 
"2", "2.5", "3", "3.5", "4", "4.5", "5", "5.5", "6", "6.5", "7", 
"7.5", "8", "8.5", "9", "9.5", "10", "10.5", "11", "11.5", "12", 
"12.5", "13", "13.5", "14", "14.5", "15", "15.5", "16", "16.5", 
"17", "17.5", "18", "18.5", "19", "19.5", "20", "20.5", "21", 
"21.5", "22", "year_station"))

代码:

library(vegan)
library(pairwiseAdonis)

Y <- lengths_year[, c(7:20, 22:25, 27, 30, 33:34, 36:38, 40:42, 44)]

set.seed(1)
adonis(Y ~ lengths_year$year_station)

pairwise.adonis(Y, lengths_year$year_station, p.adjust.m = "BH")

总的来说,警告就是警告:它们不是致命的,而是给你信息。您的结果对象不是 class "dist",而是一个 tibble。这意味着在这种情况下对象被正确处理(好吧,它是一个 tibble,但仍然......)。似乎包 pairwiseAdonis 受到新的更严格的逻辑条件解释(if)的影响:包应该使用 if (inherits(x, "dist")) 而不是 if (class(x) == "dist") 因为被分析的对象有几个class,但是if只想得到一个结果,只用一个条件