harpy.tb.filter_on_size#
- harpy.tb.filter_on_size(sdata, labels_name, table_name, output_table_name, min_size=100, max_size=100000, update_shapes_elements=True, instance_size_key='shapeSize', overwrite=False)#
Returns the updated SpatialData object.
All cells with a size outside of the min and max size range are removed using the
instance_size_keyin.obs. Run e.g.preprocess_transcriptomics()orpreprocess_proteomics()to obtain cell sizes.- Parameters:
sdata (
SpatialData) – The SpatialData object.labels_name (
list[str]) – The labels element(s) ofsdataused to select the cells via the region key insdata.tables[table_name].obs. Note that ifoutput_table_nameis equal totable_nameand overwrite is True, cells insdata.tables[table_name]linked to otherlabels_name(via the region key), will be removed fromsdata.tables[table_name](also from the backing zarr store if it is backed).table_name (
str) – The table element insdata.output_table_name (
str) – The output table element insdata.min_size (
int(default:100)) – minimum size in pixels.max_size (
int(default:100000)) – maximum size in pixels.update_shapes_elements (
bool(default:True)) – Whether to filter the shapes elements associated withlabels_name. If set toTrue, cells that do not appear in resultingoutput_table_name(with region key equal tolabels_name) will be removed from the shapes elements (via instance key) in thesdataobject. Filtered shapes will be added tosdatawith prefix ‘filtered_size’. This parameter is deprecated, and will be removed in a future version.instance_size_key (
str(default:'shapeSize')) – Column insdata.tables[table_name].obscontaining instance sizes.overwrite (
bool(default:False)) – If True, overwrites theoutput_table_nameif it already exists insdata.
- Return type:
- Returns:
: The updated SpatialData object.