spatialdata-plot icon indicating copy to clipboard operation
spatialdata-plot copied to clipboard

Plotting shapes with colouring by table.obs column (categorical as string) does not work

Open Pigrenok opened this issue 1 month ago • 0 comments

I have a very simple example. I have a cropped spatialdata object

test.zarr.tar.gz

I am trying to plot shapes 'nucleus_boundaries' with colouring by 'ident_add' column from 'table'. But I get all shapes in grey colour.

Interestingly, if I use another shapes, which is related to another table (not in this example sdata object, but in a larger one, from which this was extracted), it works fine with cropping (using polygon query).

In that full sdata object there are shapes which are related to 'table' (generated by baysor segmentation) and 'nucleus_boundaries' related to 'old table'. Here though, I tried to not filter table and set table_name to old_table. Did not work. Tried to move 'old_table' to 'table' and removed table_name parameter from render_shapes. Then I filtered 'table'

anndata = sdata_cropped['table']
sdata_cropped['table'] = anndata[sdata_cropped['nucleus_boundaries'].index]

and then tried to plot as follows:

sdata_cropped.pl.render_shapes('nucleus_boundaries', color='ident_add', table_name='table').pl.show()

And get the following

Image

Am I doing something wrong or is there a bug somewhere in the plotting routine? What am I doing wrong?

Pigrenok avatar Oct 09 '25 23:10 Pigrenok