我想做一个nMDS分析,我想在我的图表中添加代表bray-curtis相似度百分比的椭圆,但我不知道如何用R做这个,你可以用PRIMER做这种类型的图形但是我假设R也是。我该怎么做?
我希望我的图形看起来像这样:graph
我从未使用过PRIMER,我不知道这些图是如何绘制的,但我必须从你发布的图表中猜出来。可能是你首先得到一个聚类树形图(函数hclust
),然后用树高(函数cutree
)剪切它,然后为这些(vegan::ordiellipse(..., kind = "ehull")
)绘制封闭的椭圆。如果是这样,这应该可以解决问题:
library(vegan)
data(BCI)
d <- vegdist(BCI)
ord <- metaMDS(d, trace=FALSE)
cl <- hclust(d, "average") # using average linkage
plot(cl, hang=-1)
rect.hclust(cl, h=0.4, border="red") # to see the clusters
rect.hclust(cl, h=0.5, border="cyan")
rect.hclust(cl, h=0.6, border="blue")
plot(ord) # then ordination & enclosing ellipses
ordiellipse(ord, cutree(cl, h=0.4), kind="ehull", col="red", lwd=2)
ordiellipse(ord, cutree(cl, h=0.5), kind="ehull", col="cyan", lwd=2)
ordiellipse(ord, cutree(cl, h=0.6), kind="ehull", col="blue", lwd=2)
我调整了当前树形图的限制。 ordiellipse
会为每个单项课程提供错误信息,但它们是无害的(我必须从这些中清除功能)。