服务热线
178 0020 3020
#设置当前工作目录,所下载的数据或者生成的数据都在如下目录下
setwd("D:/geo/GSE70689/")
#这里计算CBD_LPS与LPS组之间的差异基因富集分析
data = read.csv("CBD_LPS-LPS_defference_expression_genes.csv", header = T)
DEG =as.character(data$X)
library(clusterProfiler)
library(org.Mm.eg.db)
#将symbol转为entrezid
entrezid <- select(org.Mm.eg.db,keys = as.vector(DEG),columns = c("GENENAME","SYMBOL","ENTREZID"),keytype = "SYMBOL")
gle = as.vector(entrezid$ENTREZID)
gle = gle[!is.na(gle)]
#GO富集分析
go <- enrichGO(gle,OrgDb = org.Mm.eg.db, ont='ALL', pAdjustMethod = 'BH', pvalueCutoff = 0.05, qvalueCutoff = 0.2, keyType = 'ENTREZID')
#GO中BP的数目
dim(go[go$ONTOLOGY=='BP',])
#GO中CC的数目
dim(go[go$ONTOLOGY=='CC',])
#GO中MF的数目
dim(go[go$ONTOLOGY=='MF',])
#输出为PDF,宽9cm,高4cm,根据输出的pdf文件可调整大小
pdf("CBDLPS_LPS_GO.pdf",width=9,height = 4)
dotplot(go,showCategory=10) #展示富集分析前10条
dev.off() #关闭pdf渲染,并写入文件到硬盘
#KEGG通路富集分析
# 其中如果是人类的基因,organism = 'hsa',其他的不需要改变
kegg <- enrichKEGG(gle, organism = 'mmu', keyType = 'kegg', pvalueCutoff = 0.05,pAdjustMethod = 'BH',
minGSSize = 10,maxGSSize = 500,qvalueCutoff = 0.2,use_internal_data = FALSE)
pdf("CBDLPS_LPS_KEGG.pdf",width=8,height = 6)
dotplot(kegg,showCategory=10)
dev.off()
附件