Skip to content

Registering a new table with a coordinate system #573

Closed

Description

@pakiessling

Hi there.

I am playing around with Spatialdata and the Visium HD release and I want to do the following:

I have a Spatialdata object created with spatialdata.io.visium_hd and annotations from Napari.
I also have a new anndata object from this dataset that I created by segmenting the HE image and assigning bins to Nuclei.
This anndata object has (X,Y) centroids of segmented cells in adata.obsm["spatial"]

How can I correctly add this as a new table to the sdata, such that polygon_query will operate on the (X,Y) centroids?
Is it necessary to add the segmented shapes to which the centroids belong first?

I tried:

adata.obs["region"] = 'Visium_HD_Human_Colon_Cancer_nuclei'
table = TableModel.parse(adata, region="Visium_HD_Human_Colon_Cancer_nuclei", region_key="region", instance_key="id")
sdata.tables["nuclei_segment"] = table

But polygon_query removes the new table from the returned object.

Thank you!

Activity

  1. pakiessling commented on May 31, 2024

    @pakiessling
    Author

    Nevermind.
    When I added the segmented shapes first everything works nicely.

    from spatialdata.models import TableModel
    from spatialdata.models import ShapesModel
    shapes = ShapesModel.parse(shapes)
    sdata.shapes["nuclei"] = shapes
    adata.obs["region"] = 'nuclei'
    adata.obs["id"] = sdata.shapes["nuclei"].index
    table = TableModel.parse(adata, region="nuclei", region_key="region", instance_key="id")
    sdata.tables["nuclei_segment"] = table
    
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions