Archive for the ‘R’ tag
Based on feedback from the recent R workshop at the EBI, I’ve updated the rcdk package to include more methods operating on atoms, a modification to parse.smiles to allow it to handle a vector of SMILES strings, which makes it more R-like (thanks to Tobias Verbeke for the patch). In addition, one can now load very large SMILES or SDF files using the iterating readers from the CDK. This feature makes use of the iterators package and lets you write code such as
iter <- iload.molecules('big.smi', type='smi')
mol <- nextElem(iter)
As a result, only one molecule is loaded at a time, allowing one to process arbitrarily large files. Version 2.9.23 has been uploaded to CRAN and should be available in a day or two
These last few days I’ve been in the UK for an EBI workshop on cheminformatics in R. It was a two day workshop, the first day focusing on general cheminormatics in R using the rcdk and rpubchem packages, and the second day focusing on doing mass spectrometry in R using XCMS and Rdisop, run by Steffen Neumann and Paul Benton. It was an excellent workshop with participation from industry and academia and skill levels ranging from new R users to experts and people with minimal cheminformatics backgrounds to full time cheminformaticians. While I think my exercises might have been a little too difficult, I think we were able to cover a variety of topics ranging from details on how to do specific cheminformatics operations in R to more application oriented tasks such as fingerprint based analysis and benchmarking virtual screening methods. The slides from the workshop are available here – it’s a pretty big slide deck and covers some introductory R (there are some mistakes in that section which I will update in the coming days), and overview of the CDK and then sections on usage and applications of the rcdk and rpubchem packages. It certainly helped that I had a very friendly audience! During the course of the workshop I also learned a few things about R (thanks to Tobias Verbeke and Steffen). Given that about 40 people or so were exposed to the rcdk package, my (known) user base should hopefully increase It was nice to get a patch from Tobias during the workshop, which will be incorporated once I’m back home. It was also great to meet a number of people with whom I’d only had email or FriendFeed exchanges with in the past – including Chris Swain, Mark Rijnbeek, Duncan Hull, Nico Adams (though I didn’t realize it was him when I was speaking to him – sorry Nico!), Duan Lian and Syed Asad Rahman. I also got to briefly meet some of the ChEMBL folks (John and Patricia). Monday night we had a lovely workshop dinner at The Cricketer (Clavering). Many thanks to Gabriella Rustici and Dominic Clark for organizing this and inviting me to run the first day. The only downside of this trip? It was too short It would’ve been great to be able to stay a day or two more to have longer discussions with various groups.
In addition to the workshop, I visited Asad and his family in Cambridge for a fantastic dinner and much useful discussion. He’s done some excellent work on SMSD and showed me some of his recent work on enzyme classification and reaction mappings. I won’t say much more as he’s writing this up, except to say that it was quite impressive and I’m eagerly looking forward to seeing the writeups. Hopefully we’ll be able to do some joint work in the near future. Given the speed up that SMSD provides for graph isomorphism, I’m in the process of updating the CDK SMARTS parser to make use of it rather than the older UIT, which should improve SMARTS matching considerably. Down the road, the pharmacophore matching code will get a similar upgrade.
I was also able to squeeze in a day trip up to Harrogate, where I grew up. It was fun to see familiar streets and places after 23 years or so. It certainly didn’t hurt to also have some pretty amazing traditional English fare (Yorkshire curd tart at Bettys and the fish ‘n chips at Graveleys was fantastic).
In preparation for the upcoming R workshop at the EBI, I’ve been cleaning up the rcdk package and updating some features. One of the new features is the ability to get a 2D depiction as a raster image. Uptil now, 2D depictions were drawn in a Swing window – this allowed you to resize the window but not much else. You really couldn’t use it for anything else but viewing.
However, R-2.11.0 provides a new function called rasterImage, which overlays a raster image onto a pre-existing plot. It turns out that the png package lets me easily create such a raster image, either from a PNG file or from a vector of bytes. Given a molecules, we can get the byte array of its PNG representation via the view.image.2d function in the latest rcdk. As a result, you can now make a plot and then overlay a 2D depiction within the plot area. For example to get the picture shown alongside, we could do:
m <- parse.smiles("C1CC2CC1C(=O)NC2")
img <- view.image.2d(m, 200,200)
rasterImage(img, 2,6, 6,10)
The latest version of rcdk and rpubchem is not on CRAN yet, but you can get source packages for OS X & Linux and binary packages for Windows at http://rguha.net/rcdk. Note that the latest version of rcdk requires R-2.11.0 along with rJava, rcdklibs, fingerprint and png as dependencies. If you’re interested in contributing check out the git repository.
I’ve been working on the rcdk and rcdklibs R packages that integrate the CDK into the R environment. For the past year or two it’s been hosted on r-forge.r-project.org which has a nice feature of nightly builds of R packages. Unfortunately their version control system is Subversion. Having used Git for my other projects, this was getting painful. So rcdk and rcdklibs are now hosted at Github as the cdkr project. This makes development much smoother, but I do loose the automated build feature. Sometime in the future, I’ll set up the repository to provide direct links to the packages (though they will also be available on CRAN)
Finally all the paper work is in place for me to visit the EBI in May to run a hands-on workshop on doing cheminformatics in R. This is part of a two day program. On May 17th I will be discussing the use of the rcdk and rpubchem packages, considering a variety of use cases such as QSAR modeling and fingerprint similarity. I’ll also be touching on the CDK, as that’s the underlying toolkit. The second day, May 18th, run by Stefan Neumann, Paul Benton and David Broadhurst will focus on handling and analyzing mass spectrometry data in R.
I’m really looking forward to this trip and the chance to discuss these packages as well as get feedback on what’s useful and what’s not. If any readers are attending and would like me to cover specific topics, feel free to drop me a line.
I’ll be reaching London on May 14th, visiting some friends and then heading to Hinxton on May 16th. Another reason I’m looking forward to the trip (in addition to some good fish and chips) is that I get to visit Harrogate, where I grew up.