简体   繁体   中英

How to use bioconductor from rpy2?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM