Using the WikiPathways API in R

[This article was first published on chem-bla-ics, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Colored pathways created with
the new R package.
Earlier this week there was a question on the WikiPathways mailing list about the webservices. There are older SOAP webservices and newer REST-like webservices, which come with this nice Swagger webfront set up by Nuno. Of course, both approaches are pretty standard and you can use them from basically any environment. Still, some personas prefer to not see technical issues: “why should I know how an car engine works”. I do not think any scholar is allowed you use this argument, but alas…

Of course, hiding those details is not so much of an issue, and since I have made so many R packages in the past, I decided to pick up the request to create an R package for WikiPathways: rWikiPathways. It is not feature complete yet, and not extensively tested in daily use yet (there is a test suite). But here are some code examples. Listing pathways and organisms in the wiki is done with:
    organisms = listOrganisms()
    pathways = listPathways()
    humanPathways = listPathways(organism="Homo sapiens")
For the technology oriented users, for each pathway, you have access to the GPML source file for each pathway:
    gpml = getPathway(pathway="WP4")
    gpml = getPathway(pathway="WP4", revision=83654)
However, most use will likely be via database identifiers for genes, proteins, and metabolites, called Xrefs (also check out the R package for BridgeDb):
    xrefs = getXrefList(pathway="WP2338", systemCode="S")
    pathways = findPathwaysByXref("HMDB00001", "Ch")
    pathways = findPathwaysByXref(identifier="HMDB00001", systemCode="Ch")
    pathways = findPathwaysByXref(
      identifier=c("HMDB00001", "HMDB00002"),
      systemCode=c("Ch", "Ch") 
Of course, these are just the basics, and the question was about colored pathways. The SOAP code was a bit more elaborate, and this is the version with this new package (the result at the top of this post):
    svg = getColoredPathway(pathway="WP1842", graphId=c("dd68a","a2c17"),
      color=c("FF0000", "00FF00"));
    writeLines(svg, "pathway.svg")
If you use this package in your research, please cite the below WikiPathways paper. If you have feature requests, please post the in the issue tracker.

Kutmon, M., Riutta, A., Nunes, N., Hanspers, K., Willighagen, E. L., Bohler, A., Mélius, J., Waagmeester, A., Sinha, S. R., Miller, R., Coort, S. L., Cirillo, E., Smeets, B., Evelo, C. T., Pico, A. R., Oct. 2015. WikiPathways: capturing the full diversity of pathway knowledge. Nucleic Acids Research.

To leave a comment for the author, please follow the link and comment on their blog: chem-bla-ics. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)