scverse / anndata

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

I get a write error: #438

Closed zznx closed 1 year ago

zznx commented 4 years ago

I get a write error: Above error raised while writing key 0 of <class 'h5py._hl.group.Group'> from /. if a name of the index to the var table is an int. Setting the name to a string fixes this.

Originally posted by @jeffhsu3 in https://github.com/theislab/anndata/issues/52#issuecomment-585151866

ivirshup commented 4 years ago

Is adata.var.index.name an integer? If so, changing it to a string as suggested by the error message should solve your problem.

zznx commented 4 years ago

Thank you anyway, but my problem is still unsolved. How to solve it @ivirshup

OSError: Unable to create link (name already exists)

Above error raised while writing key 'full_name' of <class 'h5py._hl.group.Group'> from /.

Above error raised while writing key 'raw/var' of <class 'h5py._hl.files.File'> from /.
wangjiawen2013 commented 2 years ago

I met the same error

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. Please add a comment if you want to keep the issue open. Thank you for your contributions!

ivirshup commented 1 year ago

if a name of the index to the var table is an int. Setting the name to a string fixes this.

Reading this again, makes me think issue has been resolved. We don't support integer column names.

KaWingLee9 commented 10 months ago

Maybe check the data strcture will help. For example, I had an error while writing adata.obsm['spatial'], I changed the dtype of the array. Another error occurs while writing adata.obs['array_row'], then I changed the data into int. So I guess data structure and data type are very important while wirting h5ad.

flying-sheep commented 10 months ago

Of course we support int dtypes. But we would need a minimum reproducible example: https://matthewrocklin.com/minimal-bug-reports

axol0tl commented 8 months ago

I also keep having issues with saving anndata objects after modifying them with scanpy (filtering genes) and adding some cols to .obs

ivirshup commented 8 months ago

@axol0tl, please open a full bug report with an example and traceback:

https://github.com/scverse/anndata/issues/new?assignees=&labels=Bug+🐛&projects=&template=bug-report.yml

axol0tl commented 8 months ago

ah, I realized that if there are any str values in anndata.obs -> it will not save h5ad. sorry, my bad. saved the info into a csv and dropped those cols, deleted anndata.raw, and was able to save anndata