booldog.simulation_result.continuous_result
Continuous simulation result class.
Contains ContinuousSimulationResult, returned by
continuous_simulation().
Attributes
Classes
Class to contain the result of a continuous (semi-quantitative) ODE |
Module Contents
- booldog.simulation_result.continuous_result.logger
- class booldog.simulation_result.continuous_result.ContinuousSimulationResult(network, t, y, ode_system, node_events=None, edge_events=None)
Class to contain the result of a continuous (semi-quantitative) ODE simulation of a Boolean network: the time-points and solution values, the
ODEsystem used to generate them, and any node/edge perturbation events applied. Returned bycontinuous_simulation().- network
the network the simulation was run on.
- Type:
- ode_system
the
BooleCubeODEorSquadODEinstance used to generate this simulation.- Type:
- t
1D array of time-points of the simulation.
- Type:
ndarray
- y
2D array of simulated values, shape
(len(t), len(network.nodes)), column order matching network.index/network.node_ids.- Type:
ndarray
- node_events = None
node perturbation events applied during the simulation (see __init__ Parameters).
- Type:
list of dict or None
- edge_events = None
edge perturbation events; not currently implemented upstream.
- Type:
list or None
- export(outfile, decimals=5)
Export simulation results to a file.
- Parameters:
outfile (str or Path) – Path to the output file. The file will be created if it does not exist. If the file already exists, it will be overwritten.
decimals (int) – Number of decimals to round the output values to. Default is 5.
Notes
The output file will contain:
nodelist
ODE transform
ODE parameters
node_events
timepoints
solution/y
The output will be tab-separated and can be read into a pandas DataFrame. If you want to use pandas to read the file, you can use the following code:
df = pd.read_csv(outfile, sep="\t")
The “ODE parameters” line(s) are written from
ode_system.param_dict, which bothBooleCubeODEandSquadODEprovide.
- plot(file=None, plot_nodes=None, title=None, figsize=(20, 10))
Plot the simulated time-series for each node.
Each requested node (or group of nodes, see plot_nodes) is plotted as a line of relative concentration against time, on axes shared across subplots. Vertical dashed lines mark the start (and, if given, end) times of any node_events/edge_events recorded on this result.
- Parameters:
file (str or Path or None, optional) – If given, the figure is saved to this path (via
plt.savefig(file, bbox_inches="tight")) instead of being shown interactively. Default None.plot_nodes (None or list of str or list of lists of str, optional) – Subset of nodes to plot. If None, plot all nodes on a single axes. If a list of node identifiers, plot only those nodes on a single axes. If a list of lists of node identifiers, each sublist is plotted on its own subplot (one row per sublist).
title (None or str or list of str, optional) – If plot_nodes is None/empty and title is a str, it is used as the (single) axes title. If plot_nodes is given (flat or nested list) and title is a str, it is used as a figure-level title instead (see Notes). If a list of str, used as the per-subplot subtitles as defined by plot_nodes; plot_nodes should then be a list of lists, and title should be the same length as plot_nodes (otherwise a warning is logged and subtitles are omitted).
figsize ((float, float), optional) – Width, height in inches, passed to
plt.subplots. Default(20, 10).
- Returns:
fig (matplotlib.figure.Figure)
axes (ndarray of matplotlib.axes.Axes) – Array of axes, one row per (sub)plot.
Notes
If plot_nodes is None/empty, a single axes is drawn and a string title (if given) is used directly as that axes’ title. Otherwise (plot_nodes given, flat or nested), a string title is instead used as a figure-level
suptitle, and per-axes titles are only set from a list title matching the number of (sub)plots.
- _plot_one_ax(ax, x, y, legend_labels, vlines=None, title=None)
Helper method that draws one subplot of
plot(): plots y against x as lines with a legend, fixed y-limits of (0, 1), offset spines, and optional vertical event markers.- Parameters:
ax (matplotlib.axes.Axes) – The axes to plot on.
x (ndarray) – 1D array of time-points (x-values), shared by all lines.
y (ndarray) – 2D array of values to plot, one column per line/node (passed directly to
ax.plot(x, y)).legend_labels (list of str) – Legend label for each column of y, in the same order.
vlines (list of float or None, optional) – x-positions at which to draw dashed grey vertical lines (e.g. event times). Default None (no lines).
title (str or None, optional) – If given, set as this axes’ title.
- Returns:
The axes ax is modified in place.
- Return type:
None