PCA图像可以直观地看到群体分群的情况。首先需要使用plink在服务器上得到PCA结果:
rm(list = ls()) #清除工作台
library(ggplot2)
library(RColorBrewer) #加载包
data <- read.table("SNP.eigenvec",sep = "\t",header = T) #读取在服务器上跑出来的eigenGWAS结果
#开始作图
ggplot(data,aes(x=pc1,y=pc2,color=species))+ geom_point()
tiff(filename = "species.tif", width = 30, height = 16, units = "cm", compression = "lzw", res = 600)
ggplot(data,aes(x=pc1,y=pc2,color=species))+
geom_point()+
theme_bw() +
theme(panel.border=element_blank(),panel.grid.major=element_blank(),panel.grid.minor=element_blank(),axis.line= element_line(colour = "black"))
dev.off()
接着就可以得到这样的图像: