How can I load an anndata object when 'raw' was saved as a dictionary

Pretty much what it says on the title. I saved an anndata object after integration and cell type labelling without any issues whatsoever and now when I try to load it I always get the following error:

AttributeError: ‘dict’ object has no attribute ‘shape’.

It seems ‘raw’ is being loaded as a dictionary instead of the expected format, which causes an AttributeError when trying to access attributes like ‘shape’ that are expected on a NumPy array or similar object.

I tried using different anndata versions and even selectively loading the data from the h5ad file (Reading Anndata from only parts of h5ad file: Hack solution · Issue #1517 · scverse/anndata · GitHub) but I’m having some trouble. What should I do?

Hey @sudoGui,

Are there any more specifics you could share so that we can debug that?

Is saving / loading performed by the anndata package itself, or has it been written by some third-party package?

If it’s a valid HDF5 file, you can always load individual slots with h5py, and there’s also read_elem() (anndata.experimental.read_elem — anndata 0.1.dev50+g6d70535 documentation).