- dynamo.tl.leiden(adata, resolution=1.0, use_weight=False, weights=None, initial_membership=None, adj_matrix=None, adj_matrix_key=None, seed=None, result_key=None, layer=None, obsm_key=None, selected_cluster_subset=None, selected_cell_subset=None, directed=True, copy=False, **kwargs)
Apply leiden clustering to the input adata.
For other general community detection related parameters, please refer to
The Leiden algorithm is an improvement of the Louvain algorithm. Based on the cdlib package, the Leiden algorithm consists of three phases: (1) local moving of nodes, (2) refinement of the partition, (3) aggregation of the network based on the refined partition, using the non-refined partition to create an initial partition for the aggregate network.
Please note that since 2/23/23, we have replaced the integrated louvain method from cdlib package with that from the original leidenalg package.
AnnData) – an adata object
float) – the resolution of the clustering that determines the level of detail in the clustering process. An increase in this value will result in the generation of a greater number of clusters.
bool) – whether to use the weight of the edges in the clustering process. Default False.
int]]]) – a tuple of 2 elements (cluster_key, allowed_clusters) filtering cells in adata based on cluster_key in adata.obs and only reserves cells in the allowed clusters.
bool) – whether the graph is directed.
bool) – return a copy instead of writing to adata.
**kwargs – additional arguments to pass to the cluster_community function.
An updated AnnData object with the leiden clustering results added. The adata is updated up with the result_key key to use for saving clustering results which will be included in both adata.obs and adata.uns. adata.obs[result_key] saves the clustering identify of each cell where the adata.uns[result_key] saves the relevant parameters for the leiden clustering .
- Return type: