![](https://img.haomeiwen.com/i22464412/7a37a3488281260f.png)
#把数据转换成ggplot2输入文件
data=melt(expClu, id.vars=c("geneCluster"))
colnames(data)=c("geneCluster", "Gene", "Expression")
![](https://img.haomeiwen.com/i22464412/50c5eee3c3c50878.png)
#设置颜色
#bioCol=c("#0066FF","#FF9900","#FF0000","#6E568C","#7CC767","#223D6C","#D20A13","#FFD121","#088247","#11AA4D")
bioCol=c("#1c79c0","#0dd3ff","#0389ff")
#bioCol=c("#3be8b0","#ffb900","#fc636b")
bioCol=bioCol[1:length(levels(factor(data[,"geneCluster"])))]
#绘制箱线图
p=ggboxplot(data, x="Gene", y="Expression", color = "geneCluster",#根据分型结果定义颜色
xlab="",#x轴名称
ylab="Gene expression",#y轴名称
legend.title="geneCluster",#图例标题
palette = bioCol,#颜色
width=1)
p=p+rotate_x_text(60)#x轴倾斜角度
#统计分析
p1=p+stat_compare_means(aes(group=geneCluster),
symnum.args=list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c("***", "**", "*", " ")),
label = "p.signif")
#输出箱线图
pdf(file="boxplot.pdf", width=9, height=6)
print(p1)#打印
dev.off()
![](https://img.haomeiwen.com/i22464412/d6376f1d541a57b0.png)
网友评论