1111from .. import _utils
1212from .. import logging as logg
1313from .._compat import deprecated , old_positionals , pkg_version , warn
14- from .._utils import _choose_graph , dematrix
14+ from .._utils import _choose_graph , _doc_params , dematrix
15+ from ._docs import (
16+ doc_adata ,
17+ doc_adjacency ,
18+ doc_neighbors_key ,
19+ doc_obsp ,
20+ doc_random_state ,
21+ doc_restrict_to ,
22+ )
1523from ._utils_clustering import rename_groups , restrict_adjacency
1624
1725if TYPE_CHECKING :
4654 "copy" ,
4755)
4856@deprecated ("Use `scanpy.tl.leiden` instead" )
57+ @_doc_params (
58+ doc_adata = doc_adata ,
59+ random_state = doc_random_state ,
60+ restrict_to = doc_restrict_to ,
61+ adjacency = doc_adjacency ,
62+ neighbors_key = doc_neighbors_key .format (method = "louvain" ),
63+ obsp = doc_obsp ,
64+ )
4965def louvain ( # noqa: PLR0912, PLR0913, PLR0915
5066 adata : AnnData ,
5167 resolution : float | None = None ,
@@ -80,22 +96,17 @@ def louvain( # noqa: PLR0912, PLR0913, PLR0915
8096
8197 Parameters
8298 ----------
83- adata
84- The annotated data matrix.
99+ {doc_adata}
85100 resolution
86101 For the default flavor (``'vtraag'``) or for ```RAPIDS```, you can provide a
87102 resolution (higher resolution means finding more and smaller clusters),
88103 which defaults to 1.0.
89104 See “Time as a resolution parameter” in :cite:t:`Lambiotte2014`.
90- random_state
91- Change the initialization of the optimization.
92- restrict_to
93- Restrict the clustering to the categories within the key for sample
94- annotation, tuple needs to contain ``(obs_key, list_of_categories)``.
105+ {random_state}
106+ {restrict_to}
95107 key_added
96108 Key under which to add the cluster labels. (default: ``'louvain'``)
97- adjacency
98- Sparse adjacency matrix of the graph, defaults to neighbors connectivities.
109+ {adjacency}
99110 flavor
100111 Choose between to packages for computing the clustering.
101112
@@ -118,15 +129,8 @@ def louvain( # noqa: PLR0912, PLR0913, PLR0915
118129 partition_kwargs
119130 Key word arguments to pass to partitioning,
120131 if ``vtraag`` method is being used.
121- neighbors_key
122- Use neighbors connectivities as adjacency.
123- If not specified, louvain looks .obsp['connectivities'] for connectivities
124- (default storage place for pp.neighbors).
125- If specified, louvain looks
126- .obsp[.uns[neighbors_key]['connectivities_key']] for connectivities.
127- obsp
128- Use .obsp[obsp] as adjacency. You can't specify both
129- `obsp` and `neighbors_key` at the same time.
132+ {neighbors_key}
133+ {obsp}
130134 copy
131135 Copy adata or modify it inplace.
132136
0 commit comments