Загрузка библиотек R в блокнот Jupyter с использованием Rpy2 и R Magic приводит к ошибкеPython

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Загрузка библиотек R в блокнот Jupyter с использованием Rpy2 и R Magic приводит к ошибке

Сообщение Anonymous »

Я пытаюсь загрузить несколько таких пакетов R:

Код: Выделить всё

%%R
# Load libraries from correct lib Paths for my environment - ignore this!
.libPaths(.libPaths()[c(3,2,1)])

# Load all the R libraries we will be using in the notebook

library(scran)
library(RColorBrewer)
library(slingshot)
library(monocle)
library(gam)
library(BiocParallel)
library(ggplot2)
library(plyr)
library(MAST)
Однако я получаю следующую ошибку:

Код: Выделить всё

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File /opt/anaconda3/envs/tsc-env/lib/python3.9/site-packages/rpy2/rinterface_lib/conversion.py:179, in _get_cdata(obj)
178 try:
--> 179     cdata = obj.__sexp__._cdata
180 except AttributeError:

AttributeError: 'numpy.str_' object has no attribute '__sexp__'

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
Cell In[5], line 1
----> 1 get_ipython().run_cell_magic('R', '', '# Load libraries from correct lib Paths for my environment - ignore this!\n .libPaths(.libPaths()[c(3,2,1)])\n\n# Load all the R libraries we will be using in the notebook\n\nlibrary(scran)\nlibrary(RColorBrewer)\nlibrary(slingshot)\nlibrary(monocle)\nlibrary(gam)\nlibrary(BiocParallel)\nlibrary(ggplot2)\nlibrary(plyr)\nlibrary(MAST)\n#library(Seurat)\n#library(scater)\n#library(scDblFinder)\n#library(sctransform)\n#library(scry)\n#library(clusterExperiment)\n')

File /opt/anaconda3/envs/tsc-env/lib/python3.9/site-packages/IPython/core/interactiveshell.py:2517, in InteractiveShell.run_cell_magic(self, magic_name, line, cell)
2515 with self.builtin_trap:
2516     args = (magic_arg_s, cell)
-> 2517     result = fn(*args, **kwargs)
2519 # The code below prevents the output from being displayed
2520 # when using magics with decorator @output_can_be_silenced
2521 # when the last Python token in the expression is a ';'.
2522 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):

File /opt/anaconda3/envs/tsc-env/lib/python3.9/site-packages/rpy2/ipython/rmagic.py:935, in RMagics.R(self, line, cell, local_ns)
...
182                          'to map it to one: %s' % repr(obj))
183 else:
184     cdata = cls(obj)

ValueError: Not an rpy2 R object and unable to map it to one: np.str_('value')
Проверяем с помощью R: все пакеты успешно установлены, но как я могу исправить эту ошибку значения? Спасибо,

Подробнее здесь: https://stackoverflow.com/questions/787 ... s-in-error
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»