我正在尝试通过python rpy2使用Bioconductor GenomicFeatures对象和方法,因此当我执行以下代码时:
import rpy2.robjects as robjects
robjects.r('install.packages("XML", '
'repos="http://cran.r-project.org")')
robjects.r('install.packages("BiocManager", '
'repos="http://cran.r-project.org")')
robjects.r('BiocManager::install("GenomicFeatures ")')
robjects.r('library(GenomicFeatures )')
我得到相应的错误:
ERROR: dependency ‘XML’ is not available for package ‘rtracklayer’
* removing ‘/Users/nalomran/opt/anaconda3/envs/ReQTL/lib/R/library/rtracklayer’
ERROR: dependency ‘XML’ is not available for package ‘biomaRt’
* removing ‘/Users/nalomran/opt/anaconda3/envs/ReQTL/lib/R/library/biomaRt’
ERROR: dependencies ‘rtracklayer’, ‘biomaRt’ are not available for package ‘GenomicFeatures’
* removing ‘/Users/nalomran/opt/anaconda3/envs/ReQTL/lib/R/library/GenomicFeatures’
R[write to console]: Error in library(GenomicFeatures) :
there is no package called ‘GenomicFeatures’
R[write to console]: 1: package ‘XML’ is not available (for R version 3.6.3)
R[write to console]: installation of package ‘GenomicFeatures’ had non-zero exit status
Traceback (most recent call last):
File "annotate_cis_trans.py", line 64, in <module>
robjects.r('library(GenomicFeatures)')
File "/Users/nalomran/opt/anaconda3/envs/ReQTL/lib/python3.8/site-packages/rpy2/robjects/__init__.py", line 416, in __call__
res = self.eval(p)
File "/Users/nalomran/opt/anaconda3/envs/ReQTL/lib/python3.8/site-packages/rpy2/robjects/functions.py", line 197, in __call__
return (super(SignatureTranslatedFunction, self)
File "/Users/nalomran/opt/anaconda3/envs/ReQTL/lib/python3.8/site-packages/rpy2/robjects/functions.py", line 125, in __call__
res = super(Function, self).__call__(*new_args, **new_kwargs)
File "/Users/nalomran/opt/anaconda3/envs/ReQTL/lib/python3.8/site-packages/rpy2/rinterface_lib/conversion.py", line 44, in _
cdata = function(*args, **kwargs)
File "/Users/nalomran/opt/anaconda3/envs/ReQTL/lib/python3.8/site-packages/rpy2/rinterface.py", line 621, in __call__
raise embedded.RRuntimeError(_rinterface._geterrmessage())
rpy2.rinterface_lib.embedded.RRuntimeError: Error in library(GenomicFeatures) :
there is no package called ‘GenomicFeatures’
我正在将Python3.8与conda env一起用于rpy2,如何解决此问题?
谢谢。
答案 0 :(得分:0)
非常感谢,我能够通过GenomicFeatures
在python3.8中解决安装和加载Bioconductor rpy2
所遇到的问题。我花了几个小时才能找到该解决方案,所以我想分享一下我所做的解决方案,以便最终遇到相同问题的人也可以找到它。
基本上,在跟踪错误日志时,似乎实际错误指向此特定错误行:
R[write to console]: 1: package ‘XML’ is not available (for R version 3.6.3)
在进行一些研究时,我发现了这个特定的StackOverflow问题Cannot install package XML to R,他们无法将软件包xml安装到R,而GenomicFeatures需要该软件包,因此我在安装BiocManager之前添加了以下内容(以防BiocManager未安装):
robjects.r('install.packages("XML", repos = "http://www.omegahat.net/R")')
此答案来自上述StackOverflow问题的@Jaeyoung Chun。
运行修改后的代码(在下面找到)后,我能够安装和加载这样的软件包,而没有任何错误或问题:
import rpy2.robjects as robjects
robjects.r('install.packages("XML", repos = "http://www.omegahat.net/R")')
robjects.r('install.packages("BiocManager", '
'repos="http://cran.r-project.org")')
robjects.r('BiocManager::install("GenomicFeatures ")')
robjects.r('library(GenomicFeatures )')