Reference
qmm.core.structure
Define model structure in graph, matrix or equation forms.
import_digraph
Import a JSON model and convert to a NetworkX DiGraph with sign attributes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Union[str, dict]
|
Path to JSON file or dictionary containing model structure |
required |
file_path
|
bool
|
If True, data is a file path. If False, data is a dictionary |
True
|
Returns:
Type | Description |
---|---|
DiGraph
|
nx.DiGraph: Signed directed graph (signed digraph) |
Source code in qmm/core/structure.py
create_matrix
Create an interaction matrix from a signed digraph in symbolic, signed, or binary form.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing a signed digraph model |
required |
form
|
str
|
Type of matrix elements ('symbolic', 'signed', or 'binary') |
'symbolic'
|
matrix_type
|
str
|
Type of matrix to create ('A', 'B', 'C', or 'D') |
'A'
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Interaction matrix |
Source code in qmm/core/structure.py
create_equations
Create linear system of differential equations from a signed digraph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing a signed digraph model |
required |
form
|
str
|
Type of equations to create ('state' or 'output') |
'state'
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Linear system of differential equations |
Source code in qmm/core/structure.py
qmm.core.stability
Analyse the stability properties of a system based on its structure.
sign_stability
Evaluate necessary and sufficient conditions for sign stability including color test.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Test results for sign stability conditions |
Source code in qmm/core/stability.py
system_feedback
cached
Calculate the product of conjunct and disjunct feedback cycles for any level of the system (coefficients of the characteristic polynomial).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
level
|
Optional[int]
|
Level of feedback to compute (None for all levels) |
None
|
form
|
str
|
Type of feedback ('symbolic', 'signed', or 'binary') |
'symbolic'
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Feedback cycle products at specified levels |
Source code in qmm/core/stability.py
net_feedback
cached
Calculate net feedback at a specified level of the system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
level
|
Optional[int]
|
Level of feedback to compute (None for all levels) |
None
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Net feedback at specified levels |
Source code in qmm/core/stability.py
absolute_feedback
cached
Calculate absolute feedback at a specified level of the system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
level
|
Optional[int]
|
Level of feedback to compute (None for all levels) |
None
|
method
|
str
|
Method for computing feedback ('combinations' or 'polynomial') |
'combinations'
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Total number of feedback terms at specified levels |
Source code in qmm/core/stability.py
weighted_feedback
cached
Calculate ratio of net to total feedback terms at each level of the system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
level
|
Optional[int]
|
Level to compute weighted feedback (None for all levels) |
None
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Weighted feedback metrics for each level |
Source code in qmm/core/stability.py
feedback_metrics
cached
Calculate net, absolute and weighted feedback metrics at each level of the system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Feedback metrics for each system level |
Source code in qmm/core/stability.py
hurwitz_determinants
cached
Calculate Hurwitz determinants for analysing system stability.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
level
|
Optional[int]
|
Level to compute determinants (None for all Hurwitz determinants) |
None
|
form
|
str
|
Type of computation ('symbolic', 'signed', or 'binary') |
'symbolic'
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Hurwitz determinants at specified levels |
Source code in qmm/core/stability.py
net_determinants
cached
Calculate net terms in Hurwitz determinants.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
level
|
Optional[int]
|
Level to compute determinants (None for all Hurwitz determinants) |
None
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Net terms in Hurwitz determinants |
Source code in qmm/core/stability.py
absolute_determinants
cached
Calculate absolute terms in Hurwitz determinants.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
level
|
Optional[int]
|
Level to compute determinants (None for all Hurwitz determinants) |
None
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Absolute terms in Hurwitz determinants |
Source code in qmm/core/stability.py
weighted_determinants
cached
Calculate ratio of net to total terms for Hurwitz determinants.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
level
|
Optional[int]
|
Level to compute determinants (None for all Hurwitz determinants) |
None
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Ratio of net to total terms for Hurwitz determinants |
Source code in qmm/core/stability.py
determinants_metrics
cached
Calculate net, absolute and weighted Hurwitz determinant metrics.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Hurwitz determinant metrics |
Source code in qmm/core/stability.py
conditional_stability
cached
Analyse conditional stability metrics and model stability class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Conditional stability metrics and model class |
Source code in qmm/core/stability.py
simulation_stability
cached
Analyse stability using randomly sampled interaction strengths from a uniform distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
n_sim
|
int
|
Number of simulations to perform (default 10000) |
10000
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Proportion of stable matrices and proportion that fail Hurwitz criteria |
Source code in qmm/core/stability.py
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
|
qmm.core.press
Analyse direct and indirect effects of press perturbations.
adjoint_matrix
cached
Calculate elements of classical adjoint matrix for press perturbation response.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
form
|
str
|
Type of computation ('symbolic', 'signed') |
'symbolic'
|
perturb
|
Optional[str]
|
Node to perturb (None for full matrix) |
None
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Classical adjoint matrix elements |
Source code in qmm/core/press.py
absolute_feedback_matrix
cached
Calculate total number of both positive and negative terms for press perturbation response.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
perturb
|
Optional[str]
|
Node to perturb (None for full matrix) |
None
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Absolute feedback matrix elements |
Source code in qmm/core/press.py
weighted_predictions_matrix
cached
Calculate ratio of net to total terms for a press perturbation response.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
as_nan
|
bool
|
Return NaN for undefined ratios |
True
|
as_abs
|
bool
|
Return absolute values |
False
|
perturb
|
Optional[str]
|
Node to perturb (None for full matrix) |
None
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Prediction weights |
Source code in qmm/core/press.py
sign_determinacy_matrix
cached
Calculate probability of a correct sign prediction (matches adjoint).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
method
|
str
|
Method for computing determinacy ('average', '95_bound', 'simulation') |
'average'
|
as_nan
|
bool
|
Return NaN for undefined ratios |
True
|
as_abs
|
bool
|
Return absolute values |
False
|
perturb
|
Optional[str]
|
Node to perturb (None for full matrix) |
None
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Probability of sign determinacy |
Source code in qmm/core/press.py
numerical_simulations
cached
numerical_simulations(
G,
n_sim=10000,
dist="uniform",
seed=42,
as_nan=True,
as_abs=False,
positive_only=False,
match_adjoint=False,
)
Calculate proportion of positive and negative responses from stable simulations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
n_sim
|
int
|
Number of simulations |
10000
|
dist
|
str
|
Distribution for sampling ('uniform', 'weak', 'moderate', 'strong') |
'uniform'
|
seed
|
int
|
Random seed |
42
|
as_nan
|
bool
|
Return NaN for undefined ratios |
True
|
positive_only
|
bool
|
Return just the proportion of positive responses instead of sign-dominant proportions. |
False
|
as_abs
|
bool
|
Return absolute values of proportions |
False
|
match_adjoint
|
bool
|
If true, counts the proportion of simulations matching the sign of the adjoint matrix predictions. |
False
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Average proportion of positive and negative responses |
Raises:
Type | Description |
---|---|
ValueError
|
If invalid parameter combinations are used. |
Source code in qmm/core/press.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
qmm.core.prediction
Generate qualitative predictions of system response to press perturbations with thresholds for ambiguity.
table_of_predictions
Create a table of qualitative predictions with thresholds for ambiguity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
M
|
Union[Matrix, ndarray]
|
Matrix of predictions from press perturbation analysis |
required |
t1
|
float
|
Lower threshold for likely predictions |
0.8
|
t2
|
float
|
Upper threshold for determined predictions |
1.0
|
index
|
Optional[List[str]]
|
Row labels |
None
|
columns
|
Optional[List[str]]
|
Column labels |
None
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Qualitative predictions |
Source code in qmm/core/prediction.py
compare_predictions
Compare predictions between alternative models or prediction methods.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
M1
|
DataFrame
|
First matrix of predictions |
required |
M2
|
DataFrame
|
Second matrix of predictions |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Combined predictions showing differences and agreements |
Source code in qmm/core/prediction.py
qmm.core.helper
Utility functions for model development and analysis.
list_to_digraph
Convert an adjacency matrix to a directed graph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
Union[List[List[int]], ndarray]
|
A square matrix (list of lists or numpy array) representing the adjacency matrix. Non-zero values indicate edges, where the value represents the sign of the edge. |
required |
ids
|
Optional[List[str]]
|
Optional list of node identifiers. If None, nodes will be labeled 1 to n. |
None
|
Returns:
Type | Description |
---|---|
DiGraph
|
nx.DiGraph: A NetworkX directed graph with signed edges. |
Source code in qmm/core/helper.py
digraph_to_list
Convert a directed graph to an adjacency matrix string representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
A NetworkX directed graph with signed edges. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
String representation of the adjacency matrix. |
Source code in qmm/core/helper.py
get_nodes
Get nodes of a specific type from a directed graph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX directed graph to extract nodes from. |
required |
node_type
|
str
|
Type of nodes to extract ('state' or 'all'). |
'state'
|
labels
|
bool
|
If True, return node labels instead of node ids. |
False
|
Returns:
Type | Description |
---|---|
List[Union[str, Dict[str, Any]]]
|
List of node identifiers or dictionaries containing node data. |
Source code in qmm/core/helper.py
get_weight
Calculate weight matrix by dividing net effect by absolute effect.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
net
|
Matrix
|
Matrix of net terms. |
required |
absolute
|
Matrix
|
Matrix of absolute terms. |
required |
no_effect
|
Union[Basic, float]
|
Value to use when absolute terms is 0 (default: sympy.nan). |
nan
|
Returns:
Type | Description |
---|---|
Matrix
|
sympy.Matrix: Matrix of weights. |
Source code in qmm/core/helper.py
get_positive
Calculate matrix of positive terms.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
net
|
Matrix
|
Matrix of net terms. |
required |
absolute
|
Matrix
|
Matrix of absolute terms. |
required |
Returns:
Type | Description |
---|---|
Matrix
|
sympy.Matrix: Matrix of positive terms. |
Source code in qmm/core/helper.py
get_negative
Calculate matrix of negative terms.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
net
|
Matrix
|
Matrix of net terms. |
required |
absolute
|
Matrix
|
Matrix of absolute terms. |
required |
Returns:
Type | Description |
---|---|
Matrix
|
sympy.Matrix: Matrix of negative terms. |
Source code in qmm/core/helper.py
sign_determinacy
Calculate sign determinacy matrix from prediction weights.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wmat
|
Matrix
|
Matrix of prediction weights. |
required |
tmat
|
Matrix
|
Matrix of absolute feedback. |
required |
method
|
str
|
Method to use for probability calculation ('average' or '95_bound'). |
'average'
|
Returns:
Type | Description |
---|---|
Matrix
|
sympy.Matrix: Probability of sign determinacy. |
Source code in qmm/core/helper.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
Extension module
qmm.extensions.senstability
Analyse the sensitivity of system stability to direct effects within feedback cycles.
structural_sensitivity
cached
Calculate contribution of direct effects to stabilising and destabilising feedback.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
level
|
Optional[int]
|
Feedback level (None for highest level) |
None
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Ratio of net to total feedback terms for each direct effect |
Source code in qmm/extensions/senstability.py
net_structural_sensitivity
cached
Calculate net contribution of direct effects to system feedback.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
level
|
Optional[int]
|
Feedback level (None for highest level) |
None
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Net feedback terms containing each direct effect |
Source code in qmm/extensions/senstability.py
absolute_structural_sensitivity
cached
Calculate total contribution of direct effects to system feedback.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
level
|
Optional[int]
|
Feedback level (None for highest level) |
None
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Total feedback terms containing each direct effect |
Source code in qmm/extensions/senstability.py
weighted_structural_sensitivity
cached
Calculate weighted structual sensitvity for each direct effect.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
level
|
Optional[int]
|
Feedback level (None for highest level) |
None
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Weighted structural sensitivity of each direct effect |
Source code in qmm/extensions/senstability.py
qmm.extensions.life
Analyse change in life expectancy from press perturbations.
birth_matrix
cached
Create matrix of direct effects on birth rate from press perturbations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
form
|
str
|
Type of computation ('symbolic', 'signed') |
'symbolic'
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Positive direct effects on birth rate |
Source code in qmm/extensions/life.py
death_matrix
cached
Create matrix of direct effects on death rate from press perturbations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
form
|
str
|
Type of computation ('symbolic', 'signed') |
'symbolic'
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Positive direct effects on death rate |
Source code in qmm/extensions/life.py
life_expectancy_change
cached
Calculate change in life expectancy from press perturbations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
type
|
str
|
Change in birth or death rate ('birth' or 'death') |
'birth'
|
form
|
str
|
Type of computation ('symbolic', 'signed') |
'symbolic'
|
perturb
|
Optional[str]
|
Node to perturb (None for full matrix) |
None
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Change in life expectancy for each component |
Source code in qmm/extensions/life.py
net_life_expectancy_change
cached
Calculate net terms in life expectancy change from press perturbations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
type
|
str
|
Change in birth or death rate ('birth' or 'death') |
'birth'
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Net life expectancy change for each component |
Source code in qmm/extensions/life.py
absolute_life_expectancy_change
cached
Calculate absolute terms in life expectancy change from press perturbations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
type
|
str
|
Change in birth or death rate ('birth' or 'death') |
'birth'
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Absolute life expectancy change for each component |
Source code in qmm/extensions/life.py
weighted_predictions_life_expectancy
cached
Calculate ratio of net to total change in life expectancy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
type
|
str
|
Change in birth or death rate ('birth' or 'death') |
'birth'
|
as_nan
|
bool
|
Return NaN for undefined ratios |
True
|
as_abs
|
bool
|
Return absolute values |
False
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Net-to-total ratios for life expectancy predictions |
Source code in qmm/extensions/life.py
qmm.extensions.paths
Analyse causal pathways, cycles and complementary feedback.
get_cycles
cached
Find all feedback cycles in the signed digraph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Products of interactions along each cycle |
Source code in qmm/extensions/paths.py
cycles_table
cached
Find all feedback cycles in the signed digraph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Table with cycle length, path representation, and sign |
Source code in qmm/extensions/paths.py
get_paths
cached
Find all causal pathways between two nodes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
source
|
str
|
Source node |
required |
target
|
str
|
Target node |
required |
form
|
str
|
Type of path products ('symbolic', 'signed', or 'binary') |
'symbolic'
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Products of interactions along each path |
Source code in qmm/extensions/paths.py
paths_table
cached
Create table of paths between nodes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
source
|
str
|
Source node |
required |
target
|
str
|
Target node |
required |
Returns:
Type | Description |
---|---|
Optional[DataFrame]
|
Optional[pd.DataFrame]: DataFrame containing path information or None if no paths exist |
Source code in qmm/extensions/paths.py
complementary_feedback
cached
Calculate feedback from nodes not on paths between source and target.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
source
|
str
|
Source node |
required |
target
|
str
|
Target node |
required |
form
|
str
|
Type of feedback ('symbolic', 'signed', or 'binary') |
'symbolic'
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Feedback cycles in complementary subsystem |
Source code in qmm/extensions/paths.py
system_paths
cached
Calculate combined effect of paths and complementary feedback.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
source
|
str
|
Source node |
required |
target
|
str
|
Target node |
required |
form
|
str
|
Type of computation ('symbolic', 'signed', or 'binary') |
'symbolic'
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Total effects including paths and feedback |
Source code in qmm/extensions/paths.py
weighted_paths
cached
Calculate ratio of net to total path effects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
source
|
str
|
Source node |
required |
target
|
str
|
Target node |
required |
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Net-to-total ratios for path predictions |
Source code in qmm/extensions/paths.py
path_metrics
cached
Calculate comprehensive metrics for paths between nodes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
source
|
str
|
Source node |
required |
target
|
str
|
Target node |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Metrics including path length, sign, and feedback |
Source code in qmm/extensions/paths.py
qmm.extensions.effects
Analyse cumulative effects from perturbation scenarios with multiple-inputs and multiple-outputs.
define_input_output
Define model components as state variables, inputs and outputs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
remove_disconnected
|
bool
|
Remove disconnected components |
True
|
Returns:
Type | Description |
---|---|
DiGraph
|
nx.DiGraph: Model with input, state and output classification |
Source code in qmm/extensions/effects.py
cumulative_effects
cached
Calculate cumulative effects to multiple inputs using state-space representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
form
|
str
|
Type of computation ('symbolic', 'signed', or 'binary') |
'symbolic'
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Cumulative effects on state variables and outputs |
Source code in qmm/extensions/effects.py
absolute_effects
cached
Calculate absolute effects from multiple inputs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Total effects on state variables and outputs |
Source code in qmm/extensions/effects.py
weighted_effects
cached
Calculate ratio of net to total terms for predicting cumulative effects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Ratio of net to total effects |
Source code in qmm/extensions/effects.py
sign_determinacy_effects
cached
Calculate probability of correct sign prediction for cumulative effects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
method
|
str
|
Method for computing determinacy ('average', '95_bound') |
'average'
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Sign determinacy probabilities for effects |
Source code in qmm/extensions/effects.py
get_simulations
cached
Calculate average proportion of positive and negative effects from stable numerical simulations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
n_sim
|
int
|
Number of simulations |
10000
|
dist
|
str
|
Distribution for sampling |
'uniform'
|
seed
|
int
|
Random seed |
42
|
perturb
|
Optional[Tuple[str, int]]
|
Optional tuple of (node, sign) to perturb |
None
|
observe
|
Optional[Tuple[Tuple[str, int], ...]]
|
Optional tuple of observations as (node, sign) tuples |
None
|
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict containing effects, valid_sims, all_nodes, and tmat |
Source code in qmm/extensions/effects.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
|
simulation_effects
Performs numerical simulations of cumulative effects using random interaction strengths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
n_sim
|
int
|
Number of simulations |
10000
|
dist
|
str
|
Distribution for sampling ("uniform", "weak", "moderate", "strong") |
'uniform'
|
seed
|
int
|
Random seed |
42
|
positive_only
|
bool
|
Return just the proportion of positive responses instead of sign-dominant proportions |
False
|
Returns:
Type | Description |
---|---|
Matrix
|
SymPy Matrix containing simulation results |
Source code in qmm/extensions/effects.py
qmm.extensions.indicators
Identify informative indicators from press perturbations.
mutual_information
cached
Calculate mutual information of variables for alternative models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
models
|
Union[DiGraph, List[DiGraph]]
|
One or more NetworkX DiGraphs representing alternative models |
required |
perturb
|
str
|
Node and sign to perturb |
required |
n_sim
|
int
|
Number of simulations |
10000
|
seed
|
int
|
Random seed |
42
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Mutual information for indicator selection |
Source code in qmm/extensions/indicators.py
qmm.extensions.validation
Validate qualitative predictions of system response to press perturbations from observations.
marginal_likelihood
cached
Calculate proportion of simulations matching qualitative observations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
perturb
|
str
|
Node and sign to perturb |
required |
observe
|
str
|
String of observations |
required |
n_sim
|
int
|
Number of simulations |
10000
|
distribution
|
str
|
Distribution for sampling |
'uniform'
|
seed
|
int
|
Random seed |
42
|
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
Marginal likelihood |
Source code in qmm/extensions/validation.py
model_validation
cached
Compare marginal likelihoods from alternative model structures.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
perturb
|
str
|
Node and sign to perturb |
required |
observe
|
str
|
String of observations |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Marginal likelihood comparison for model variants |
Source code in qmm/extensions/validation.py
posterior_predictions
cached
Calculate model predictions conditioned on observations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
perturb
|
str
|
Node and sign to perturb |
required |
observe
|
str
|
String of observations |
''
|
n_sim
|
int
|
Number of simulations |
10000
|
dist
|
str
|
Distribution for sampling |
'uniform'
|
seed
|
int
|
Random seed |
42
|
Returns:
Type | Description |
---|---|
Matrix
|
sp.Matrix: Predictions conditioned on observations |
Source code in qmm/extensions/validation.py
diagnose_observations
cached
Identify possible perturbations from marginal likelihoods.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G
|
DiGraph
|
NetworkX DiGraph representing signed digraph model |
required |
observe
|
str
|
String of observations |
required |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: Ranked perturbations matching observations |
Source code in qmm/extensions/validation.py
bayes_factors
bayes_factors(
G_list,
perturb,
observe,
n_sim=10000,
distribution="uniform",
seed=42,
names=None,
)
Calculate Bayes factors from the ratio of marginal likelihoods of alternative models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G_list
|
Union[List[DiGraph], Tuple[DiGraph, ...]]
|
List or tuple of NetworkX DiGraphs representing alternative models |
required |
perturb
|
str
|
Node and sign to perturb |
required |
observe
|
str
|
String of observations |
required |
n_sim
|
int
|
Number of simulations |
10000
|
distribution
|
str
|
Distribution for sampling |
'uniform'
|
seed
|
int
|
Random seed |
42
|
names
|
Optional[List[str]]
|
Optional list of model names |
None
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: DataFrame containing Bayes factors |