Skip to content

ValueError: Value passed for key scanorama_embedding is of incorrect shape #2143

@zappuf

Description

@zappuf
  • 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.

When running the Integrating spatial data with scRNA-seq using scanorama tutorial with the provided sample data, the following error occurs.

This may be related to the following warning I also see

<string>:6: VisibleDeprecationWarning: Creating an ndarray from nested sequences exceeding the maximum number of dimensions of 32 is deprecated. If you mean to do this, you must specify 'dtype=object' when creating the ndarray.

How can I overcome this issue?

Example code below has how I downloaded the data in the Data integration and label transfer from scRNA-seq dataset section of the tutorial and then just the code block where the error actually occurs.


Minimal code sample (that we can copy&paste without having any data)

scanorama_error

import subprocess
from pathlib import Path

if Path('./downloaded_data/adata_processed.h5ad').is_file():
    print("Data previously downloaded, skipping to next step")
else:
    subprocess.run(['wget', '-O', './downloaded_data/adata_processed.h5ad', 'https://hmgubox.helmholtz-muenchen.de/f/4ef254675e2a41f89835/?dl=1'])

adata_cortex = sc.read("./downloaded_data/adata_processed.h5ad")


embedding_anterior = np.concatenate(integrated_anterior, axis=0)
adata_cortex_anterior.obsm["scanorama_embedding"] = embedding_anterior

embedding_posterior = np.concatenate(integrated_posterior, axis=0)
adata_cortex_posterior.obsm["scanorama_embedding"] = embedding_posterior
<string>:6: VisibleDeprecationWarning: Creating an ndarray from nested sequences exceeding the maximum number of dimensions of 32 is deprecated. If you mean to do this, you must specify 'dtype=object' when creating the ndarray.

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/tmp/ipykernel_134148/2515279522.py in <module>
      1 embedding_anterior = np.concatenate(integrated_anterior, axis=0)
----> 2 adata_cortex_anterior.obsm["scanorama_embedding"] = embedding_anterior
      3 
      4 embedding_posterior = np.concatenate(integrated_posterior, axis=0)
      5 adata_cortex_posterior.obsm["scanorama_embedding"] = embedding_posterior

/opt/conda/lib/python3.7/site-packages/anndata/_core/aligned_mapping.py in __setitem__(self, key, value)
    149 
    150     def __setitem__(self, key: str, value: V):
--> 151         value = self._validate_value(value, key)
    152         self._data[key] = value
    153 

/opt/conda/lib/python3.7/site-packages/anndata/_core/aligned_mapping.py in _validate_value(self, val, key)
    213                 f"value.index does not match parent’s axis {self.axes[0]} names"
    214             )
--> 215         return super()._validate_value(val, key)
    216 
    217     @property

/opt/conda/lib/python3.7/site-packages/anndata/_core/aligned_mapping.py in _validate_value(self, val, key)
     51                 right_shape = tuple(self.parent.shape[a] for a in self.axes)
     52                 raise ValueError(
---> 53                     f"Value passed for key {key!r} is of incorrect shape. "
     54                     f"Values of {self.attrname} must match dimensions "
     55                     f"{self.axes} of parent. Value had shape {val.shape} while "

ValueError: Value passed for key 'scanorama_embedding' is of incorrect shape. Values of obsm must match dimensions (0,) of parent. Value had shape (22272, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1) while it should have had (23238,).

Versions

Details

anndata 0.7.8
scanpy 1.8.2
sinfo 0.3.1

PIL 9.0.1
anndata 0.7.8
annoy NA
backcall 0.2.0
beta_ufunc NA
binom_ufunc NA
cached_property 1.5.2
cffi 1.15.0
colorama 0.4.4
cycler 0.10.0
cython_runtime NA
dateutil 2.8.2
debugpy 1.5.1
decorator 5.1.1
defusedxml 0.7.1
entrypoints 0.4
fbpca NA
h5py 3.6.0
igraph 0.9.9
intervaltree NA
ipykernel 6.9.0
ipython_genutils 0.2.0
ipywidgets 7.6.5
jedi 0.18.1
joblib 1.1.0
jupyter_server 1.13.5
kiwisolver 1.3.2
leidenalg 0.8.8
llvmlite 0.38.0
louvain 0.7.1
matplotlib 3.5.1
matplotlib_inline NA
mpl_toolkits NA
natsort 8.1.0
nbinom_ufunc NA
numba 0.55.1
numexpr 2.8.0
numpy 1.21.5
packaging 21.3
pandas 1.3.5
parso 0.8.3
pexpect 4.8.0
pickleshare 0.7.5
pkg_resources NA
prompt_toolkit 3.0.27
psutil 5.9.0
ptyprocess 0.7.0
pycparser 2.21
pydev_ipython NA
pydevconsole NA
pydevd 2.6.0
pydevd_concurrency_analyser NA
pydevd_file_utils NA
pydevd_plugins NA
pydevd_tracing NA
pygments 2.11.2
pynndescent 0.5.6
pyparsing 3.0.7
pytz 2021.3
scanorama 1.7.1
scanpy 1.8.2
scipy 1.7.3
seaborn 0.11.2
setuptools 59.8.0
sinfo 0.3.1
six 1.16.0
sklearn 1.0.2
sortedcontainers 2.4.0
sphinxcontrib NA
statsmodels 0.13.2
storemagic NA
tables 3.7.0
texttable 1.6.4
threadpoolctl 3.1.0
tornado 6.1
tqdm 4.62.3
traitlets 5.1.1
typing_extensions NA
umap 0.5.2
wcwidth 0.2.5
yaml 6.0
zipp NA
zmq 22.3.0

IPython 7.31.1
jupyter_client 7.1.2
jupyter_core 4.9.1
jupyterlab 3.2.9
notebook 6.4.8

Python 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 06:08:53) [GCC 9.4.0]
Linux-3.10.0-1062.1.2.el7.x86_64-x86_64-with-debian-10.10
72 logical CPU cores

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions