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 tolabels_layer
) will be removed from the shapes layers, via the_INSTANCE_KEY
ofsdata.tables[table_layer].obs
) and the index of the shapes layers in thesdata
object. Only shapes layers ofsdata
in same coordinate system as thelabels_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 nameprefix_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.