Skip to content

render_shapes() with color argument fails on Merfish data #441

@ConstensouxAlexis

Description

@ConstensouxAlexis

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions