## Tuesday, December 22, 2015

### Using the WikiPathways API in R

 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.