Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.uns['neighbors'] crashes conversion of pbmc3k_processed() demo data #88

Open
ktpolanski opened this issue Aug 1, 2022 · 0 comments
Open

Comments

@ktpolanski
Copy link

Tried to pass sc.datasets.pbmc3k_processed() through the Jupyter %%R -i adata syntax, encountered wall of error pasted below. Deleted .uns['neighbors'], the object went through just fine.

anndata 0.7.5, anndata2ri 1.1.0, rpy2 3.4.3 if relevant

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-4f83d5b8882a> in <module>
----> 1 get_ipython().run_cell_magic('R', '-i adata', 'adata\n')

/opt/conda/envs/teichlab/lib/python3.8/site-packages/IPython/core/interactiveshell.py in run_cell_magic(self, magic_name, line, cell)
   2397             with self.builtin_trap:
   2398                 args = (magic_arg_s, cell)
-> 2399                 result = fn(*args, **kwargs)
   2400             return result
   2401 

<decorator-gen-121> in R(self, line, cell, local_ns)

/opt/conda/envs/teichlab/lib/python3.8/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

/opt/conda/envs/teichlab/lib/python3.8/site-packages/rpy2/ipython/rmagic.py in R(self, line, cell, local_ns)
    773                                                'consolewrite_print',
    774                                                self.write_console_regular))
--> 775                         cell_display(result, args)
    776                         text_output += self.flush()
    777 

/opt/conda/envs/teichlab/lib/python3.8/site-packages/rpy2/ipython/rmagic.py in CELL_DISPLAY_DEFAULT(res, args)
    108 
    109 def CELL_DISPLAY_DEFAULT(res, args):
--> 110     return ro.r.show(res)
    111 
    112 

/opt/conda/envs/teichlab/lib/python3.8/site-packages/rpy2/robjects/functions.py in __call__(self, *args, **kwargs)
    196                 v = kwargs.pop(k)
    197                 kwargs[r_k] = v
--> 198         return (super(SignatureTranslatedFunction, self)
    199                 .__call__(*args, **kwargs))
    200 

/opt/conda/envs/teichlab/lib/python3.8/site-packages/rpy2/robjects/functions.py in __call__(self, *args, **kwargs)
    115 
    116     def __call__(self, *args, **kwargs):
--> 117         new_args = [conversion.py2rpy(a) for a in args]
    118         new_kwargs = {}
    119         for k, v in kwargs.items():

/opt/conda/envs/teichlab/lib/python3.8/site-packages/rpy2/robjects/functions.py in <listcomp>(.0)
    115 
    116     def __call__(self, *args, **kwargs):
--> 117         new_args = [conversion.py2rpy(a) for a in args]
    118         new_kwargs = {}
    119         for k, v in kwargs.items():

/opt/conda/envs/teichlab/lib/python3.8/functools.py in wrapper(*args, **kw)
    873                             '1 positional argument')
    874 
--> 875         return dispatch(args[0].__class__)(*args, **kw)
    876 
    877     funcname = getattr(func, '__name__', 'singledispatch function')

/opt/conda/envs/teichlab/lib/python3.8/site-packages/anndata2ri/py2r.py in py2rpy_anndata(obj)
     69         # Convert everything we know
     70         with localconverter(full_converter() + dict_converter):
---> 71             metadata = ListVector(obj.uns.items())
     72 
     73         rd_args = {conv_name.scanpy2sce(k): mat_converter.py2rpy(obj.obsm[k]) for k in obj.obsm.keys()}

/opt/conda/envs/teichlab/lib/python3.8/site-packages/rpy2/robjects/vectors.py in __init__(self, tlist)
    639                 raise ValueError('tlist should have a /method/ __iter__ '
    640                                  '(not an attribute)')
--> 641             kv = [(str(k), conversion.py2rpy(v)) for k, v in tlist]
    642             kv = tuple(kv)
    643             df = baseenv_ri.find("list").rcall(kv, globalenv_ri)

/opt/conda/envs/teichlab/lib/python3.8/site-packages/rpy2/robjects/vectors.py in <listcomp>(.0)
    639                 raise ValueError('tlist should have a /method/ __iter__ '
    640                                  '(not an attribute)')
--> 641             kv = [(str(k), conversion.py2rpy(v)) for k, v in tlist]
    642             kv = tuple(kv)
    643             df = baseenv_ri.find("list").rcall(kv, globalenv_ri)

/opt/conda/envs/teichlab/lib/python3.8/functools.py in wrapper(*args, **kw)
    873                             '1 positional argument')
    874 
--> 875         return dispatch(args[0].__class__)(*args, **kw)
    876 
    877     funcname = getattr(func, '__name__', 'singledispatch function')

/opt/conda/envs/teichlab/lib/python3.8/site-packages/anndata2ri/py2r.py in py2rpy_dict(obj)
     31     """Try converting everything. For nested dicts, this needs itself to be registered"""
     32     converted = {}
---> 33     for k, v in obj.items():
     34         try:
     35             converted[str(k)] = conversion.py2rpy(v)

/opt/conda/envs/teichlab/lib/python3.8/_collections_abc.py in __iter__(self)
    742     def __iter__(self):
    743         for key in self._mapping:
--> 744             yield (key, self._mapping[key])
    745 
    746 ItemsView.register(dict_items)

/opt/conda/envs/teichlab/lib/python3.8/site-packages/anndata/compat/_overloaded_dict.py in __getitem__(self, key)
     98             return self.overloaded[key].get()
     99         else:
--> 100             return self.data[key]
    101 
    102     def __setitem__(self, key, value):

/opt/conda/envs/teichlab/lib/python3.8/site-packages/rpy2/robjects/vectors.py in __getitem__(self, i)
    263 
    264     def __getitem__(self, i):
--> 265         res = super().__getitem__(i)
    266 
    267         if isinstance(res, Sexp):

/opt/conda/envs/teichlab/lib/python3.8/site-packages/rpy2/rinterface_lib/sexp.py in __getitem__(self, i)
    639             )
    640         else:
--> 641             raise TypeError(
    642                 'Indices must be integers or slices, not %s' % type(i))
    643         return res

TypeError: Indices must be integers or slices, not <class 'rpy2.robjects.vectors.ListVector'>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant