【问题标题】:preparing data for vegan NMDS in R在 R 中为纯素 NMDS 准备数据
【发布时间】:2017-02-10 18:13:52
【问题描述】:

我想在 R 中使用 vegan 对我的数据子集运行 NMDS 和 PERMANOVA。我的数据包含很多零,如下所示:

> str(invert)
'data.frame':   96 obs. of  67 variables:
 $ SampleID                       : Factor w/ 96 levels "11-1-E-1","11-1-E-2",..: 61 62 63 49 50 51 85 86 87 73 ...
 $ SampleDate                     : Factor w/ 8 levels "17-Aug-12","17-Oct-12",..: 1 1 1 6 6 6 2 2 2 4 ...
 $ Year                           : int  2012 2012 2012 2012 2012 2012 2012 2012 2012 2012 ...
 $ Month                          : Factor w/ 4 levels "August","July",..: 1 1 1 2 2 2 3 3 3 4 ...
 $ Habitat                        : Factor w/ 4 levels "epiphyte","pool",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ N                              : num  1429 143 1705 1147 212 ...
 $ S                              : int  6 2 8 9 4 5 6 8 5 5 ...
 $ Aeshnidae                      : int  0 0 0 0 0 0 0 0 0 0 ...
 $ Aeshnidae..Anax                : int  0 0 0 0 0 0 0 0 0 0 ...
 $ Aeshnidae..Gynacantha          : int  0 0 0 0 0 0 0 0 0 0 ...
 $ Aeshnidae..Oplonaeschna        : int  0 0 0 0 0 0 0 0 0 0 ...
 $ Anisoptera                     : int  0 0 0 0 0 0 0 0 0 0 ...
 $ ant                            : num  0 0 0 0 0 0 0 0 0 0 ...

如您所见,“栖息地”有四个级别。我想分别分析每个栖息地。我试过子集,但这意味着我必须做四次(每个栖息地一次)。有没有更有效的方法?

这是我为泳池栖息地划分子集的方式:

invert[6:67] <- lapply(invert[6:67], as.numeric)
pool <- subset(invert, Habitat=="pool")

ord <- metaMDS(pool[,7:67], 
               k=2, 
               trymax = 1000, 
               autotransform = TRUE, 
               expand = FALSE, 
               plot = FALSE)

plot(ord$points[,2],ord$points[,1], type="n",
     main="Communities by month", 
     xlab="NMDS 1",
     ylab="NMDS 2", 
     xlim=c(-1.5,1.5), 
     ylim=c(-1.5,1.5))
ordisymbol(ord, pool, factor="Month", cex=1.25, rainbow=T, legend=T)

#run PERMANOVA;
adonis(pool[,8:67] ~ pool$Month)

【问题讨论】:

    标签: r subset vegan


    【解决方案1】:

    您应该为您的 nmds 以矩阵形式运行所有物种 x 站点,然后创建一个组对象,指定哪些行来自哪个栖息地。 例如,如果我的矩阵的前 6 行来自城市化地区,然后接下来的 6 行来自雨林,我将创建一个这样的分组对象:

    habitattypes<-c(rep("Urbanized",16), rep("RainForest",16))
    Permanova<-adonis(yourdata^0.25~habitattypes, permutations = 999, method = "bray")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-20
      • 1970-01-01
      • 1970-01-01
      • 2021-06-25
      • 2020-10-02
      • 2021-10-30
      • 2019-10-20
      相关资源
      最近更新 更多