您现在的位置是:首页 > 电脑 > 

给定基因集gene list后,R语言GO、KEGG分析

2025-07-21 16:36:26
给定基因集gene list后,R语言GO、KEGG分析 一.把准备好的gene名字复制到txt文件中(此时是symbol格式的gene名,如下,得到gene.txt 二.安装所需包 if (!requireamespace(BiocManager, quietly = TRUE)) install.packages(&#

给定基因集gene list后,R语言GO、KEGG分析

一.把准备好的gene名字复制到txt文件中(此时是symbol格式的gene名,如下,得到

二.安装所需包

if (!requireamespace(BiocManager, quietly = TRUE))   
install.packages(BiocManager)
BiocManager::install(clusterProfiler)
library(clusterProfiler)
BiocManager::install(AnnotationHub)
library(AnnotationHub) 
BiocManager::install(org.db)
library(org.db)   
library(ggplot2)
BiocManager::install(DOSE)
library(DOSE)

三.ID转换


#1 读取第一步中的txt文件
go_ythdf2 <- (,sep= )#读取
go_ythdf2 <- t(go_ythdf2)#从列 变为行
#2 读取db包
keytypes(org.db)
# 将gene_symbol转换为ESEMBL
go_ythdf2_id_trance <- bitr(go_ythdf2,fromType = SYMBOL,toType = ESEMBL,OrgDb = org.db,drop = T)
#4 提取ESEMBL的信息
f <- as.data.frame(go_ythdf2_id_trance[,2])
colnames(f)[1] <- 		
colnames(f) <- V1
EG2Ensembl=toTable(org.)
f=f$V1  
geneLists=data.frame(ensembl_id=f)
results=merge(geneLists,EG2Ensembl,by=	ensembl_id	,all.x=T)
id=(results$gene_id)

四.GO分析

#1 GO分析
All <- enrichGO(OrgDb=org.db, gene = id, ont = ALL,  readable= TRUE) 
save(All,file = 	All.rda	)
#如果要单独绘制BP,CC,MF,把ont=ALL修改成自己想要的类型即可#2 画图,气泡图#2.1 气泡图,显示前10项,标题为“Enrichment GO Up-Gene”
dotplot(All,showCategory=10,title=Enrichment GO Up-Gene)scale_color_gradient(low = red, high = blue)theme_bw() #2.2 柱状图,显示前20项,标题为“Enrichment GO Top20”
barplot(All, showCategory=20,title=EnrichmentGO)  # 2. BP,MF,CC分别显示(要加载DOSE包)
p1 <- dotplot(All,split=OTOLOGY,title=Enrichment GO Up-Gene) facet_grid(OTOLOGY~.,scale=free)theme_bw()
p1
ggsave(	GO.pdf	,p1,width = 8,height = 10)# 只显示8个通路
# p <- dotplot(All,split=OTOLOGY,showCategory=8,title=Enrichment GO Up-Gene) facet_grid(OTOLOGY~.,scale=free)
#   theme_bw()
# p
# ggsave(	GO8.pdf	,p,width = 8,height = 10)#三个单独出图
BP <- enrichGO(OrgDb=org.db, gene = id, ont = BP,  readable= TRUE) 
p10 <- dotplot(BP,showCategory=10,title=Enrichment GO Up-Gene-BP)scale_color_gradient(low = red, high = blue)theme_bw() 
ggsave(	BF10.pdf	,p10,width = 8,height = 6)MF <- enrichGO(OrgDb=org.db, gene = id, ont = MF,  readable= TRUE) 
p12 <- dotplot(MF,showCategory=10,title=Enrichment GO Up-Gene-MF)scale_color_gradient(low = red, high = blue)theme_bw() 
ggsave(	MF10.pdf	,p12,width = 8,height = 6)CC <- enrichGO(OrgDb=org.db, gene = id, ont = CC,  readable= TRUE) 
p14 <- dotplot(CC,showCategory=10,title=Enrichment GO Up-Gene-CC)scale_color_gradient(low = red, high = blue)theme_bw() 
ggsave(	CC10.pdf	,p14,width = 8,height = 6)

 

 

 

 五、KEGG分析

#1KEGG分析
KEGG <- enrichKEGG(gene= id, organism  = 	hsa	, pvalueCutoff = 0.05) 
#2 画图,第一种做法,气泡图,设置字体大小
dotplot(KEGG,font.size=12)
# 画图,第二种做法,柱状图
barplot(KEGG,font.size=8) 
#4 画图,第三种做法,泡泡图
dotplot(KEGG,showCategory=10,title=Enrichment KEGG Top10) 
#4.1 调节标题,字体,泡泡大小
p2 <- dotplot(KEGG, font.size=8, showCategory=10, title=Enrichment KEGG Top10)  scale_size(rang=c(5.20))
p2
ggsave(	KEGG10.pdf	,p2,width = 6,height = 6)

这样分析就结束啦,放上gene list练手

链接:
提取码:mr4o

#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格

本文地址:http://www.dnpztj.cn/diannao/880941.html

相关标签:无
上传时间: 2024-04-17 07:00:47
留言与评论(共有 7 条评论)
本站网友 整形外科医生
13分钟前 发表
title=Enrichment GO Up-Gene-MF)scale_color_gradient(low = red
本站网友 浮小麦
18分钟前 发表
high = blue)theme_bw() ggsave( CC10.pdf
本站网友 药物滥用是指
28分钟前 发表
install(org.db) library(org.db) library(ggplot2) BiocManager
本站网友 哥哥和妹妹做
2分钟前 发表
font.size=12) # 画图,第二种做法,柱状图 barplot(KEGG
本站网友 吉安团购
22分钟前 发表
high = blue)theme_bw() ggsave( CC10.pdf
本站网友 温州万象城
15分钟前 发表
scale=free)theme_bw() p1 ggsave( GO.pdf