GO富集分析
library(clusterProfiler)
GO_database <- 'org.Hs.eg.db' #GO分析指定物种,物种缩写索引表详见http://bioconductor.org/packages/release/BiocViews.html#___OrgDb
gene <- bitr(Top30_Gene,fromType = 'SYMBOL',toType = 'ENTREZID',OrgDb = GO_database,drop = TRUE) #Top30_Gene为要富集的基因集合
GO<-enrichGO( gene$ENTREZID,#GO富集分析
OrgDb = GO_database,
keyType = "ENTREZID",#设定读取的gene ID类型
ont = "ALL",#(ont为ALL因此包括 Biological Process,Cellular Component,Mollecular Function三部分)
pvalueCutoff = 0.05,#设定p值阈值
qvalueCutoff = 0.2,#设定q值阈值
readable = T)
GO <- as.data.frame(GO)
rownames(GO) <- 1:nrow(GO)
GO$order=factor(rev(as.integer(rownames(GO))),labels = rev(GO$Description))
#展示GO富集分析Top5的富集信息
Go<- GO %>%
group_by(ONTOLOGY) %>%
arrange(pvalue) %>%
slice_head(n = 5)
#画图
library(ggplot2)
pdf("GO_Top30.pdf",width=7,height=5)
ggplot(Go,aes(y=order,x=-log(pvalue),fill=p.adjust))+
geom_bar(stat = "identity",width=0.7)+####???ӿ???
#coord_flip()+##?ߵ???????
scale_fill_gradient(low = "red",high ="yellow" )+#??ɫ?Լ????Ի?
labs(title = "The Most Enriched GO Terms",
x = "-log(p.value)",
y = "Pathways")+
theme(axis.title.x = element_text(face = "bold",size = 16),
axis.title.y = element_text(face = "bold",size = 16),
legend.title = element_text(face = "bold",size = 16))+
facet_grid(ONTOLOGY~., scale="free")+ #按照ONTOLOGY的类别分面板进行展示
theme_bw()
dev.off()
#去掉网格线(往上面加)
theme_bw() +
theme(panel.grid.major=element_line(colour=NA),
panel.background = element_rect(fill = "transparent",colour = NA),
plot.background = element_rect(fill = "transparent",colour = NA),
panel.grid.minor = element_blank())
KEGG富集分析
标签:富集,分析,title,element,theme,GO,fill From: https://www.cnblogs.com/huaguang13/p/17845469.html