netneurotools.modularity.consensus_modularity

netneurotools.modularity.consensus_modularity(adjacency, gamma=1, B='modularity', repeats=250, null_func=<function mean>, seed=None)[source]

Find community assignments from adjacency through consensus.

Performs repeats iterations of community detection on adjacency and then uses consensus clustering on the resulting community assignments.

Parameters:
  • adjacency ((N, N) array_like) – Adjacency matrix (weighted/non-weighted) on which to perform consensus community detection.

  • gamma (float, optional) – Resolution parameter for modularity maximization. Default: 1

  • B (str or (N, N) array_like, optional) – Null model to use for consensus clustering. If str, must be one of [‘modularity’, ‘potts’, ‘negative_sym’, ‘negative_asym’]. Default: ‘modularity’

  • repeats (int, optional) – Number of times to repeat Louvain algorithm clustering. Default: 250

  • null_func (callable, optional) – Function used to generate null model when performing consensus-based clustering. Must accept a 2D array as input and return a single value. Default: np.mean

  • seed ({int, np.random.RandomState instance, None}, optional) – Seed for random number generation. Default: None

Returns:

  • consensus ((N,) np.ndarray) – Consensus-derived community assignments

  • Q_all (array_like) – Optimized modularity over all repeats community assignments

  • zrand_all (array_like) – z-Rand score over all pairs of repeats community assignment vectors

References

Bassett, D. S., Porter, M. A., Wymbs, N. F., Grafton, S. T., Carlson, J. M., & Mucha, P. J. (2013). Robust detection of dynamic community structure in networks. Chaos: An Interdisciplinary Journal of Nonlinear Science, 23(1), 013142.

Examples using netneurotools.modularity.consensus_modularity

Consensus clustering with modularity maximization

Consensus clustering with modularity maximization