Skip to content

Is there a way to subset cell_boundaries using an AnnData table? #898

@Pancreas-Pratik

Description

@Pancreas-Pratik

This is what I have done with cell_circles, I was wondering if I could do the same with cell_boundaries?

Initially, I more or less did this to create a subset AnnData:

#keep cells that have 10 counts or greater (remove cells that have less than 10 counts)
sc.pp.filter_cells(sdata.tables["table"], min_counts=10)

#keep genes that are in 5 cells or greater (remove genes that are expressed in less than 5 cells)
sc.pp.filter_genes(sdata.tables["table"], min_cells=5)

and then I did this to subset cell_circles within the sdata:

sdata_filtered=spatialdata.match_sdata_to_table(sdata=sdata, table_name='table', table=sdata.tables["table"], how='right')
sdata_filtered

SpatialData object
├── Shapes
│     └── 'cell_circles': GeoDataFrame shape: (154472, 2) (2D shapes)
└── Tables
      └── 'table': AnnData (154472, 377)
with coordinate systems:
    ▸ 'global', with elements:
        cell_circles (Shapes)
sdata.shapes['cell_circles']=sdata_filtered.shapes['cell_circles']

Now, I was wondering if I could do something similar to this type of subset that was done on cell_circles, but if I could do it on cell_boundaries also. I tried match_element_to_table(), however it did not work, I could post the error if needed, but I suspect that this is known and expected.

I believe this has to do with the dimensions of GeoDataFrame shape, and how cell_circles appears to have "something" that cell_boundaries does not have:

'cell_boundaries': GeoDataFrame shape: (162254, 1) (2D shapes)
'cell_circles': GeoDataFrame shape: (154472, 2) (2D shapes)

Thank you very much in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions