简体   繁体   English

如何使用rpy2的bioconductor?

[英]How to use bioconductor from rpy2?

I'm trying to use bioconductor (Specifically seqLogo) from rpy2. 我正在尝试从rpy2使用bioconductor(特别是seqLogo)。 I found the helpful package: 我找到了有用的包:

http://pythonhosted.org/rpy2-bioconductor-extensions/index.html 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: 在我的系统的R环境中,以下工作完美:

> require(seqLogo)

and I'd like to use this already installed seqLogo package from rpy2. 我想从rpy2使用这个已安装的seqLogo软件包。 How can this be done? 如何才能做到这一点? since I have rpy2 installed, I can do: 因为我安装了rpy2,我可以这样做:

>>> import bioc

but not sure how to install new bioconductor packages like seqLogo from bioc . 但不确定如何从bioc安装新的bioconductor包,如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. Bioconductor项目改变了其软件包安装程序的内部结构。 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. 否则rpy2的bioconductor扩展已经有一段时间没有更新了。 There might be other things that would need to be fixed. 可能还有其他事情需要修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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