scverse / scverse/scanpy

TypeError: Can't implicitly convert non-string objects to strings

Open
#2,321 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.6k
Forks
779
Avg merge
1d 4h
Merged PRs (30d)
27

Description

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of scanpy.
  • (optional) I have confirmed this bug exists on the master branch of scanpy.

Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.

Minimal code sample (that we can copy&paste without having any data)
combined_data.var["highly_variable_intersection-0"] = combined_data.var["highly_variable_intersection-0"].astype(str) 

combined_data.write(f"{workspace}Data/Models/Healthy/combined_hvgs_recalculated.h5ad")
TypeError: Can't implicitly convert non-string objects to strings

Above error raised while writing key 'highly_variable_intersection-0' of <class 'h5py._hl.group.Group'> to /

anndata == 0.8.0
scanpy == 1.9.1

I tried converting the columns into various datatypes like str, bool, object, category but that did not help.
What is stranger is, that I even deleted this column ( both via del and drop). It solved the issue for another user but for me the same error persists, even after confirming that the column is indeed deleted.

[Paste the output of scanpy.logging.print_versions() leaving a blank line after the details tag]


anndata 0.8.0
scanpy 1.9.1

PIL 9.2.0
absl NA
asttokens NA
attr 21.4.0
backcall 0.2.0
beta_ufunc NA
binom_ufunc NA
certifi 2022.06.15
cffi 1.15.1
charset_normalizer 2.1.0
chex 0.1.3
colorama 0.4.5
cycler 0.10.0
cython_runtime NA
dateutil 2.8.2
debugpy 1.6.0
decorator 5.1.1
defusedxml 0.7.1
deprecate 0.3.2
docrep 0.3.2
entrypoints 0.4
etils 0.6.0
executing 0.8.3
flatbuffers 2.0
flax 0.5.2
fsspec 2022.5.0
google NA
h5py 3.7.0
hypergeom_ufunc NA
idna 3.3
igraph 0.9.11
iniconfig NA
ipykernel 6.15.1
ipython_genutils 0.2.0
ipywidgets 7.7.1
jax 0.3.14
jaxlib 0.3.14
jedi 0.18.1
joblib 1.1.0
kiwisolver 1.4.3
leidenalg 0.8.10
llvmlite 0.38.1
louvain 0.7.1
matplotlib 3.5.2
matplotlib_inline NA
mpl_toolkits NA
msgpack 1.0.4
mudata 0.2.0
multipledispatch 0.6.0
natsort 8.1.0
nbinom_ufunc NA
newick 1.0.0
numba 0.55.2
numpy 1.22.4
numpyro 0.10.0
opt_einsum v3.3.0
optax 0.1.3
packaging 21.3
pandas 1.4.3
parso 0.8.3
pexpect 4.8.0
pickleshare 0.7.5
pkg_resources NA
pluggy 1.0.0
prompt_toolkit 3.0.30
psutil 5.9.1
ptyprocess 0.7.0
pure_eval 0.2.2
py 1.11.0
pycparser 2.21
pydev_ipython NA
pydevconsole NA
pydevd 2.8.0
pydevd_file_utils NA
pydevd_plugins NA
pydevd_tracing NA
pygments 2.12.0
pyparsing 3.0.9
pyro 1.8.1
pytest 7.1.2
pytorch_lightning 1.6.5
pytz 2022.1
requests 2.28.1
rich NA
scHPL NA
scarches 0.5.3
scipy 1.8.1
scvi 0.17.1
seaborn 0.11.2
session_info 1.0.0
setuptools 63.1.0
six 1.16.0
sklearn 1.1.1
socks 1.7.1
stack_data 0.3.0
statsmodels 0.13.2
tensorboard 2.9.1
texttable 1.6.4
threadpoolctl 3.1.0
toolz 0.12.0
torch 1.12.0+cu102
torchmetrics 0.9.2
tornado 6.2
tqdm 4.64.0
traitlets 5.3.0
tree 0.1.7
typing_extensions NA
urllib3 1.26.10
wcwidth 0.2.5
wrapt 1.14.1
yaml 6.0
zmq 23.2.0

IPython 8.4.0
jupyter_client 7.3.4
jupyter_core 4.10.0
notebook 6.4.12

Python 3.10.5 | packaged by conda-forge | (main, Jun 14 2022, 07:04:59) [GCC 10.3.0]
Linux-3.10.0-1160.71.1.el7.x86_64-x86_64-with-glibc2.17

Session information updated at 2022-09-09 14:21
combined_data.write(f"{workspace}Data/Models/Healthy/combined_hvgs_recalculated.h5ad")
combined_data.write(f"{workspace}Data/Models/H

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the minimal combined_data.write(...) example with the reported anndata 0.8.0, scanpy 1.9.1, and h5py 3.7.0 environment. Inspect how the highly_variable_intersection-0 key is handled during writing, then establish whether the failure still occurs on a supported version and add regression coverage if a project defect is confirmed.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
bioinformatics, data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.