Plotting certain dataframe annotation columns into the points leads to an error.
Easy to reproduce:
from spatialdata.datasets import blobs
from napari_spatialdata import Interactive
Interactive(blobs())
The annotation:
global > blobs_points > Dataframe columns: instance_id can be plotted
global > blobs_points > Dataframe columns: genes cannot be plotted and gives the following error:
...
File ~/embl/projects/basel/napari-spatialdata/src/napari_spatialdata/_widgets.py:200, in AListWidget._(self=<napari_spatialdata._widgets.AListWidget object>, vec=0 gene_b
1 gene_b
2 gene_b
3 ...gory
Categories (2, object): ['gene_a', 'gene_b'], **kwargs={'key': 'genes'})
198 element_indices = element_indices[element_indices != 0]
199 # When merging if the row is not present in the other table it will be nan so we can give it a default color
--> 200 if (vec_color_name := vec.name + "_color") not in self.model.adata.uns:
vec_color_name = 'genes_color'
vec = 0 gene_b
1 gene_b
2 gene_b
3 gene_a
4 gene_b
...
195 gene_a
196 gene_b
197 gene_a
198 gene_a
199 gene_a
Name: genes, Length: 200, dtype: category
Categories (2, object): ['gene_a', 'gene_b']
self = <napari_spatialdata._widgets.AListWidget object at 0x333907760>
201 colorer = AnnData(shape=(len(vec), 0), obs=pd.DataFrame(index=vec.index, data={"vec": vec}))
202 _set_colors_for_categorical_obs(colorer, "vec", palette="tab20")
AttributeError: 'NoneType' object has no attribute 'uns'
Plotting certain dataframe annotation columns into the points leads to an error.
Easy to reproduce:
The annotation:
global > blobs_points > Dataframe columns: instance_id
can be plottedglobal > blobs_points > Dataframe columns: genes
cannot be plotted and gives the following error:AttributeError: 'NoneType' object has no attribute 'uns'