过表征分析(Over Representation Analysis,ORA)(Boyle et al. 2004)是一种广泛使用的基因富集分析方法,用于确定已知的生物学功能或过程是否在实验得到的基因列表中被过度表达。
library(org.Hs.eg.db) #人类注释数据库
library(clusterProfiler)
library(topGO)
library(Rgraphviz)
padj = 0.01 # 自定义
foldChange= 2 # 自定义
# data为limma差异表达分析的结果
signif_dat = data[(data$adj.P.Val < padj) & abs(data$logFC)>=foldChange,]
signif_dat = signif_dat[order(signif_dat$logFC),]
head(signif_dat)
# bitr {clusterProfiler}
gene.df <- bitr(signif_dat$symbol, fromType = "SYMBOL",
toType = c("ENTREZID"),
OrgDb = org.Hs.eg.db)
ENTREZID_lst <- gene.df$ENTREZID
注:进行ORA分析,输入数据是差异表达基因的$ENTREZID列表。
#GO analyse
ego <- enrichGO(gene = ENTREZID_lst,
OrgDb=org.Hs.eg.db,
pvalueCutoff = 0.01,
qvalueCutoff = 0.01,
readable = TRUE)
# ont = "MF",默认
# ont: One of "BP", "MF", and "CC" subontologies, or "ALL" for all three.
#class(ego)
#head(ego)
# GO富集结果写入文件
write.csv(as.data.frame(ego@result), file="GO_enrich_result.csv")
# GO富集结果作图
dotplot(ego,showCategory=10,title="Enrichment GO Top10") #泡泡图
barplot(ego, showCategory=15,title="EnrichmentGO") #柱状图
plotGOgraph(ego) #GO图,看不清楚可以尝试左上角另存为pdf
#KEGG analyse
kegg <- enrichKEGG(gene = ENTREZID_lst,
organism ="hsa",
pvalueCutoff = 0.05,
qvalueCutoff = 0.05,
#readable = TRUE ,
use_internal_data =FALSE)
#use_internal_data =TRUE, 下载最新的在线版本的KEGG数据进行富集分析,
# 需要安装KEGG.db
# KEGG富集结果写入文件
write.table(as.data.frame(kegg@result), file="KEGG_enrich_result.csv")
dotplot(kegg,showCategory=10,title="Enrichment KEGG Top10") # 画气泡图
barplot(kegg, showCategory=10,title="EnrichmentGO") #柱状图
# 显示通路图,kegg网页,便于查看
browseKEGG(kegg,'hsa04061')
clusterProfiler
使用clusterProfiler进行富集分析 - 简书