netneurotools.metrics.assortativity_dir
- netneurotools.metrics.assortativity_dir(x, W, use_numba=True)[source]
Calculate assortativity for directed 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, directed 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:
Notes
For a directed adjacency matrix \(A\), and an annotation vector \(\mathbf{x}\), the assortativity of the network is defined as:
\[\begin{split}\begin{align} r & = \sum_{ij} \frac{a_{ij}}{m} \tilde{x}_i^{\text{out}} \tilde{x}_j^{\text{in}} \\ & = \sum_{ij} \frac{a_{ij}}{m} (\frac{x_i-\bar{\mathbf{x}}^{\text{out}}}{\sigma_{\mathbf{x}}^{\text{out}}}) (\frac{x_j-\bar{\mathbf{x}}^{\text{in}}}{\sigma_{\mathbf{x}}^{\text{in}}}) \end{align}\end{split}\]where \(a_{ij}\) is the weight of the directed connection from node \(i\) to node \(j\), and \(m\) is the total weight of the network. \(\bar{\mathbf{x}}^{\text{in}}\), \(\bar{\mathbf{x}}^{\text{out}}\), \(\sigma_{\mathbf{x}}^{\text{in}}\), and \(\sigma_{\mathbf{x}}^{\text{out}}\) are the means and standard deviations of the in-degree and out-degree weighted annotations, defined as:
\[\begin{split}\begin{align} \bar{\mathbf{x}}^{\text{in}} & = \frac{1}{m} \sum_i k_i^{\text{in}} x_i \\ \bar{\mathbf{x}}^{\text{out}} & = \frac{1}{m} \sum_i k_i^{\text{out}} x_i \\ \sigma_{\mathbf{x}}^{\text{in}} & = \sqrt{\frac{1}{m} \sum_i k_i^{\text{in}} (x_i - \bar{\mathbf{x}}^{\text{in}})^2} \\ \sigma_{\mathbf{x}}^{\text{out}} & = \sqrt{\frac{1}{m} \sum_i k_i^{\text{out}} (x_i - \bar{\mathbf{x}}^{\text{out}})^2} \end{align}\end{split}\]in which \(k_i^{\text{in}}\) is the sum of incoming weights to node \(i\) and \(k_i^{\text{out}}\) is the sum of outgoing weights from node \(i\).
References