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

Conversion from SingleCellExperiment to AnnData fails to convert .uns back to python objects #57

Open
scottgigante opened this issue Oct 29, 2020 · 0 comments

Comments

@scottgigante
Copy link
Contributor

scottgigante commented Oct 29, 2020

Minimal code sample

import scanpy as sc
import rpy2.robjects as ro
import rpy2.robjects.numpy2ri
import anndata2ri

rpy2.robjects.numpy2ri.activate()
anndata2ri.activate()

pbmc = sc.datasets.pbmc68k_reduced()
ro.globalenv['sce'] = pbmc
pbmc_converted = ro.globalenv['sce']

pbmc_converted.write_h5ad("test.h5ad")
Traceback (most recent call last):
  File "/home/scottgigante/.local/lib/python3.6/site-packages/anndata/_io/utils.py", line 188, in func_wrapper
    return func(elem, key, val, *args, **kwargs)
  File "/home/scottgigante/.local/lib/python3.6/site-packages/anndata/_io/h5ad.py", line 145, in write_not_implemented
    f"Failed to write value for {key}, "
NotImplementedError: Failed to write value for uns/louvain, since a writer for type <class 'rpy2.robjects.vectors.ListVector'> has not been implemented yet.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/scottgigante/.local/lib/python3.6/site-packages/anndata/_core/anndata.py", line 1852, in write_h5ad
    as_dense=as_dense,
  File "/home/scottgigante/.local/lib/python3.6/site-packages/anndata/_io/h5ad.py", line 112, in write_h5ad
    write_attribute(f, "uns", adata.uns, dataset_kwargs=dataset_kwargs)
  File "/usr/lib/python3.6/functools.py", line 807, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "/home/scottgigante/.local/lib/python3.6/site-packages/anndata/_io/h5ad.py", line 126, in write_attribute_h5ad
    _write_method(type(value))(f, key, value, *args, **kwargs)
  File "/home/scottgigante/.local/lib/python3.6/site-packages/anndata/_io/h5ad.py", line 286, in write_mapping
    write_attribute(f, f"{key}/{sub_key}", sub_value, dataset_kwargs=dataset_kwargs)
  File "/usr/lib/python3.6/functools.py", line 807, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "/home/scottgigante/.local/lib/python3.6/site-packages/anndata/_io/h5ad.py", line 126, in write_attribute_h5ad
    _write_method(type(value))(f, key, value, *args, **kwargs)
  File "/home/scottgigante/.local/lib/python3.6/site-packages/anndata/_io/utils.py", line 195, in func_wrapper
    ) from e
NotImplementedError: Failed to write value for uns/louvain, since a writer for type <class 'rpy2.robjects.vectors.ListVector'> has not been implemented yet.

Above error raised while writing key 'uns/louvain' of <class 'h5py._hl.files.File'> from /.

Versions

>>> sc.logging.print_versions()
scanpy==1.4.6 anndata==0.7.3 umap==0.4.6 numpy==1.19.1 scipy==1.5.2 pandas==1.0.5 scikit-learn==0.23.1 statsmodels==0.11.1 python-igraph==0.8.2 louvain==0.6.0
>>> anndata2ri.__version__
'1.0.5.dev2+ea266ab'
>>> rpy2.__version__
'3.3.6'
>>> sys.version_info
sys.version_info(major=3, minor=6, micro=9, releaselevel='final', serial=0)
scottgigante added a commit to KrishnaswamyLab/scprep that referenced this issue Nov 2, 2020
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