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_listlibrary(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_resultwrite.csv(enrich_result,"enrich_result.csv",row.names = T) ## 保存富集分析结果
。