sparrow.sh.filter_shapes_layer

sparrow.sh.filter_shapes_layer#

sparrow.sh.filter_shapes_layer(sdata, table_layer, labels_layer, prefix_filtered_shapes_layer)#

Filter shapes in a SpatialData object.

Cells that do not appear in table_layer (with _REGION_KEY equal to labels_layer) will be removed from the shapes layers, via the _INSTANCE_KEY of sdata.tables[table_layer].obs) and the index of the shapes layers in the sdata object. Only shapes layers of sdata in same coordinate system as the labels_layer will be considered. Polygons that are filtered out from a shapes layer (e.g. with name “shapes_example”) will be added as a new shapes layer with name prefix_filtered_shapes_layer + “_” + “shapes_example”.

Parameters:
  • sdata (SpatialData) – The SpatialData object,

  • table_layer (str) – The name of the table layer.

  • labels_layer (str) – The name of the labels layer.

  • prefix_filtered_shapes_layer (str) – The prefix for the name of the new shapes layer consisting of the polygons that where filtered out from a shapes layer.

Return type:

SpatialData

Returns:

: The updated sdata object.