如何使用R包进行KEGG和GO分析

先贴上代码,后面有空的时候来解释:

source("http://bioconductor.org/biocLite.R");biocLite("clusterProfiler")
biocLite("clusterProfiler")
getwd()
setwd("E:/my project/R_project")
library(org.Hs.eg.db)
data(geneList, package="DOSE")
gene <- names(geneList)[abs(geneList) > 2]
gene.df <- bitr(gene, fromType = "ENTREZID",
        toType = c("ENSEMBL", "SYMBOL"),
        OrgDb = org.Hs.eg.db)

#GO analyse
ego_cc <- enrichGO(gene = gene,
                   OrgDb=org.Hs.eg.db,
                   ont = "CC",
                   pAdjustMethod = "BH",
                   minGSSize = 1,
                   pvalueCutoff = 0.01,
                   qvalueCutoff = 0.01,
                   readable = TRUE)
write.table(as.data.frame( ego_cc@result), file="test_CC.txt")
barplot(ego_CC, showCategory=15,title="EnrichmentGO_CC")#条状图,按p从小到大排的

#KEGG analyse
kk <- enrichKEGG(gene = gene,
                 organism ="human",
                 pvalueCutoff = 0.01,
                 qvalueCutoff = 0.01,
                 minGSSize = 1,
                 #readable = TRUE ,
                 use_internal_data =FALSE)
write.table(as.data.frame(kk@result), file="test_kk.txt")

 

你可能感兴趣的:(R,功能富集分析)