Introduction
首先,介绍下,为什么要抓取KEEG数据库呢,而且为什么要用KEEGREST这个包呢,下面是简单的介绍
The interface to KEGGREST is simpler and in some ways more powerful than KEGGSOAP; however, not all the functionality that was available through the SOAP API has been exposed in the REST API. If and when more functionality is exposed on the server-side, this package will be updated to take advantage of it.
同时,还有一个原因,因为是学生党,没有公司支撑,所以,想拿到最新的KEEG的数据库信息可以说是天方夜谭,因为需要钱!才能给你permission!!!
而且免费的MsigDb提供的版本实在是太老了,所以自己动手风衣足食,自己手动利用新的API扒出一个新一点的KEEG database来进行GSEA的相关信息。那么开搞!
Ready
利用Rstdio安装好下面的几个包msigdb、dplyr、KEGGREST、stringi、stringr以及相关的依赖
GO
library(msigdb)
library(dplyr)
library(KEGGREST)
library(stringi)
library(stringr)
res <- keggList("pathway", "hsa") #得到人的所有KEEG pathway的信息
pathwayid<-names(res)
saveList<-list()
for (i in c(1:length(res))) {
# i=82
pathwayName<-str_sub(res[i],1,str_length(res[i])-23)#截取pathway的名字
test1<-pathwayid[i]
pathgetId<-str_sub(test1,6,str_length(test1))#截取pathway的代号
gs<-keggGet(pathgetId)#通过代号找到这条pathway
geneName<-strsplit(as.character(gs[[1]]$GENE),';')
genes <- unlist(lapply(gs[[1]]$GENE,function(x) strsplit(x,';')[[1]][1]))##获取这条pathway中的gene symbol
PathwayGene<-genes[1:length(genes)%%2 ==0]%>%as.character()
saveList[pathwayName]<-list(PathwayGene)#将这条pathway写到list中,保存起来
}
#最后写成GMT文件,然后可以作为输入进行GSEA了
gmtProfile<-list()
gmtProfile$genesets<-saveList
gmtProfile$geneset.names<-names(saveList)
write.gmt(gmtProfile,'KeegData.gmt')
我整理的地址 https://github.com/Soulnature/KEEG-data,觉得可以,给个小星星哦
网友评论