library(dplyr)
library(ggplot2)
library(RColorBrewer)
library(clusterProfiler)
mytheme<- theme(axis.title = element_text(size = 13),
axis.text = element_text(size = 11),
plot.title = element_text(size = 14,
hjust= 0.5,
face= "bold"),
legend.title = element_text(size = 13),
legend.text = element_text(size = 11),axis.text.y = element_blank())
kegg <- enrichKEGG(genelist ,
organism="mmu",
pvalueCutoff=0.1,
pAdjustMethod="BH",
keyType="kegg")
Kegg=as.data.frame(kegg)
#KEGG_result<- mutate(Kegg,RichFactor= Count / as.numeric(sub( "/\\d+", "", BgRatio)))
top20<-KEGG_result[1:20,]
top20$text_x <- rep(0.03,20)
top20$pathway <- factor(top20$Description,levels = rev(top20$Description))
p2<- ggplot(data = top20,aes(x = Count, y = pathway))+
geom_bar(aes(fill = -log10(pvalue)), stat = "identity", width = 0.8, alpha = 0.7)+
scale_fill_distiller(palette = "YlOrRd", direction = 1)+
labs(x = "Number of Gene", y = "pathway", title = "KEGG enrichment barplot")+
geom_text(aes(x = text_x,label= pathway),hjust= 0)+
mytheme
p2
ggsave("KEGG.pdf",width = 6,
height = 8)