booldog.continuous.semi_quantitative
Continuous / semi-quantitative simulation of Boolean networks via ODEs.
Provides ContinuousMixin, the mixin used by
booldog.BoolDogModel to convert Boolean rules into an ODE
system (transform_bool_to_continuous) and to run time-course
simulations of it, including timed node perturbations
(continuous_simulation). The actual ODE construction is delegated to
booldog.continuous.ode_factory.ode_factory().
Attributes
Classes
Mixin providing continuous/semi-quantitative simulation methods. |
Module Contents
- booldog.continuous.semi_quantitative.logger
- class booldog.continuous.semi_quantitative.ContinuousMixin
Mixin providing continuous/semi-quantitative simulation methods.
Mixed into
booldog.BoolDogModel; not intended to be used directly.- transform_bool_to_continuous(transform='normalisedhillcube', **kwargs)
Build an ODE system from this Boolean network.
A thin wrapper around
booldog.continuous.ode_factory.ode_factory()that passes self (this BoolDogModel instance) through as the network to convert. The returned ODE object keeps a reference to self (as ODE.boolean_network) rather than copying it.- Parameters:
transform (str, optional) – One of the accepted transforms (case-insensitive). See booldog.continuous.ode_factory.transforms for options. Defaults to
'normalisedhillcube'.**kwargs – Additional keyword arguments passed to the selected ODE class’s constructor; see booldog.continuous.ode_factory.ode_factory for the per-transform options.
- Returns:
ode_system – The constructed ODE system - a booldog.continuous.ode_factory.BooleCubeODE or booldog.continuous.ode_factory.SquadODE instance, depending on transform.
- Return type:
- continuous_simulation(node_events=None, edge_events=None, t_min=0, t_max=30, initial_state=0, ode_system=None, solver=solve_ivp, **kwargs)
Run continuous semi-quantitative simulation.
- Parameters:
node_events (None, dict, or list of dict, optional) – List of node events with a dictionary defining each event. A single event may be passed as a bare dict instead of a one-element list. See Notes for description of event definitions.
edge_events (None or list of dict, optional) – Disrupt connections #TODO not implemented. Currently only stored on the returned result object; has no effect on the simulation itself.
t_min (float, optional) – Interval of integration, simulation starts with t=t_min and integrates until it reaches t=t_max.
t_max (float, optional) – Interval of integration, simulation starts with t=t_min and integrates until it reaches t=t_max.
initial_state (float or int or array or dict, optional) – Initial state of nodes. See Notes for description of format.
ode_system (None or booldog.continuous.ode_factory.ODE, optional) – If none, the ODE is created with transform_bool_to_continuous.
solver (callable, optional) – ODE solver with a scipy.integrate.solve_ivp-compatible signature (fun, t_span, y0, events, args, max_step, …), called once per perturbation segment. Defaults to scipy.integrate.solve_ivp itself.
**kwargs – If ode_system is None, additional keyword arguments are passed to transform_bool_to_continuous (and from there to the selected ODE class’s constructor; see booldog.continuous.ode_factory.ode_factory for the per-transform options).
- Returns:
result – Container for the simulation output, with (among others) attributes:
t : ndarray, shape (n_time_points,) - combined time-points across all perturbation segments.
y : ndarray, shape (n_time_points, n_nodes) - state values at each time-point in t.
ode_system : the booldog.continuous.ode_factory.ODE instance used for the simulation.
node_events, edge_events : the events passed in.
See ContinuousSimulationResult for its plot and export methods.
- Return type:
booldog.simulation_result.continuous_result.ContinuousSimulationResult
Notes
- Format of the node_events parameter
The node events are passed as a list of dictionaries defining each event. Dictionary keys are:
time: time at which the event occurs
node: name of node which is perturbed
value: value to which the node is set
duration: (optional) duration for which the node is fixed if longer than 0, (i.e. not a point perturbation)
Example - at timepoint 10, node X is set to 0.25 for 5 time-steps. and at timepoint 12, node Y and X are set to 1 for 0 timesteps:
node_events = [ {'time':10, 'node':'X', 'value':.25, 'duration':5}, {'time':12, 'node':'Y', 'value':1}, {'time':12, 'node':'X', 'value':1} ]
- Format of the initial_state parameter
If the initial state is an int or float, the value is assigned for all variables. Otherwise the parameter argument should be a dict with keys as node names and values for their initial state. In this case, if the initial state is not defined for all nodes, a default key with the default value should also be present in the dict.