当前位置:网站首页>KEGG通路的从属/注释信息如何获取
KEGG通路的从属/注释信息如何获取
2022-07-25 20:32:00 【黄思源】
*富集分析经常做,之前只知道GO term有从上到下的层次关系,今天才知道KEGG pathway也有类似的分层关系。
*
起因是我准备更新一下自己的kegg富集结果展示图,之前一直画的这种图,略显朴素了。
正好搜到了这张图,还挺好看的(主要是配色很清新)

这张图并不难(等有空把代码整理出来发给大家),可是这个「kegg pathway annotation」我真没见过呀!去官网看了看,能找到,但没法下载

在朋友圈求助后,费了很大劲才把这个问题解决。中间好几个小伙伴都很热心地给了我帮助,感谢他们!
以下是我整理的KEGG pathway annotation文件的网盘链接,用到的代码和数据也在里面,想改善一下kegg富集图的朋友可以看看。
*链接:https://pan.baidu.com/s/18pwYZGGZSuk2_LGW8_nQFQ 提取码:ihyn (PS: 觉得有用可以给我
*本期推送的第1篇推文点个赞呀,谢谢了!)

整理这个文件的思路如下
浏览器打开这个网页(https://www.genome.jp/kegg/pathway.html),然后查看网页源代码(一般是鼠标右键),就能看到这个:

然后复制粘贴到一个文本文件
kegg_html.txt,删掉前188行左右,后17行左右(删掉的这些行明显不含有用信息),得到kegg_html_copy.txt。然后运行我编写的代码
pre.R就能得到最终表格了
library(tidyverse)
tmp1=readLines("kegg_html_copy.txt")
tmp2=c()
for (li in 1:length(tmp1)) {
if(str_detect(tmp1[li],">[0-9]")) {
tmp2=append(tmp2,tmp1[li])
}
}
###
big_anno=""
small_anno=""
final_lines=c()
for (li in 1:length(tmp2)) {
if (str_detect(tmp2[li],">[0-9]\\. ")) {
tmp_anno=str_extract(tmp2[li],">.*<")
tmp_anno=str_split(tmp_anno,"\\. ")[[1]][2]
tmp_anno=str_split(tmp_anno,"<")[[1]][1]
big_anno=tmp_anno
} else if (str_detect(tmp2[li],">[0-9]\\.[0-9]{1,2} ")) {
tmp_anno2=str_extract(tmp2[li],">.*<")
tmp_anno2=str_replace(tmp_anno2,"^>[0-9]\\.[0-9]{1,2} ","")
tmp_anno2=str_split(tmp_anno2,"<")[[1]][1]
small_anno=tmp_anno2
} else if (str_detect(tmp2[li],">[0-9]{5}")){
element1=str_extract(tmp2[li],">[0-9]{5}")
element1=str_split(element1,">")[[1]][2]
if (!str_detect(tmp2[li],"hsa\\+pathogen")) {
element2=str_extract(tmp2[li],"pathway\\/[a-zA-Z]{2,4}[0-9]{5}")
element2=str_split(element2,"\\/")[[1]][2]
element3=str_extract(tmp2[li],"pathway.*?<") #非贪婪匹配
element3=str_extract(element3,">.*<")
element3=str_split(element3,">")[[1]][2]
element3=str_split(element3,"<")[[1]][1]
} else {
element2="organism:hsa+pathogen"
element3=str_extract(tmp2[li],"hsa\\+pathogen.*?<") #非贪婪匹配
element3=str_extract(element3,">.*<")
element3=str_split(element3,">")[[1]][2]
element3=str_split(element3,"<")[[1]][1]
}
tmp_line=paste(as.character(element1),element2,element3,big_anno,small_anno,sep = ";")
final_lines=append(final_lines,tmp_line)
}else{
print(tmp2[li])
}
}
###
final_df=as.data.frame(final_lines)
colnames(final_df)="V1"
final_df=final_df%>%apply(1, function(x){as.data.frame(str_split(x,";")[[1]])})
final_df=as.data.frame(final_df)
final_df=as.data.frame(t(final_df))
rownames(final_df)=NULL
colnames(final_df)=NULL
colnames(final_df)=c("ID","Pathway Identifier","Pathway","big annotion","small annotion")
###
library(xlsx)
write.xlsx(final_df,file = "kegg_info.xlsx",col.names = T,row.names = F)
边栏推荐
- Clickhouse notes 02 -- installation test clickvisual
- Cloud native guide: what is cloud native infrastructure
- Proxy implements MySQL read / write separation
- The database empties the table data and makes the primary key start from 1
- [cloud native] use of Nacos taskmanager task management
- [today in history] July 19: the father of IMAP agreement was born; Project kotlin made a public appearance; New breakthroughs in CT imaging
- 【ONNX】pytorch模型导出成ONNX格式:支持多参数与动态输入
- Network protocol: TCP part2
- 10.< tag-动态规划和子序列, 子数组>lt.53. 最大子数组和 + lt.392. 判断子序列 dbc
- Leetcode customs clearance: hash table six, this is really a little simple
猜你喜欢

10.< tag-动态规划和子序列, 子数组>lt.53. 最大子数组和 + lt.392. 判断子序列 dbc
![Vulnhub | dc: 6 | [actual combat]](/img/7e/de7d5b56724bde5db2bb8338c35aa8.png)
Vulnhub | dc: 6 | [actual combat]

PMP practice once a day | don't get lost in the exam -7.25

各厂商网络虚拟化的优势

Introduction to several scenarios involving programming operation of Excel in SAP implementation project
![[advanced mathematics] [4] indefinite integral](/img/4f/2aae654599fcc0ee85cb1ba46c9afd.png)
[advanced mathematics] [4] indefinite integral

「分享」DevExpress ASP.NET v22.1最新版本系统环境配置要求
![[advanced mathematics] [1] function, limit, continuity](/img/c5/f9fd3814a61d0fba24b37253c7e51c.png)
[advanced mathematics] [1] function, limit, continuity

test
![[matlab] download originality documents based on oil monkey script and MATLAB](/img/c2/1788b758778ba73dd02fb0d006869e.png)
[matlab] download originality documents based on oil monkey script and MATLAB
随机推荐
网络协议:TCP Part2
Socket error Event: 32 Error: 10053. Connection closing...Socket close
Timing analysis and constraints based on xlinx (1) -- what is timing analysis? What are temporal constraints? What is temporal convergence?
Docker 搭建 Redis Cluster集群
[today in history] July 18: Intel was founded; The first photo was posted on the world wide web; EBay spins off PayPal
2022.7.24-----leetcode.1184
9.< tag-动态规划和子序列, 子数组>lt.718. 最长重复子数组 + lt.1143. 最长公共子序列
Recommended system topic | Minet: cross domain CTR prediction
[advanced mathematics] [6] differential calculus of multivariate functions
【ONNX】pytorch模型导出成ONNX格式:支持多参数与动态输入
[today in history] July 1: the father of time-sharing system was born; Alipay launched barcode payment; The first TV advertisement in the world
[Infographics Show] 248 Public Domain Name
[today in history] July 19: the father of IMAP agreement was born; Project kotlin made a public appearance; New breakthroughs in CT imaging
【高等数学】【5】定积分及应用
【高等数学】【4】不定积分
[cloud native | learn kubernetes from scratch] VIII. Namespace resource quotas and labels
DIY个人服务器(diy存储服务器)
[tensorrt] trtexec tool to engine
Chinese son-in-law OTA Ono became the first Asian president of the University of Michigan, with an annual salary of more than 6.5 million!
Network protocol: TCP part2