柱状图并添加SD差异线

setwd('D:\\12_G4NaK_PEG\\02_peak\\01_peakSDrich')
library(reshape2)
library(ggpubr)
df1<-read.table('1rich_all.txt')
data<-df1[,c(1,2,6,7)]
colnames(data)<-c('region','sample','value','se')
unique(data$sample)
data$sample<- factor(data$sample,
                     levels= c('Common','K+PEG_spe',
                               'Na+PEG_spe'),ordered = TRUE)
data$region<- factor(data$region,
                     levels= c('Promoter',"5'UTR",'Exon','Intron',"3'UTR",'Downstream','Intergenic'),ordered = TRUE)
head(data)
> head(data)
      region sample     value          se
1      3'UTR Common 0.3527320 0.006010641
2      5'UTR Common 3.4914900 0.135435238
3 Intergenic Common 0.8705570 0.009819727
4 Downstream Common 0.8664667 0.009967259
5       Exon Common 0.6716043 0.004786839
6     Intron Common 0.7460300 0.004904233
ggplot(data,aes(x=region,y=value,fill=sample))+
  geom_bar(stat="identity",width = 0.7,
           position=position_dodge(0.8))+
  geom_errorbar(aes(ymax=value+se,ymin=value-se),
                position=position_dodge(0.8),width=0.5,size=1)+
  scale_fill_brewer(type="seq",palette="Set2")+
  guides(fill = guide_legend(title = ''))+theme_classic()+
  geom_hline(aes(yintercept=1),colour='#990000',linetype='dashed')+
  ylab('Fold enrichment')+xlab('')+labs(title ='G4 Peaks')+
  theme(axis.title = element_text(face = "bold",
                                  size = "14",color = "black"),
        axis.text.x = element_text(face = "bold",color = "black",angle = 45,
                                   size = 12,  hjust = 1, vjust = 1),
        axis.text.y = element_text(face = "bold",size =12,color = "black"),
        strip.text.y = element_text(face = 'bold',colour = 'black'),
        strip.text.x = element_text(face = 'bold',colour = 'black'),
        legend.text = element_text(size = 10,face = "bold"),
        legend.title = element_text(size = 10,
                                    face = "bold"),
        legend.position = c(0.9,0.8),
        panel.grid.major.y = element_blank(),
        panel.grid.minor.y = element_blank(),
        panel.grid.major.x = element_blank(),
        panel.grid.minor.x = element_blank(),
        axis.line = element_line(size=1, colour = "black") ,
        plot.title = element_text(lineheight=.8, face="bold", hjust=0.5, size =16),) 

结果类似下图:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值