R语言中gene symbol 转换为ENTREZID, clusterprofile富集分析

001、

genes <- read.table("genes.txt")                         ## 读取基因symbol
head(genes)
tail(genes)
genes <- genes[genes != "NA_NA" & genes != "unknow",, drop = FALSE]       ## 去除无效信息(可选)
genes_list <- unique(genes$V1)                                            ## 去重
genes_list

library(org.Hs.eg.db)
keytypes(org.Hs.eg.db) 

library(clusterProfiler)
#ID转换,把gene_symbol转换成ENTREZID。
SYMBOL2ENTREZID <- bitr(genes_list, fromType = "SYMBOL",toType = "ENTREZID",OrgDb = "org.Hs.eg.db",drop = T)      ## 由symbol转换为ENTRZID
class(SYMBOL2ENTREZID)
dim(SYMBOL2ENTREZID)

enrich_result <- enrichGO(gene = SYMBOL2ENTREZID$ENTREZID,                                                        ## 富集分析
                          org.Hs.eg.db,
                          keyType = "ENTREZID",
                          ont = "ALL",
                          pAdjustMethod = "BH",
                          minGSSize = 10, 
                          maxGSSize = 500,
                          pvalueCutoff = 1, 
                          qvalueCutoff = 1,
                          readable = TRUE)
enrich_result


write.csv(enrich_result,"enrich_result.csv",row.names = T)                                                        ## 保存富集分析结果

 

 。

 

posted @ 2024-10-04 11:51  小鲨鱼2018  阅读(45)  评论(0编辑  收藏  举报