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

render_shapes() with color argument fails on Merfish data

Open ConstensouxAlexis opened this issue 7 months ago • 0 comments

Hi, I work with spatialdata 0.3.0, and spatialdata_plot 0.2.9. When calling render_shapes() on Merfish data, with a color argument, plot fails with error: ValueError: cannot insert EntityID, already exists. This error is raised when calling reset_index() on table.obs, because columns EntityID already exists.

However, if I delete column EntityID in table.obs, render_shapes fails with error ValidationError: Cannot construct SpatialData object, input contains invalid elements. For renaming, please see the discussion here https://github.com/scverse/spatialdata/discussions/707. tables/table: EntityIDnot found inadata.obs. Please create the column.

Works fine: sdata.pl.render_shapes( element=shapes_key, ).pl.show( coordinate_systems='global' )

Raises ValueError: sdata.pl.render_shapes( element=shapes_key, color="any column" ).pl.show( coordinate_systems='global' )

Raises ValidationError: del sdata[table_key].obs["EntityID"] sdata.pl.render_shapes( element=shapes_key, color="any column" ).pl.show( coordinate_systems='global' )

The same problem is caused by "EntityID" column in sdata["shapes"]. The easiest workaround is to rename table.obs index if table.obs.index.name == "EntityID", and to delete "EntityID" column in the shapes, or just to allow duplicates in reset_index()

ConstensouxAlexis avatar Apr 07 '25 09:04 ConstensouxAlexis