clusterProfiler是進(jìn)行富集分析最常用的工具着饥。在我們進(jìn)行差異分析得到很多差異基因之后草讶,我們可以分別對(duì)上調(diào)的基因和下調(diào)的基因進(jìn)行差異分析
library(clusterProfiler)
library(org.Hs.eg.db)
x <- genes
eg <- bitr(x, fromType="SYMBOL", toType=c("ENTREZID","ENSEMBL"), OrgDb="org.Hs.eg.db"); head(eg)
genelist <- eg$ENTREZID
genelist <- genelist[-duplicated(genelist)]
go <- enrichGO(genelist, OrgDb = org.Hs.eg.db, ont='ALL',pAdjustMethod = 'BH',pvalueCutoff = 0.05,
qvalueCutoff = 0.2,keyType = 'ENTREZID')
barplot(go,showCategory=20,drop=T)
dotplot(go,showCategory=50)
還可以繪制GO的網(wǎng)絡(luò)關(guān)系圖,但是值得注意的是這里的數(shù)據(jù)只能是富集一個(gè)GO通路(BP、CC或MF)的數(shù)據(jù)
go.BP <- enrichGO(genelist, OrgDb = org.Hs.eg.db, ont='BP',pAdjustMethod = 'BH',
pvalueCutoff = 0.05, qvalueCutoff = 0.2,keyType = 'ENTREZID')
plotGOgraph(go.BP)
使用其他數(shù)據(jù)庫莹痢,以Hallmark為例:
library(clusterProfiler)
library(org.Hs.eg.db)
library(msigdbr)
DEG_edgeR <- readxl::read_xlsx('downstream_data/DE/fibrocyte_Fibrosis_vs_others.xlsx')
x <- (DEG_edgeR %>% filter(logFC > 0, PValue < 0.15))$gene
x
eg <- clusterProfiler::bitr(x, fromType = "SYMBOL", toType = c("ENTREZID", "ENSEMBL"), OrgDb = "org.Hs.eg.db")
genelist <- eg$ENTREZID
genelist <- genelist[-duplicated(genelist)]
m_t2g <- msigdbr(species = "Homo sapiens", category = "H") %>%
dplyr::select(gs_name, entrez_gene)
go <- enricher(
genelist,
pvalueCutoff = 1,
pAdjustMethod = "fdr",
qvalueCutoff = 1,TERM2GENE = m_t2g,
)
dotplot(go, showCategory = 20)