酷酷的boxplot(现学现卖系列)

2019-01-08  本文已影响20人  医科研
####诚然,R是个巨大的宝库,学了点皮毛就觉得自己要当艺术家了,今后凡学术论文都要酷,当然切不可金玉其外,败絮其中。
library(ggpubr)
library(ggplot2)
##设定比较分组
my_comparisons <- list(c("high", "low"))
ggboxplot(marker_exp,       ##data
           x="risk",        ##x
          y="LOC101927359", ##y
          title="LOC101927359",
          ylab = "Expression", #纵坐标名称
          color = "risk", palette = "jco",add = "jitter")+
          stat_compare_means(method = "t.test",##统计方法
         comparisons =  my_comparisons)##比较
                   
         
##绘图1-1
box1<-ggboxplot(marker_exp, x="risk", y=c("LOC101927359","TBX2","C2orf61"), 
           combine = TRUE,##多个组合
          fill = "risk",ylab = "Expression")+
          scale_fill_brewer(palette="Dark2")+ 
          stat_compare_means( method = "t.test",label = 
          "p.signif",comparisons = my_comparisons)##星号设置
          #theme_gray(base_size = 14)##background
box1
##
box2<-ggboxplot(marker_exp, x="risk", y=c("LOC101927359","TBX2","C2orf61"), 
                combine = TRUE,
                fill = "risk",ylab = "Expression")+
                scale_fill_brewer(palette="Dark2")+
                stat_compare_means( method = "t.test",#检验方法
                                    label = "p.signif",#星号
                                    comparisons = my_comparisons)+
               theme_gray()
上一篇下一篇

猜你喜欢

热点阅读