Skip to content

Commit

Permalink
changed n_iterations default for leiden to 100
Browse files Browse the repository at this point in the history
  • Loading branch information
Intron7 committed Jun 24, 2023
1 parent 98c7905 commit 6b2037a
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions rapids_singlecell/scanpy_gpu/_clustering.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import cupy as cp
import cudf
import cugraph
from cugraph import Graph
from cugraph import leiden as culeiden
from cugraph import louvain as culouvain
import numpy as np
import pandas as pd
from cuml.cluster import KMeans
Expand All @@ -16,7 +18,7 @@
def leiden(
adata: AnnData,
resolution: float = 1.0,
n_iterations: int = -1,
n_iterations: int = 100,
use_weights: bool = True,
neighbors_key: Optional[int] = None,
key_added: str = "leiden",
Expand All @@ -34,9 +36,9 @@ def leiden(
Higher values lead to more clusters.
n_iterations
How many iterations of the Leiden clustering algorithm to perform.
Positive values above 2 define the total number of iterations to perform,
-1 has the algorithm run until it reaches its optimal clustering.
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.
use_weights
If `True`, edge weights from the graph are used in the computation
Expand All @@ -63,12 +65,12 @@ def leiden(
else:
weights = None

g = cugraph.Graph()
g = Graph()

g.from_cudf_adjlist(offsets, indices, weights)

# Cluster
leiden_parts, _ = cugraph.leiden(g, resolution=resolution, max_iter=n_iterations)
leiden_parts, _ = culeiden(g, resolution=resolution, max_iter=n_iterations)

# Format output
groups = (
Expand Down Expand Up @@ -138,12 +140,12 @@ def louvain(
else:
weights = None

g = cugraph.Graph()
g = Graph()

g.from_cudf_adjlist(offsets, indices, weights)

# Cluster
louvain_parts, _ = cugraph.louvain(g, resolution=resolution, max_iter=n_iterations)
louvain_parts, _ = culouvain(g, resolution=resolution, max_iter=n_iterations)

# Format output
groups = (
Expand Down

0 comments on commit 6b2037a

Please sign in to comment.