Upgrading from 0.7.5 to 0.7.6 throws TypeError when saving h5ad
See original GitHub issueWhen loading an h5ad and combining it with various annotations, the object is saved as:
mergedData.write(par["output"], compression = "gzip")
This results in the following exception
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/anndata/_io/utils.py", line 209, in func_wrapper
return func(elem, key, val, *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/anndata/_io/h5ad.py", line 270, in write_series
group.create_dataset(
File "/usr/local/lib/python3.8/site-packages/h5py/_hl/group.py", line 148, in create_dataset
dsid = dataset.make_new_dset(group, shape, dtype, data, name, **kwds)
File "/usr/local/lib/python3.8/site-packages/h5py/_hl/dataset.py", line 140, in make_new_dset
dset_id.write(h5s.ALL, h5s.ALL, data)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5d.pyx", line 232, in h5py.h5d.DatasetID.write
File "h5py/_proxy.pyx", line 145, in h5py._proxy.dset_rw
File "h5py/_conv.pyx", line 444, in h5py._conv.str2vlen
File "h5py/_conv.pyx", line 95, in h5py._conv.generic_converter
File "h5py/_conv.pyx", line 249, in h5py._conv.conv_str2vlen
TypeError: Can't implicitly convert non-string objects to strings
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/anndata/_io/utils.py", line 209, in func_wrapper
return func(elem, key, val, *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/anndata/_io/h5ad.py", line 263, in write_dataframe
write_series(group, col_name, series, dataset_kwargs=dataset_kwargs)
File "/usr/local/lib/python3.8/site-packages/anndata/_io/utils.py", line 212, in func_wrapper
raise type(e)(
TypeError: Can't implicitly convert non-string objects to strings
Above error raised while writing key 'highly_variable' of <class 'h5py._hl.group.Group'> from /.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/tmp/viash-run-mergeabtogex-GbM6xh", line 73, in <module>
mergedData.write(par["output"], compression = "gzip")
File "/usr/local/lib/python3.8/site-packages/anndata/_core/anndata.py", line 1905, in write_h5ad
_write_h5ad(
File "/usr/local/lib/python3.8/site-packages/anndata/_io/h5ad.py", line 112, in write_h5ad
write_attribute(f, "var", adata.var, dataset_kwargs=dataset_kwargs)
File "/usr/local/lib/python3.8/functools.py", line 875, in wrapper
return dispatch(args[0].__class__)(*args, **kw)
File "/usr/local/lib/python3.8/site-packages/anndata/_io/h5ad.py", line 130, in write_attribute_h5ad
_write_method(type(value))(f, key, value, *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/anndata/_io/utils.py", line 212, in func_wrapper
raise type(e)(
TypeError: Can't implicitly convert non-string objects to strings
Above error raised while writing key 'highly_variable' of <class 'h5py._hl.group.Group'> from /.
Above error raised while writing key 'var' of <class 'h5py._hl.files.File'> from /.
This is specific for version 0.7.6 as the build tests that we perform do work for the same data on 0.7.5. Please note that this also impacts the scirpy package as the following code also returns a similar exception, just on a different column:
import anndata
import scanpy as sc
import scirpy
data = sc.read_h5ad(par["input"])
contigs = scirpy.io.read_10x_vdj(par["input_vdj"])
scirpy.pp.merge_with_ir(data, contigs)
data.write(par["output"], compression = "gzip")
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Upgrading from 0.7.5 to 0.7.6 throws TypeError when ... - GitHub
When loading an h5ad and combining it with various annotations, the object is saved as: mergedData.write(par["output"], ...
Read more >Upgrading from Opencore 0.6.5 to 0.7.6. Any gotchas/things to ...
6 I found this setting in the Config. plist that ships with OC 0.7. 6 to be True. Once I set it to...
Read more >Release notes — anndata 0.9.0.dev36+g18078aa ...
Documented how to use alternative compression methods for the h5ad file format ... Passing ambiguous keys to obs_vector() and var_vector() now throws errors ......
Read more >new-10kPBMC-Scanpy
Save the raw data in a separate slot. For this, we set the .raw attribute of the AnnData object to the normalized and...
Read more >Error After Updating to OpenCore 0.7.5 - Intel-based Systems
Hello, I updated from OpenCore 0.6.2 to 0.7.5 on my MSI Z490-A PRO, i5-10400, GTX 780 build and changed my config.plist file accordingly....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We are indeed merging different datasets together in this component on the var slot. This results in the following dtypes on the var slots
The problem is that during the merge we have a var column that does not exist in a dataset. Therefore adding with pandas.concat results in an object type instead of bool. As a quick fix I tried using the convert_dtypes() functionality but this results in setting the boolean dtype which does not solve the issue either.
For the time being I’m going to pin the version of anndata for these components.
Closing as duplicate of #504