spatialleiden.search_resolution

spatialleiden.search_resolution(adata, n_clusters, *, start=(1.0, 0.4), step=0.1, n_iter=15, latent_kwargs=None, spatial_kwargs=None)

Search the resolutions of the spatial and latent space layer to obtain n clusters using SpatialLeiden clustering.

Parameters:
  • adata (AnnData)

  • n_clusters (int) – Number of clusters.

  • start (tuple[float, float], optional) – Starting points for resolution, latent and spatial layer, respectively.

  • step (float, optional) – Increment if cluster number is incorrect.

  • n_iter (int, optional) – Maximum number of iterations before stopping. If correct number of clusters is obtained it will stop early.

  • latent_kwargs (dict | None, optional) – Keyword arguments passed to spatialleiden.leiden().

  • spatial_kwargs (dict | None, optional) – Keyword arguments passed to spatialleiden.spatialleiden().

Returns:

Target resolution for the latent space and spatial layer.

Return type:

tuple[float, float]