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),)
结果类似下图: