anndata icon indicating copy to clipboard operation
anndata copied to clipboard

I get a write error:

Open zznx opened this issue 5 years ago • 3 comments

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

zznx avatar Oct 13 '20 03:10 zznx

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

ivirshup avatar Oct 13 '20 07:10 ivirshup

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 /.

zznx avatar Oct 14 '20 06:10 zznx

I met the same error

wangjiawen2013 avatar Jul 27 '22 09:07 wangjiawen2013

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!

github-actions[bot] avatar Jun 28 '23 02:06 github-actions[bot]

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.

ivirshup avatar Jun 28 '23 09:06 ivirshup

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.

KaWingLee9 avatar Jan 09 '24 06:01 KaWingLee9

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

flying-sheep avatar Jan 09 '24 08:01 flying-sheep

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

axol0tl avatar Mar 01 '24 14:03 axol0tl

@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

ivirshup avatar Mar 01 '24 15:03 ivirshup

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

axol0tl avatar Mar 01 '24 15:03 axol0tl