Showing posts with label pathway. Show all posts
Showing posts with label pathway. Show all posts

Friday, June 08, 2018

Download all KEGG pathway KGML files for SPIA analysis

Most people know the KEGG pathway, but not everyone knows that it costs at least $2000 to subscribe to its database. If you want to save the cost a bit, you can manually download the KEGG pathway KGML files and install them in SPIA. Here I have a workaround to download all KEGG pathway files using their REST API.
## Claim: this is my personal trick. I recommend people subscribe to their KEGG FTP download to support the authors.

# change folder to the folder where your SPIA installed, for example in my Mac
cd /Library/Frameworks/R.framework/Versions/4.0/Resources/library/SPIA
# download all XML and png files for all human pathway
curl -s http://rest.kegg.jp/list/pathway/hsa | awk '{split($1,a,":"); print "curl -s http://rest.kegg.jp/get/"a[2]"/kgml -o extdata/keggxml/hsa/"a[2]".xml"}' | bash

curl -s http://rest.kegg.jp/list/pathway/hsa | awk '{split($1,a,":"); print "curl -s http://rest.kegg.jp/get/"a[2]"/image -o extdata/keggxml/hsa/"a[2]".png"}' | bash

# then switch to R console
setwd("/Library/Frameworks/R.framework/Versions/3.4/Resources/library/SPIA")
library(SPIA)
makeSPIAdata(kgml.path=system.file("extdata/keggxml/hsa",package="SPIA"),organism="hsa",out.path="./extdata")

Done!