A modular Python package for analyzing how network-driven dynamics induce mesoscale organization, through Jacobian-based and diffusion-based functional distances.
Based on the paper:
Giacomo Barzon, Oriol Artime, Samir Suweis, and Manlio De Domenico Unraveling the mesoscale organization induced by network-driven dynamics, PNAS 2024. https://www.pnas.org/doi/10.1073/pnas.2317608121 and the code is based on the original repository: https://github.com/gbarzon/jacobian_geometry
Install the package locally:
pip install -e .Let us consider a networked dynamical system
In vectorial notation, we have that
The Jacobian distance is then defined as the temporal evolution of the difference between two perturbations of intensity
Since we are interested in unveiling the emergent patterns that are most persistent at the mesoscale, it is natural to average the distance matrices,
up to a certain cutoff that we fix
### Import utils functions
import jacobian_geometry
### Get the network
# E.g., generate a hierarchical modular network
from galib.models import HMRandomGraph
N = 128
HMshape = [2,2,32]
avklist = [1,3,20]
mat = HMRandomGraph(HMshape, avklist)
### Define the dynamical process
dynamic = 'Epidemics'
### Define the dynamical parameters
B = 1.
R = 0.05
params = [B, R]
### Compute jacobian distance at various tau
# avg_jacobian_distance: matrix of the pairwise jacobian distance
# linkage: hierarchical clustering encoded as a linkage matrix (see scipy.cluster.hierarchy.linkage)
avg_jacobian_distance, _, linkage, jacobian = jacobian_geometry.jacobian_distance(mat, dynamic, args=params, norm=True, show=True)| Dynamics | |
|---|---|
| Biochemical | |
| Epidemics | |
| Mutualistic | |
| Neuronal | |
| Noisy voter model | |
| Population | |
| Regulatory | |
| Synchronization |
├── LICENSE
├── pyproject.toml
├── README.md
├── src
│ ├── jacobian_geometry
│ │ ├── dynamics
│ │ │ ├── base.py
│ │ │ ├── biochemical.py
│ │ │ ├── diffusion_interaction.py
│ │ │ ├── epidemics.py
│ │ │ ├── __init__.py
│ │ │ ├── mutualistic.py
│ │ │ ├── neuronal.py
│ │ │ ├── noisyvm.py
│ │ │ ├── population.py
│ │ │ ├── regulatory2.py
│ │ │ ├── regulatory.py
│ │ │ ├── synchronization_norm.py
│ │ │ └── synchronization.py
│ │ ├── __init__.py
│ │ ├── metrics
│ │ │ ├── brockmann_barzel_distances.py
│ │ │ ├── distance.py
│ │ │ ├── __init__.py
│ │ │ └── statistics.py
│ │ └── utils
│ │ ├── __init__.py
│ │ ├── plotting.py
└── tests
└── test.py
You can import the most important tools directly from the top-level package:
import jacobian_geometry as jgjg.integrate_dynamics– Run simulations on a given networkjg.compute_jacobian– Compute Jacobian at a statejg.jacobian_distance– Compute Jacobian distance
Possible Dynamics: ['Mutualistic', 'Biochemical', 'Population', 'Regulatory','Epidemics','Synchronization', 'Neuronal', 'NoisyVM', 'Diffusion']
from jacobian_geometry.metrics import (
compute_distance,
average_distance,
jacobian_distance,
community_detection,
)Also available:
from jacobian_geometry.metrics.brockmann_barzel import (
Probability_Matrix,
Brockmann_Distance_Matrix,
Barzel_and_Brockmann_Distance,
Barzel_and_Brockmann_Matrix,
)from jacobian_geometry.utils import plottingMIT License.
Giacomo Barzon (giacomo.barzon@unipd.it)