inputFile="M singleGeneClinical.txt"
setwd("/Users/zhongyue/Desktop/生物信息学/13.mergeclinical")
rt=read.table(inputFile,sep="\t",header=T,check.names=F)
head(rt)
compared<-list(c("M0","M1"))
clinical="M"
gene="MAL2"
library(ggplot2)
library(ggsignif)
library(ggpubr)
outPdf=paste0(gene,".",clinical,".pdf")
pdf(file=outPdf,
width=9,
height=6,)
p<-ggplot(data=rt,aes(M,MAL2))+geom_boxplot(aes(fill=M),width=0.5)+theme_classic()+scale_fill_discrete(name="M classificaition")#修改图例的名字
p+theme(legend.title=element_text(size=14,face="bold"),axis.title=element_text(size=12,face="bold"),axis.text.y=element_text(size=12,face="bold"),axis.text.x=element_text(size=12,face="bold"),legend.position="top",plot.title = element_text(size = 16,hjust=0.5))+ggtitle("MAL2 expression group by M classificaition")+stat_compare_means(method = "kruskal.test",label = "p.format",label.y = 500,size=6,face="bold")+xlab("M classificaition")+ylab("MAL2 expression")+ylim(0,500)#要放同一行,两组用wilcox.test
dev.off()#axis.text是xy轴的刻度和字体,axis.title是xy轴下面的文本标题