rm(list=ls())
library(RColorBrewer)
library(calibrate)
library(genefilter)
library(gplots)
library(rio)
library(ggsci)
library(eoffice)
library(ggplot2)
library(scatterplot3d)
df=import("pca/snp.pca.csv",header=T)
color <-c("#E64B35FF","#4DBBD5FF","#00A087FF","#3C5488FF","#F39B7FFF","#8491B4FF","#B09C85FF")
df$group=factor(df$group)
colors <- color[as.numeric(df$group)]
p=ggplot(data=df,mapping=aes(pc1,pc3))
p=df
pp=scatterplot3d(p[,3:5], color=colors,angle=65, pch=16, axis = TRUE,label.tick.marks = TRUE,xlab="PC1(31.2%)",ylab="PC2(29.6%)",zlab="PC3(22.7%)")
legend("right", legend=levels(p$group), col=c("#E64B35FF","#4DBBD5FF","#00A087FF","#3C5488FF",
"#F39B7FFF","#8491B4FF","#B09C85FF"), pch=16, xpd=T, horiz=F)#
text(pp$xyz.convert(p[,3:5]),labels=p$sample,cex=0.4,col = colors,adj=c(1,-1,font=2))#给散点加文字,adj让文字在点上
topptx(filename = "PCA_plot_3d_with_label.pptx")
SNP PCA 3d图绘制代码_R
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...