Thursday, November 18, 2010

Notes on some issues to solve with RPy

I upgraded to R version 2.12.0 the other day. The R GUI shows on my 32-bit iMac at work (5 years old):

R version 2.12.0 (2010-10-15)
[R.app GUI 1.35 (5632) i386-apple-darwin9.8.0]


$ python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from rpy2 import robjects
Bus error

Oops..
Luckily, CRAN still stockpiles old binary installers. Grabbed 2.11.1 here, looks like it installed correctly. The R GUI shows:

R version 2.11.1 (2010-05-31)

However the rpy2 install is messed up. Removed the egg from site-packages, reinstall rpy2 using easy_install. And it works. Need to re-install the ape package in this version of R.

We'll use the tree from the other day (here). Typical R code for this plot:

library(ape)
setwd('Desktop')
tree = read.tree('tree.txt')
plot(tree)
axisPhylo()

And it works! (You'll just have to trust me).
Now, how to do it using RPy?


>>> read_tree = robjects.r['read_tree']
Traceback (most recent call last):
File "", line 1, in
File "build/bdist.macosx-10.6-universal/egg/rpy2/robjects/__init__.py", line 241, in __getitem__

LookupError: 'read_tree' not found

read.dna is not found either..

I'm going to put this up for reference and see if I can get some help. I'll be back later.

And then while re-testing some of these examples I got this:


$ python
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from rpy2 import robjects
Bus error


Hunhh? How could it stop working like that?