【问题标题】:using ordiellipse in NMDS in R on axes 2 and 3在轴 2 和轴 3 上使用 R 中 NMDS 中的 ordiellipse
【发布时间】:2015-07-15 09:37:28
【问题描述】:

我正在尝试通过以下函数将 NMDS by vegan package 应用于数据集:

library(vegan)
library(MASS)
library(MVA)
library(ggplot2)
all_d <- vegdist(landmetr, method= "hor", binary=FALSE, diag=TRUE,
             upper=FALSE, na.rm = FALSE)
allmds3 <- isoMDS(all_d, k=3)
gr0 <- factor(france100_7c$LAND_CODE)
plot(allmds3$points[,2:3], col=gr0, bg="grey", cex=0.2,pch=20) 
# regress environmental variables on configuration of site points
provaenv3 <- envfit(allmds3$points[,2:3], landmetr,999, na.rm = FALSE, france100_7c$LAND_CODE)
# add the environmental regressions to the area plot
plot(provaenv3,add=T, cex=0.5)
#plot0
ordiellipse (allmds3, gr0, kind = "sd", conf=0.95, label = T)

但是,尽管此双标图是在轴 2 和 3 上构建的,但 ordiellipse 函数仍会编写用于标识轴 1 和 2 双标图上的集群的椭圆。 谁能解释一下为什么会发生这种情况以及如何在轴 2 和轴 3 双图上绘制正确的椭圆?

【问题讨论】:

  • 很遗憾,我无法访问landmetr。你能让你的例子可重现吗?

标签: r vegan


【解决方案1】:

在这种情况下,预期的用法是将choices 也传递给ordiellipse。如?ordiellipse中所述

 ...: Parameters passed to graphical functions or to ‘scores’ to
      select axes and scaling etc.

因此@EDi 的示例可以更简单地完成

library("vegan")
data(dune)
data(dune.env)
set.seed(1234)
NMDS <- metaMDS(dune, k = 3)
take <- c(1,3)
plot(NMDS, choices = take, display = "sites", type = "n")
points(NMDS, choices = take, display = "sites",
       col = dune.env$Management)
with(dune.env, ordiellipse(NMDS, Management, choices = take))

生产

【讨论】:

  • +1。椭圆可以按一个因子着色吗?目前,我认为,ordiellipse(和其他人)只接受一种颜色。可能是有用的功能(我总是使用循环)。如果不可能,我可以尝试实现它......
【解决方案2】:

您可以使用替代绘图功能ordiplot()

require(vegan)
data(dune)
data(dune.env)
NMDS <- metaMDS(dune, k = 3)
pl<-ordiplot(NMDS, choices = c(2, 3), display = 'sites', type = 'n')
points(pl, what = 'sites', col = dune.env$Management, pch = 16)
ordiellipse(pl, dune.env$Management)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-05
    • 2012-05-24
    • 1970-01-01
    • 2012-11-27
    相关资源
    最近更新 更多