GenomicFeatures 安装和加载错误 "there is no package called ‘GenomicFeatures" 通过 Python3 rpy2

GenomicFeatures Installation and Loading Error "there is no package called ‘GenomicFeatures" via Python3 rpy2

我正在尝试通过 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 for rpy2,我该如何解决这个问题?

提前致谢。

谢天谢地,我能够解决我在 python3.8 中通过 rpy2 安装和加载 Bioconductor GenomicFeatures 时遇到的问题。我花了几个小时来解决这个问题解决方案,所以我想分享我所做的解决方案,以便如果遇到相同问题的人可以找到它。

基本上,在跟踪错误日志时,实际错误似乎指向这个特定的错误行:

R[write to console]: 1: package ‘XML’ is not available (for R version 3.6.3)  

当我做一些研究时,我发现了这个特殊的 Whosebug 问题 Cannot install package XML to R 他们无法将包 xml 安装到 R 并且 GenomicFeatures 需要该包所以我在安装之前添加了以下行BiocManager(如果未安装 BiocManager):

robjects.r('install.packages("XML", repos = "http://www.omegahat.net/R")')

此答案来自上述 Whosebug 问题的@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 )')