By wangjing, 30 July, 2025 Forums Researches https://kdocs.cn/l/cizTsdLam377 # 加载包 ##GO富集分析 library… # 加载包 ##GO富集分析 library(clusterProfiler) library(tidyverse) # 读取基因列表 gene_list <- read.table("/Users/wangjing/Desktop/geneId_1_2.txt", header = FALSE, stringsAsFactors = FALSE) gene_ids <- gene_list$V1 # 读取 GO 注释文件 go_data <- read.table("/Users/wangjing/Desktop/KNX_hap1.gene2GOterm.txt", sep = "\t", header = TRUE, quote = "") # 构建 TERM2GENE 和 TERM2NAME go_term2gene <- go_data[, c(2, 1)] # GO_ID 对应 GeneID go_term2name <- go_data[, c(2, 3)] # GO_ID 对应描述 # 运行 GO 富集 go_enrich <- enricher(gene = gene_ids, pvalueCutoff = 0.01, pAdjustMethod = "BH", TERM2GENE = go_term2gene, TERM2NAME = go_term2name) # 保存结果 write.csv(as.data.frame(go_enrich), "/Users/wangjing/Desktop/GOenrichment.csv", row.names = FALSE) # 可视化 barplot(go_enrich, showCategory = 20) dotplot(go_enrich, showCategory = 20) Log in or register to post comments
# 加载包 ##GO富集分析 library… # 加载包 ##GO富集分析 library(clusterProfiler) library(tidyverse) # 读取基因列表 gene_list <- read.table("/Users/wangjing/Desktop/geneId_1_2.txt", header = FALSE, stringsAsFactors = FALSE) gene_ids <- gene_list$V1 # 读取 GO 注释文件 go_data <- read.table("/Users/wangjing/Desktop/KNX_hap1.gene2GOterm.txt", sep = "\t", header = TRUE, quote = "") # 构建 TERM2GENE 和 TERM2NAME go_term2gene <- go_data[, c(2, 1)] # GO_ID 对应 GeneID go_term2name <- go_data[, c(2, 3)] # GO_ID 对应描述 # 运行 GO 富集 go_enrich <- enricher(gene = gene_ids, pvalueCutoff = 0.01, pAdjustMethod = "BH", TERM2GENE = go_term2gene, TERM2NAME = go_term2name) # 保存结果 write.csv(as.data.frame(go_enrich), "/Users/wangjing/Desktop/GOenrichment.csv", row.names = FALSE) # 可视化 barplot(go_enrich, showCategory = 20) dotplot(go_enrich, showCategory = 20)
# 加载包 ##GO富集分析 library…