rpy2无法加载某些bioconductor包

时间:2015-08-07 22:57:00

标签: python r rpy2 bioconductor

最近我们的系统将R更新为3.2.1(在一个单独的位置)。从那时起,我在rpy2中加载某些软件包时遇到问题。

我尝试过:

  • 将LD_LIBRARY_PATH设置为当前路径
  • 卸载然后重新安装rpy2
  • 取消安装,然后重新安装有问题的软件包

当我切换回之前的R安装时(当然,为旧的R版本重新安装rpy2),它工作正常。它似乎并没有影响所有包。

例如,加载' limma'没有问题。但加载' affy',我在python控制台中有以下错误:

>>> from rpy2.robjects.packages import importr
>>> base = importr('affy')
/mnt/software/anaconda/envs/py2/lib/python2.7/site-packages/rpy2/robjects/packages.py:63: UserWarning: Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object '/mnt/software/R-3.2.1/lib64/R/library/preprocessCore/libs/preprocessCore.so':
  /mnt/software/R-3.2.1/lib64/R/library/preprocessCore/libs/preprocessCore.so: undefined symbol: R_NaN

  return _reval(expr)
/mnt/software/anaconda/envs/py2/lib/python2.7/site-packages/rpy2/robjects/packages.py:438: UserWarning: Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object '/mnt/software/R-3.2.1/lib64/R/library/preprocessCore/libs/preprocessCore.so':
/mnt/software/R-3.2.1/lib64/R/library/preprocessCore/libs/preprocessCore.so: undefined symbol: R_NaN

  env = _get_namespace(rname)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/mnt/software/anaconda/envs/py2/lib/python2.7/site-packages/rpy2/robjects/packages.py", line 438, in importr
    env = _get_namespace(rname)
rpy2.rinterface.RRuntimeError: Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared object '/mnt/software/R-3.2.1/lib64/R/library/preprocessCore/libs/preprocessCore.so':
  /mnt/software/R-3.2.1/lib64/R/library/preprocessCore/libs/preprocessCore.so: undefined symbol: R_NaN

在Ipython Notebook中:

%load_ext rpy2.ipython

%%R
library(affy)

Error: package or namespace load failed for ‘affy’

我尝试了建议here但没有成功。

我使用的是R 3.2.1,bioconductor 3.1,rpy2 2.6.1

谢谢!

1 个答案:

答案 0 :(得分:1)

错误消息指向R包preprocessCore。 尝试重新安装它。如果从iPython做任何事情:

from rpy2.robjects import r
r_src = """
source("http://www.bioconductor.org/biocLite.R")
biocLite("preprocessCore")
"""
r(r_src)

完成后,如果安装完成,它应该可以工作:

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