save anndata object to h5ad file
rialc13 opened this issue · 2 comments
rialc13 commented
Hi,
After performing spatial trajectory analysis, I am trying to save the anndata object to h5ad file using the write_h5ad(file_name) function but am getting the following error -
I googled the error & many people suggested removing the adata.raw layer. I did that (using del bdata.raw), still I get the following (new) error -
Can you please help? Thanks
duypham2108 commented
It seems Anndata prevents saving it in the new version if the key in a dictionary has an int type. We will try to fix it soon.
One temporary solution is using pickle
# For saving
import pickle
with open('anndata.obj', 'wb') as fp:
pickle.dump(data, fp)
# For loading
import pickle
with open('anndata.obj', 'rb') as fp:
adata = pickle.load(fp)
rialc13 commented
Thank you so much! This worked!