muon.tl.leiden

Contents

muon.tl.leiden#

muon.tl.leiden(data: MuData | AnnData, resolution: float | Sequence[float] | Mapping[str, float] | None = None, mod_weights: Sequence[float] | Mapping[str, float] | None = None, random_state: int = 0, key_added: str = 'leiden', neighbors_key: str = None, directed: bool = True, partition_type: Type[LeidenMutableVertexPartition] | None = None, partition_kwargs: Mapping[str, Any] = mappingproxy({}), **kwargs)#

Cluster cells using the Leiden algorithm.

This runs only the multiplex Leiden algorithm on the MuData object using connectivities of individual modalities (see documentation for more details). For that, scanpy.pp.neighbors() should be run first for each modality.

For taking use of mdata.obsp['connectivities'], it’s scanpy.tl.leiden() that should be used. See scanpy.tl.leiden() for details.

Parameters:
  • datamuon.MuData object.

  • resolution – Resolution parameter controlling coarseness of the clustering (higher values -> more clusters). To use different resolution per modality, dictionary {mod: value} or list/tuple [value_mod1, value_mod2, ...]. Single value to use the same resolution for all modalities.

  • mod_weights – Weight each modality controlling its contribution (higher values -> more important). To use different weight per modality, dictionary {mod: value} or list/tuple [value_mod1, value_mod2, ...]. Single value to use the same weight for all modalities.

  • random_state – Random seed for the optimization.

  • key_addedmdata.obs key where cluster labels to be added.

  • neighbors_key – Use neighbors connectivities as adjacency. If not specified, look for .obsp['connectivities'] in each modality. If specified, look for .obsp[.uns[neighbors_key]['connectivities_key']] in each modality for connectivities.

  • directed – Treat the graph as directed or undirected.

  • partition_type – Type of partition to use, RBConfigurationVertexPartition by default. See find_partition() for more details.

  • partition_kwargs – Arguments to be passed to the partition_type.

  • **kwargs – Arguments to be passed to optimizer.optimise_partition_multiplex().