graphclust.cluster.GraphCommunityClustering#

class graphclust.cluster.GraphCommunityClustering(k=15, *, graph='jaccard', method='louvain', resolution=1.0, random_state=None)[source]#

Bases: ClusterMixin, BaseEstimator

Community detection on a neighborhood graph (PhenoGraph-style pipeline).

  1. Build a graph: "jaccard" (kNN graph with Jaccard weights, i.e. the first-order fuzzy neighborhood similarity), "knn" (binary symmetric kNN graph) or "fuzzy" (transitive fuzzy neighborhood similarity, sparsified to the kNN pairs).

  2. Maximize modularity with method:

    • "louvain" (Blondel et al. 2008, via networkx);

    • "leiden" (Traag, Waltman and van Eck 2019; uses the optional packages leidenalg and python-igraph and falls back to Louvain with a warning if they are missing);

    • "label_propagation" (Raghavan et al. 2007);

    • "greedy" (Clauset–Newman–Moore).

resolution > 1 favors smaller communities. The number of clusters is not an input: it follows from the graph and the resolution.