spatialleiden.leiden

spatialleiden.leiden(adata, *, resolution=1, neighbors=None, key_added='leiden', directed=True, use_weights=True, n_iterations=-1, partition_type=<class 'leidenalg.VertexPartition.RBConfigurationVertexPartition'>, neighbors_key='connectivities', random_state=42, **partition_kwargs)

Perform Leiden clustering.

Parameters:
  • adata (AnnData)

  • resolution (float, optional) – Resolution for the partition. Controls the coarseness of the clustering.

  • neighbors (sparray | spmatrix | ndarray) – Matrix of row-wise neighbor definitions i.e. cij is the connectivity of i \(\to\) j.

  • key_added (str, optional) – Key to store the clustering results in anndata.AnnData.obs

  • directed (bool, optional) – Whether to use a directed graph.

  • use_weights (bool, optional) – Whether to use weights for the edges.

  • n_iterations (int, optional) – Number of iterations to run the Leiden algorithm. If the number is negative it runs until convergence.

  • partition_type (Type[leidenalg.VertexPartition.MutableVertexPartition], optional) – A leidenalg.VertexPartition.MutableVertexPartition to be used.

  • neighbors_key (str, optional) – Key to use for the neighbor connectivities in anndata.AnnData.obsp. Only used if neighbors is None.

  • random_state (int, optional) – Random seed.

  • partition_kwargs – Keyword arguments for the partition_type.