netneurotools.metrics.assortativity_und

netneurotools.metrics.assortativity_und(x, W, use_numba=True)[source]

Calculate assortativity for undirected networks.

This function implements Bazinet’s assortativity for annotated networks as defined in [1].

Parameters:
  • x ((N,) array_like) – Annotation scores for each node in the network

  • W ((N, N) array_like) – Weighted, undirected connection weight array

  • use_numba (bool, optional) – Whether to use numba for calculation. Default: True (if numba is available).

Returns:

assortativity – Assortativity of the network

Return type:

float

Notes

Assortativity is defined as the Pearson correlation between the local annotation scores of connected nodes [2]. In other words, it quantifies the tendency for nodes with similar annotation scores to be connected [1]. For an adjacency matrix \(A\), and an annotation vector \(\mathbf{x}\), the assortativity of a network, with respect to \(\bar{\mathbf{x}}\) is defined as:

\[\begin{split}\begin{align} r & = \sum_{ij} \frac{a_{ij}}{2m} \tilde{x}_i \tilde{x}_j \\ & = \sum_{ij} \frac{a_{ij}}{2m} (\frac{x_i-\bar{\mathbf{x}}}{\sigma_{\mathbf{x}}}) (\frac{x_j-\bar{\mathbf{x}}}{\sigma_{\mathbf{x}}}) \end{align}\end{split}\]

where \(a_{ij}\) is the weight of the connection between nodes \(i\) and \(j\), \(2m\) is the total weight of the network. \(\bar{\mathbf{x}}\) and \(\sigma_{\mathbf{x}}\) are the mean and standard deviation of the annotation, defined as:

\[\begin{split}\begin{align} \bar{\mathbf{x}} & = \frac{1}{2m} \sum_i k_i x_i \\ \sigma_{\mathbf{x}} & = \sqrt{\frac{1}{2m} \sum_i k_i (x_i - \bar{\mathbf{x}})^2} \end{align}\end{split}\]

in which \(k_i\) is the sum of the weights of the connections to node \(i\).

References