Question

I'm trying to use bioconductor (Specifically seqLogo) from rpy2. I found the helpful package:

http://pythonhosted.org/rpy2-bioconductor-extensions/index.html

however when I try this from the documentation of the package:

import rpy2.robjects as robjects
from rpy2.robjects.packages import importr
base = importr('base')

# evaluate locally a remote R script
base.source("http://www.bioconductor.org/biocLite.R")
base.require("biocLite")
bioclite = robjects.globalenv['biocLite']

I get the error

  File "/usr/local/lib/python2.7/dist-packages/rpy2-2.3.6-py2.7-linux-x86_64.egg/rpy2/robjects/environments.py", line 17, in __getitem__
    res = super(Environment, self).__getitem__(item)
LookupError: 'biocLite' not found

In the R environment on my system, the following works perfectly:

> require(seqLogo)

and I'd like to use this already installed seqLogo package from rpy2. How can this be done? since I have rpy2 installed, I can do:

>>> import bioc

but not sure how to install new bioconductor packages like seqLogo from bioc.

If I try:

importr("seqLogo")

I get the error:

rpy2.rinterface.RRuntimeError: Error in loadNamespace(name) : there is no package called ‘seqLogo’

thanks.

Was it helpful?

Solution

The Bioconductor project changed a bit the internals of its package installer. The following should work:

from rpy2.robjects.packages import importr

# do the following _only the first time_, to install the package seqLogo
base = importr('base')
base.source("http://www.bioconductor.org/biocLite.R")
biocinstaller = importr("BiocInstaller")
biocinstaller.biocLite("seqLogo")

# load the installed package "seqLogo"
seqlogo = importr("seqLogo")

Otherwise the bioconductor extensions to rpy2 have not been updated for quite some time. There might be other things that would need to be fixed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top