rapids_singlecell.tl.louvain#
- rapids_singlecell.tl.louvain(adata, resolution=1.0, *, restrict_to=None, key_added='louvain', adjacency=None, n_iterations=100, threshold=1e-07, use_weights=True, neighbors_key=None, obsp=None, dtype=<class 'numpy.float32'>, use_dask=False, copy=False)[source]#
Cluster cells into subgroups using the Louvain algorithm [BGLL08].
- Parameters:
- adata AnnData
annData object
- resolution float | list[float] (default:
1.0) A parameter value or a list of parameter values controlling the coarseness of the clustering. (called gamma in the modularity formula). Higher values lead to more clusters. If a list of values is provided, the Leiden algorithm will be run for each value in the list.
- restrict_to tuple[str, Sequence[str]] | None (default:
None) Restrict the clustering to the categories within the key for sample annotation, tuple needs to contain
(obs_key, list_of_categories).- key_added str (default:
'louvain') adata.obskey under which to add the cluster labels.- adjacency sparse.spmatrix | None (default:
None) Sparse adjacency matrix of the graph, defaults to neighbors connectivities.
- n_iterations int (default:
100) This controls the maximum number of levels/iterations of the Louvain algorithm. When specified the algorithm will terminate after no more than the specified number of iterations. No error occurs when the algorithm terminates early in this manner. Capped at 500 to prevent excessive runtime.
- threshold float (default:
1e-07) Modularity gain threshold for each level/iteration. If the gain of modularity between two levels of the algorithm is less than the given threshold then the algorithm stops and returns the resulting communities. Defaults to 1e-7.
- use_weights bool (default:
True) If
True, edge weights from the graph are used in the computation (placing more emphasis on stronger edges).- neighbors_key int | None (default:
None) If not specified,
louvainlooks at.obsp['connectivities']for neighbors connectivities. If specified,louvainlooks at.obsp[.uns[neighbors_key]['connectivities_key']]for neighbors connectivities.- obsp str | None (default:
None) Use
.obsp[obsp]as adjacency. You can’t specify bothobspandneighbors_keyat the same time.- dtype str | np.dtype | cp.dtype (default:
<class 'numpy.float32'>) Data type to use for the adjacency matrix.
- use_dask bool (default:
False) If
True, use Dask to create the graph and cluster. This will use all GPUs available. This feature is experimental. For datasets with less than 10 Million cells, it is recommended to useuse_dask=False.- copy bool (default:
False) Whether to copy
adataor modify it in place.
- Return type:
AnnData | None