sparrow.tb.filter_on_size#
- sparrow.tb.filter_on_size(sdata, labels_layer, table_layer, output_layer, min_size=100, max_size=100000, update_shapes_layers=True, shapes_layers_to_filter=None, cellsize_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
cellsize_keyin.obs. Run e.g.sparrow.tb.preprocess_transcriptomicsorsparrow.tb.preprocess_proteomicsto obtain cell sizes.- Parameters:
sdata (
SpatialData) – The SpatialData object.labels_layer (
list[str]) – The labels layer(s) ofsdataused to select the cells via the _REGION_KEY insdata.tables[table_layer].obs. Note that ifoutput_layeris equal totable_layerand overwrite is True, cells insdata.tables[table_layer]linked to otherlabels_layer(via the _REGION_KEY), will be removed fromsdata.tables[table_layer](also from the backing zarr store if it is backed).table_layer (
str) – The table layer insdata.output_layer (
str) – The output table layer insdata.min_size (
int(default:100)) – minimum size in pixels.max_size (
int(default:100000)) – maximum size in pixels.update_shapes_layers (
bool(default:True)) – Whether to filter the shapes layers associated withlabels_layer. If set toTrue, cells that do not appear in resultingoutput_layer(with_REGION_KEYequal tolabels_layer) will be removed from the shapes layers (via_INSTANCE_KEY) in thesdataobject. Filtered shapes will be added tosdatawith prefix ‘filtered_size’.shapes_layers_to_filter (default:
None) – List of shapes layers to filter. If None, all shapes layers in same coordinate system as thelabels_layerwill be filtered, ifupdate_shapes_layersis True.cellsize_key (default:
'shapeSize') – Column insdata.tables[table_layer].obscontaining cell sizes.overwrite (
bool(default:False)) – If True, overwrites theoutput_layerif it already exists insdata.
- Return type:
SpatialData- Returns:
: The updated SpatialData object.