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, 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_key
in.obs
. Run e.g.sp.tb.preprocess_transcriptomics
orsp.tb.preprocess_proteomics
to obtain cell sizes.- Parameters:
sdata (
SpatialData
) – The SpatialData object.labels_layer (
list
[str
]) – The labels layer(s) ofsdata
used to select the cells via the _REGION_KEY insdata.tables[table_layer].obs
. Note that ifoutput_layer
is equal totable_layer
and 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_KEY
equal tolabels_layer
) will be removed from the shapes layers (via_INSTANCE_KEY
) in thesdata
object. Filtered shapes will be added tosdata
with prefix ‘filtered_size’.cellsize_key (default:
'shapeSize'
) – Column insdata.tables[table_layer].obs
containing cell sizes.overwrite (
bool
(default:False
)) – If True, overwrites theoutput_layer
if it already exists insdata
.
- Return type:
SpatialData
- Returns:
: The updated SpatialData object.