cellrank: saving results fails
The adata file from the tutorial https://cellrank.readthedocs.io/en/stable/cellrank_basics.html can not be saved using adata.write(‘CellRank_Tutorial.h5ad’).
## after the tutorial https://cellrank.readthedocs.io/en/stable/cellrank_basics.html
adata.write('CellRank_Tutorial.h5ad')
...
adata.write('CellRank_Tutorial.h5ad')
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/anndata/_io/utils.py", line 209, in func_wrapper
return func(elem, key, val, *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/anndata/_io/h5ad.py", line 148, in write_not_implemented
raise NotImplementedError(
NotImplementedError: Failed to write value for uns/coarse_fwd, since a writer for type <class 'anndata._core.anndata.AnnData'> 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 "/usr/local/lib/python3.8/dist-packages/anndata/_core/anndata.py", line 1912, in write_h5ad
_write_h5ad(
File "/usr/local/lib/python3.8/dist-packages/anndata/_io/h5ad.py", line 118, in write_h5ad
write_attribute(f, "uns", adata.uns, dataset_kwargs=dataset_kwargs)
File "/usr/lib/python3.8/functools.py", line 875, in wrapper
return dispatch(args[0].__class__)(*args, **kw)
File "/usr/local/lib/python3.8/dist-packages/anndata/_io/h5ad.py", line 130, in write_attribute_h5ad
_write_method(type(value))(f, key, value, *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/anndata/_io/h5ad.py", line 294, in write_mapping
write_attribute(f, f"{key}/{sub_key}", sub_value, dataset_kwargs=dataset_kwargs)
File "/usr/lib/python3.8/functools.py", line 875, in wrapper
return dispatch(args[0].__class__)(*args, **kw)
File "/usr/local/lib/python3.8/dist-packages/anndata/_io/h5ad.py", line 130, in write_attribute_h5ad
_write_method(type(value))(f, key, value, *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/anndata/_io/utils.py", line 212, in func_wrapper
raise type(e)(
NotImplementedError: Failed to write value for uns/coarse_fwd, since a writer for type <class 'anndata._core.anndata.AnnData'> has not been implemented yet.
Above error raised while writing key 'uns/coarse_fwd' of <class 'h5py._hl.files.File'> from /.
...
Versions:
cellrank==1.5.1 scanpy==1.7.2 anndata==0.7.8 numpy==1.21.2 numba==0.55.0 scipy==1.7.3 pandas==1.3.5 pygpcca==1.0.3 scikit-learn==1.0.2 statsmodels==0.13.1 python-igraph==0.8.3 scvelo==0.2.4 pygam==0.8.0 matplotlib==3.5.1 seaborn==0.11.2
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 30 (2 by maintainers)
Should’ve be fixed on master long ago.
Hi @stela2502 ,
thanks for raising this issue, can reproduce. Quickest way to fix this is to upgrade to the newest version of
AnnDataaspip install git+https://github.com/theislab/anndata, though new release should be coming out soon. Not sure exactly why I’ve decided to store the coarse-grained transtions asAnnData(could be justpandas.DataFrame), so will change it later.Hello All, I am also using Anndata=0.8.0. I am not able to save adata in h5ad format. Here is the sample code
import anndata adata=anndata.read_h5ad("/home/Akila/input.h5ad") adata.write("/home/Akila/BA9.h5ad")Error message: TypeError: No method has been defined for writing <class ‘numpy.matrix’> elements to <class ‘h5py._hl.group.Group’>
Above error raised while writing key ‘X’ of <class ‘h5py._hl.group.Group’> to /
Please advice
Thank you for that snippet, yes, I am able to save adata now. While an imperfect solution, it means that I can move forward with this line of analysis. Looking forward to future fixes, but for now I’m set, thanks for your time!
Thanks for your continued attention to this. My versions are now
anndata==0.7.8,cellrank=git+https://github.com/theislab/cellrank@8efabc8bba90262638721405c7ef7e85d9301fd7, and I receive the following error: