Skip to content

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

Description

@le-ander

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions