Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

int32 columns in obs break writing of adata to disk #68

Open
le-ander opened this issue Feb 17, 2022 · 1 comment
Open

int32 columns in obs break writing of adata to disk #68

le-ander opened this issue Feb 17, 2022 · 1 comment

Comments

@le-ander
Copy link
Member

le-ander commented Feb 17, 2022

if I convert a singlecellexperiment object with anndata2ri, obs columns which should be int32 have a weird dtype in pandas. this breaks writing the adata to disk with the fillowing h5py error:

TypeError: Object dtype dtype('O') has no native HDF5 equivalent
Above error raised while writing key 'nFeature_RNA' of <class 'h5py._hl.group.Group'> from /.
Above error raised while writing key 'nFeature_RNA' of <class 'h5py._hl.group.Group'> from /.
Above error raised while writing key 'obs' of <class 'h5py._hl.files.File'> from /.

this fixes the error:

>>> adata.obs["nFeature_RNA"].dtype
Int32Dtype()
>>> adata.obs["nFeature_RNA"] = adata.obs["nFeature_RNA"].astype(np.int32)
>>> adata.obs["nFeature_RNA"].dtype
dtype('int32')

no more error when writing the adata to disk after this

@ivirshup
Copy link
Member

I think the solution here would be for this library to not allow the nullable pandas dtypes. However, these do work in anndata 0.8.0, which you can try the release candidate of now.

The issue is that Int32Dtype() can have null values while dtype('int32') can't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants