harpy.sh.filter_shapes

Contents

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 to labels_name) will be removed from the shapes elements, via the instance key of sdata.tables[table_name].obs) and the index of the shapes elements in the sdata object. Only shapes elements of sdata in same coordinate system as the labels_name will 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 name prefix_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:

SpatialData

Returns:

: The updated sdata object.