Skip to content

No warning when the manually specified table doesn't actually annotate the labels element #467

Description

@timtreis
Image

I forgot to set the spatialdata_attrs so the function was generating random colors for my labels - instead it should've failed and told me that the table doesn't annotate that labels object.

Activity

  1. timtreis commented on May 24, 2025

    @timtreis
    MemberAuthor

    Correct plot after setting it:

    Image
  2. VikramGanesanjs commented on Sep 9, 2025

    @VikramGanesanjs

    @timtreis I am having the same issue, could you explain how you are supposed to set the spatialdata_attrs to make this work? I've tried replacing the table.uns['spatialdata_attrs']['region_key'] with 'leiden', but it throws the error (Regions in the AnnData object and leiden do not match.)

  3. timtreis commented on Sep 11, 2025

    @timtreis
    MemberAuthor

    Hey @VikramGanesanjs,

    here you can find an example on how to manually set it: https://github.com/scverse/spatialdata-notebooks/blob/main/notebooks/examples/sdata_from_scratch.ipynb

    the tl;dr is like this:

    table.uns["spatialdata_attrs"] = {
        "region": "<name of the sdata element it annotates>",  
        "region_key": "<column in adata.obs that will link a given obs to the elements it annotates, same entry as region>",
        "instance_key": "<column that matches a given obs in the table to a given circle by id>",
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions