scverse / anndata

Annotated data.
http://anndata.readthedocs.io
BSD 3-Clause "New" or "Revised" License
577 stars 154 forks source link

H5ad converts string/object to categorical when saving and reading #1607

Closed wangjiawen2013 closed 2 months ago

wangjiawen2013 commented 2 months ago

Please make sure these conditions are met

Report

Hi, My anndata.obs has a column of dtype object(string), but when I saved the h5ad and read again with scanpy, the column became categorical ! Then it made conflicts with my spatialdata objects.

adata.write("adata.h5ad")
sc.read_h5ad("adata.h5ad")

Versions


the anndata version: 0.10.8
the scanpy version: 1.10.2
wangjiawen2013 commented 2 months ago

image

image

flying-sheep commented 2 months ago

Duplicate of #534, which has been fixed on main: in the next AnnData release, you can set convert_strings_to_categoricals=False