How to draw circle in PCoA results?

倾然丶 夕夏残阳落幕 提交于 2019-12-09 21:27:56

问题


I have results with PC1 and PC2 for all the samples, so that I can draw a scatter plot using PC1 as x and PC2 as y.

Now the samples are labeled by another variable, let's say type indicating which sample is case or control. How can I draw a plot as above, with circles covering the responding type.

Actually, I am using vegan package. I can draw a plot with metaMDS and ordiplot, but don't know how to make a circle as above. I have tried to read the tutorial, but still have no idea.


回答1:


I was able to draw this with ade4.

xy <- cbind.data.frame(x = runif(200, -1, 1), y = runif(200, -1, 1))
posi <- factor(xy$x > 0) : factor(xy$y > 0)
coul <- c("black", "red", "green", "blue")

library(ade4)
pca <- princomp(xy)
s.class(pca$scores[, 1:2], fac = posi, cell = 2, axesell = FALSE, csta = 0, col = coul, clabel = FALSE)



来源:https://stackoverflow.com/questions/34389869/how-to-draw-circle-in-pcoa-results

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!