2020-12-05

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轴下面的文本标题

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 0. 基本内容介绍 ggplot2|详解八大基本绘图要素 1. boxplot例子 memory.limit() ...
    南谛走心阅读 626评论 0 0
  • group.B.txt SampleGroup1Group2M3N2ControlMeth_7dM3B2Contr...
    曲凉不见阅读 493评论 0 0
  • 作者:严涛浙江大学作物遗传育种在读研究生(生物信息学方向)伪码农,R语言爱好者,爱开源 ggplot2学习笔记之图...
    Dylan的迪阅读 2,679评论 0 6
  • 写在前面 ggplot2 是一个功能强大且灵活的R包 ,由Hadley Wickham 编写,其用于生成优雅的图...
    Boer223阅读 28,259评论 0 67
  • 0228 1.some refernce materialR CookbookR in Actionggplot2...
    TX_ab85阅读 794评论 0 0