pairwiseAdonis错误,如果if(class(x)==“ dist”)

时间:2018-11-08 14:53:28

标签: r vegan

我为这些标签表示歉意,但是StackOverflow不允许我为pairwiseAdonis创建新标签,因此我不得不改用纯素食主义者,因为从技术上讲,它涉及事后测试。

我下载了pairwiseAdonis,以进行一些PERMANOVA(纯素食)事后测试,它似乎可以工作。但是,每次运行测试时,每行数据都会收到以下警告之一:

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

我不确定这意味着什么,而且我还没有足够的经验来开始挑选软件包的代码以了解发生了什么。我主要担心的是,如果这个错误可能意味着我得到的所有结果都毫无意义?如果是这样,您能推荐我可以使用的其他任何PERMANOVA事后测试吗?

这里是我的一部分数据(通过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")

1 个答案:

答案 0 :(得分:0)

通常,警告是警告:警告不是致命的,但可以为您提供信息。您的结果对象不是"dist"类,但它是一个小标题。这意味着在这种情况下,对象已正确处理(好吧,这是一个小问题,但仍然...)。似乎软件包 pairwiseAdonis 被新的更严格的逻辑条件解释(if所打击:该软件包应使用if (inherits(x, "dist"))而不是if (class(x) == "dist"),因为分析对象有几个类,但是if只希望有一个结果并且只使用一个条件。