lazyslide.tl.spatial_domain#
- spatial_domain(wsi, feature_key, tile_key='tiles', layer=None, resolution=0.1, key_added='domain')#
Perform unsupervised spatial domain segmentation on a WSI using feature embeddings.
This function applies scaling, PCA, neighborhood graph construction, and Leiden clustering to identify spatial domains within the WSI based on the provided features.
- Parameters:
- wsi
WSIData The whole-slide image object.
- feature_keystr
The key for the feature table to use.
- tile_keystr, default: “tiles”
The key for the tile table.
- layerstr, optional
The layer in the feature table to use for clustering.
- resolutionfloat, optional
The resolution parameter for Leiden clustering. Defaults to 0.1.
- key_addedstr, optional
The key under which to store the domain labels. Defaults to “domain”.
- wsi
- Returns:
- None
The domain labels are added to the tile table in the WSIData object.
Examples
>>> import lazyslide as zs >>> wsi = zs.datasets.sample() >>> zs.pp.find_tissues(wsi) >>> zs.pp.tile_tissues(wsi, 256, mpp=0.5) >>> zs.tl.feature_extraction(wsi, "resnet50") >>> zs.pp.tile_graph(wsi) >>> zs.tl.spatial_features(wsi, "resnet50") >>> zs.tl.spatial_domain(wsi, layer="spatial_features", feature_key="resnet50", resolution=0.3)