Hi,
just ran into this issue with the most recent anndata(0.13.2) and napari_spatialdata (0.7.2):
I can't visualize Vars on Labels elements in the interactive viewer.
To reproduce:
napari_spatialdata=0.7.2
anndata=0.13.2
from spatialdata.datasets import blobs
from napari_spatialdata import Interactive
sdata = blobs()
Interactive(sdata)
- select
blobs_labels as the Element
- select any of
channel_0_sum, ... as Vars
results in this error (and the viewer doesn't colorcode accordingly)
2026-07-27 11:41:51.724 | DEBUG | napari_spatialdata._view:_on_layer_update:564 - Updating layer.
2026-07-27 11:41:51.742 | DEBUG | napari_spatialdata._view:_on_layer_update:564 - Updating layer.
Traceback (most recent call last):
File "envs/xenium/lib/python3.12/site-packages/napari_spatialdata/_widgets.py", line 67, in <lambda>
self.itemDoubleClicked.connect(lambda item: self._onAction((item.text(),)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "envs/xenium/lib/python3.12/site-packages/napari_spatialdata/_widgets.py", line 136, in _onAction
vec, name, index = self._getter(item, index=self.getIndex())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "envs/xenium/lib/python3.12/site-packages/napari/utils/_proxies.py", line 197, in __call__
return self.create(self.__wrapped__(*args, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "envs/xenium/lib/python3.12/site-packages/napari_spatialdata/utils/_utils.py", line 58, in decorator
res, name, index = fn(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "envs/xenium/lib/python3.12/site-packages/napari_spatialdata/_model.py", line 139, in get_var
column = self.adata._get_X(layer=self.adata_layer)[ix]
^^^^^^^^^^^^^^^^^
AttributeError: 'AnnData' object has no attribute '_get_X'
the problem
Napari is trying to call this non-existant _get_X method on the AnnData. I quickly check the anndata source,
there used to be a method AnnData._get_X() in anndata==0.12, but they have removed it in 0.13 (nothing mentioned in the release notes though)
Possible fixes:
- set
anndata<0.13 for this project (and _get_X() will be available)
- fix the issue in napari_spatialdata and force
anndata>=0.13:
# change src/napari_spatialdata/_model.py:line139 from
# column = self.adata._get_X(layer=self.adata_layer)[ix]
# to
column = self.adata.layers[self.adata_layer][ix]
I don't see how to do a clean backwards compatible change working with both anndata 0.12 and 0.13, probably requires some hack checking package versions in the code
Hi,
just ran into this issue with the most recent anndata(0.13.2) and napari_spatialdata (0.7.2):
I can't visualize
VarsonLabelselements in the interactive viewer.To reproduce:
blobs_labelsas the Elementchannel_0_sum, ... asVarsresults in this error (and the viewer doesn't colorcode accordingly)
the problem
Napari is trying to call this non-existant
_get_Xmethod on the AnnData. I quickly check theanndatasource,there used to be a method
AnnData._get_X()inanndata==0.12, but they have removed it in0.13(nothing mentioned in the release notes though)Possible fixes:
anndata<0.13for this project (and_get_X()will be available)anndata>=0.13:I don't see how to do a clean backwards compatible change working with both anndata 0.12 and 0.13, probably requires some hack checking package versions in the code