sparrow.sh.filter_shapes_layer#
- sparrow.sh.filter_shapes_layer(sdata, table_layer, labels_layer, prefix_filtered_shapes_layer, shapes_layers_to_filter=None)#
Filter shapes in a SpatialData object.
Cells that do not appear in
table_layer(with_REGION_KEYequal tolabels_layer) will be removed from the shapes layers, via the_INSTANCE_KEYofsdata.tables[table_layer].obs) and the index of the shapes layers in thesdataobject. Only shapes layers ofsdatain same coordinate system as thelabels_layerwill 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.shapes_layers_to_filter (
list[str] |None(default:None)) – List of names of the shapes layers to filter. If None, all shapes layers insdatathat match the coordinate system of the labels layer will be filtered.
- Return type:
SpatialData- Returns:
: The updated
sdataobject.