harpy.sh.filter_shapes#
- harpy.sh.filter_shapes(sdata, table_name, labels_name, prefix_filtered_shapes_name)#
Filter shapes in a SpatialData object.
Instances that do not appear in
table_name(with region key equal tolabels_name) will be removed from the shapes elements, via the instance key ofsdata.tables[table_name].obs) and the index of the shapes elements in thesdataobject. Only shapes elements ofsdatain same coordinate system as thelabels_namewill be considered. Polygons that are filtered out from a shapes element (e.g. with name “shapes_example”) will be added as a new shapes element with nameprefix_filtered_shapes_name+ “_” + “shapes_example”.- Parameters:
sdata (
SpatialData) – The SpatialData object,table_name (
str) – The name of the table element.labels_name (
str) – The name of the labels element.prefix_filtered_shapes_name (
str) – The prefix for the name of the new shapes element consisting of the polygons that where filtered out from a shapes element.
- Return type:
- Returns:
: The updated
sdataobject.