PCoA根据显着性水平(ggplot2,ellipse)

时间:2015-05-16 23:24:40

标签: pca ellipse drawellipse

我需要你的帮助人员。我想基于95%显着性水平在PCoA图中围绕我的点绘制椭圆,最好是。如果我只根据数据"时间"它也会工作。这是我的数据集

structure(list(Replicate = structure(c(16L, 17L, 23L, 24L, 22L, 
8L, 6L, 11L, 18L, 4L, 1L, 7L, 27L, 12L, 14L, 25L, 10L, 5L, 26L, 
9L, 20L, 13L, 3L, 19L, 15L, 21L, 2L), .Label = c("BL_0", "BL_16", 
"BL_31", "BL_6", "BL_64", "BL_9", "P1_0", "P1_13", "P1_16", "P1_3", 
"P1_31", "P1_6", "P1_64", "P1_9", "P2_0", "P2_13", "P2_16", "P2_31", 
"P2_6", "P2_64", "P2_9", "P3_13", "P3_16", "P3_31", "P3_6", "P3_64", 
"P3_9"), class = "factor"), Type = structure(c(2L, 2L, 2L, 2L, 
2L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 
2L, 2L, 1L, 2L, 2L, 2L, 1L), .Label = c("Control", "Oil_incubation"
), class = "factor"), Time = c("13", "16", "16", "31", "13", 
"13", "9", "31", "31", "6", "0", "0", "9", "6", "9", "6", "3", 
"64", "64", "16", "64", "64", "31", "6", "0", "9", "16"), Coord.1 = c(0.21836, 
0.21572, 0.18982, -0.018254, 0.22034, 0.21312, -0.21268, 0.067738, 
0.084045, -0.18963, -0.29999, -0.30367, 0.17732, 0.12072, 0.18748, 
0.10258, -0.14886, -0.24779, -0.041936, 0.20202, -0.15778, 0.02018, 
-0.23429, 0.14379, -0.30149, 0.20963, -0.2165), Coord.2 = c(-0.087942, 
-0.056834, -0.010958, 0.21897, -0.082826, -0.078938, -0.15756, 
0.29455, 0.30797, -0.15886, -0.096771, -0.11315, -0.084762, -0.17144, 
-0.1059, -0.16748, -0.17394, -0.052203, 0.34899, -0.03522, 0.51834, 
0.35924, -0.0039365, -0.082649, -0.09268, -0.088414, -0.1456)), .Names = c("Replicate", 
"Type", "Time", "Coord.1", "Coord.2"), row.names = c(NA, -27L
), class = "data.frame")

这是我使用的代码:

PCoA <- read.delim(file.choose(), header=T)
attach(PCoA)
PCoA$Time <- as.character(PCoA$Time)
cols <- c("0" = "red","3" = "blue","6" = "brown", "9" = "hotpink", "13" = "orange","16" = "olivedrab","31" = "azure3", "64" = "purple")
ggplot(PCoA, aes(x=Coord.1, y=Coord.2, shape=Type, colour=Time)) + scale_colour_manual(values = cols, breaks=c("0","3","6","9","13","16","31","64")) + geom_point(size=7) + xlab("PC1 (73.7%)") + ylab("PC2 (17.3%)") + geom_hline(aes(yintercept=0)) + geom_vline(aes(xintercept=0)) + theme(plot.title = element_text(size=30,lineheight=.8, vjust=1, family="Bauhaus 93"), axis.title.x = element_text(size=16, vjust=-0.35), axis.title.y = element_text(size=16, vjust=0.5)) + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.background = element_blank(), axis.line = element_line(colour = "white"))

谢谢, 杰尼

0 个答案:

没有答案
相关问题