Subsetting not working after saving anndata
See original GitHub issueI’ve been having some issues recently when trying to subset an anndata object after I save it to disk. Everything works perfectly, but after I save it to disk using adata.write(filename, compression='gzip')
, and then read it back again from disk, the subsetting doesn’t work. It only happens after saving to disk, and it seems to only happen after I’ve run additional analysis (UMAP, rank_genes_groups, etc… I don’t know exactly which entry is the one breaking the writing/reading).
This is the error I get:
Traceback (most recent call last): File “”, line 48, in <module> File “/Users/andres/miniconda3/envs/finalenv/lib/python3.7/site-packages/anndata/core/anndata.py”, line 1230, in getitem return self._getitem_view(index) File “/Users/andres/miniconda3/envs/finalenv/lib/python3.7/site-packages/anndata/core/anndata.py”, line 1234, in _getitem_view return AnnData(self, oidx=oidx, vidx=vidx, asview=True) File “/Users/andres/miniconda3/envs/finalenv/lib/python3.7/site-packages/anndata/core/anndata.py”, line 561, in init self._init_as_view(X, oidx, vidx) File “/Users/andres/miniconda3/envs/finalenv/lib/python3.7/site-packages/anndata/core/anndata.py”, line 633, in _init_as_view self._raw = adata_ref.raw[oidx] File “/Users/andres/miniconda3/envs/finalenv/lib/python3.7/site-packages/anndata/core/anndata.py”, line 344, in getitem new._varm = self._varm._view(self, vidx) AttributeError: ‘dict’ object has no attribute ‘_view’
Any subsetting (of observations or variables) gives me this error. I tried removing keys from .uns
, etc. , but nothing seems to work.
These are the versions I’m running, all installed with conda:
scanpy==1.4.4.post1 anndata==0.6.22.post1 umap==0.3.10 numpy==1.17.2 scipy==1.3.1 pandas==0.25.2 scikit-learn==0.21.3 statsmodels==0.10.1 python-igraph==0.7.1 louvain==0.6.1
I also tried using different (or no) compression to save and read, but that didn’t help either. I don’t know if it’s related to the recent problems with h5py, but either way I am using h5py=2.9.0 and hdf5=1.10.5. Hopefully someone can help! Let me know if I should post this in the anndata repository instead.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
I think the easiest would be to pass the parts you want to the AnnData constructor, like:
That makes sense - thanks!