pt.tl.Dialogue().calculate_multifactor_PMD() adds MCPs to .obs with int keys instead of str leading to error on adata.write_h5ad():
Traceback (most recent call last):
File "/Users/eliaskahl/miniconda3/envs/pertpy-apple-silicon/lib/python3.10/site-packages/anndata/_io/utils.py", line 214, in func_wrapper
return func(elem, key, val, *args, **kwargs)
File "/Users/eliaskahl/miniconda3/envs/pertpy-apple-silicon/lib/python3.10/site-packages/anndata/_io/specs/registry.py", line 175, in write_elem
_REGISTRY.get_writer(dest_type, t, modifiers)(f, k, elem, *args, **kwargs)
File "/Users/eliaskahl/miniconda3/envs/pertpy-apple-silicon/lib/python3.10/site-packages/anndata/_io/specs/registry.py", line 24, in wrapper
result = func(g, k, *args, **kwargs)
File "/Users/eliaskahl/miniconda3/envs/pertpy-apple-silicon/lib/python3.10/site-packages/anndata/_io/specs/methods.py", line 499, in write_dataframe
col_names = [check_key(c) for c in df.columns]
File "/Users/eliaskahl/miniconda3/envs/pertpy-apple-silicon/lib/python3.10/site-packages/anndata/_io/specs/methods.py", line 499, in <listcomp>
col_names = [check_key(c) for c in df.columns]
File "/Users/eliaskahl/miniconda3/envs/pertpy-apple-silicon/lib/python3.10/site-packages/anndata/_io/utils.py", line 109, in check_key
raise TypeError(f"{key} of type {typ} is an invalid key. Should be str.")
TypeError: 0 of type <class 'int'> is an invalid key. Should be str.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/eliaskahl/workspace/github.com/theislab-gobi-sc-dialogue/dialogue-experiments-elias/mre-mcp-str-keys.py", line 19, in <module>
adata.write_h5ad("data/dialogue-example_pmd.h5ad")
File "/Users/eliaskahl/miniconda3/envs/pertpy-apple-silicon/lib/python3.10/site-packages/anndata/_core/anndata.py", line 1918, in write_h5ad
_write_h5ad(
File "/Users/eliaskahl/miniconda3/envs/pertpy-apple-silicon/lib/python3.10/site-packages/anndata/_io/h5ad.py", line 98, in write_h5ad
write_elem(f, "obs", adata.obs, dataset_kwargs=dataset_kwargs)
File "/Users/eliaskahl/miniconda3/envs/pertpy-apple-silicon/lib/python3.10/site-packages/anndata/_io/utils.py", line 220, in func_wrapper
raise type(e)(
TypeError: 0 of type <class 'int'> is an invalid key. Should be str.
Report
pt.tl.Dialogue().calculate_multifactor_PMD()
adds MCPs to.obs
withint
keys instead ofstr
leading to error onadata.write_h5ad()
:Minimal reproducible example:
Version information
pertpy 0.4.0 scanpy 1.9.2 session_info 1.0.0
PIL 9.4.0 PyQt5 NA adjustText NA anndata 0.8.0 arrow 1.2.3 arviz 0.14.0 asttokens NA attr 22.1.0 backcall 0.2.0 certifi 2022.12.07 cffi 1.15.1 cftime 1.6.2 charset_normalizer 3.0.1 comm 0.1.2 custom_inherit 2.4.1 cycler 0.10.0 cython_runtime NA dateutil 2.8.2 decorator 5.1.1 decoupler 1.3.3 defusedxml 0.7.1 entrypoints 0.4 ete3 3.1.2 executing 0.8.3 fontTools 4.38.0 google NA h5py 3.8.0 idna 3.4 igraph 0.10.4 ipykernel 6.19.2 ipython_genutils 0.2.0 ipywidgets 7.6.5 jax 0.4.4 jaxlib 0.4.4 jedi 0.18.1 jinja2 3.1.2 joblib 1.2.0 kiwisolver 1.4.4 leidenalg 0.9.1 llvmlite 0.39.1 markupsafe 2.1.1 matplotlib 3.7.0 mizani 0.8.1 mpl_toolkits NA mudata 0.2.1 multipledispatch 0.6.0 muon 0.1.3 natsort 8.2.0 netCDF4 1.6.2 numba 0.56.4 numpy 1.23.5 numpyro 0.10.1 opt_einsum v3.3.0 packaging 22.0 palettable 3.3.0 pandas 1.5.3 parso 0.8.3 patsy 0.5.3 pexpect 4.8.0 pickleshare 0.7.5 pkg_resources NA platformdirs 2.5.2 plotnine 0.10.1 ply 3.11 png 0.20220715.0 prompt_toolkit 3.0.36 psutil 5.9.0 ptyprocess 0.7.0 pure_eval 0.2.2 pycparser 2.21 pygments 2.11.2 pynndescent 0.5.8 pyomo 6.5.0 pyparsing 3.0.9 pypi_latest 0.1.2 pytz 2022.7 questionary 1.10.0 reportlab 3.6.12 requests 2.28.2 rich NA rpy2 3.5.8 scipy 1.10.1 seaborn 0.11.2 setuptools 65.6.3 sip NA six 1.16.0 sklearn 1.2.1 skmisc 0.1.4 sparsecca 0.3.0 stack_data 0.2.0 statannotations 0.5.0 statsmodels 0.13.5 switchlang 0.1.0 texttable 1.6.7 threadpoolctl 3.1.0 tornado 6.2 toyplot 1.0.3 toytree 2.0.1 tqdm 4.64.1 traitlets 5.7.1 typing_extensions NA tzlocal NA umap 0.5.3 urllib3 1.26.14 wcwidth 0.2.5 xarray 2023.2.0 xarray_einstats 0.5.1 zmq 23.2.0 zoneinfo NA
IPython 8.10.0 jupyter_client 7.4.9 jupyter_core 5.2.0 notebook 6.5.2
Python 3.10.9 | packaged by conda-forge | (main, Feb 2 2023, 20:26:08) [Clang 14.0.6 ] macOS-13.1-arm64-arm-64bit
Session information updated at 2023-03-01 13:34