booldog.simulation_result.boolean_result

Boolean simulation results

Attributes

_CYTOSCAPE_AVAILABLE

_PILLOW_AVALIBLE

logger

DEFAULT_COLOURS

Classes

BooleanStateSpace

Class to contain a subspace of a Boolean Network.

BooleanSimulationResult

Class to contain simulation results

Module Contents

booldog.simulation_result.boolean_result._CYTOSCAPE_AVAILABLE = True
booldog.simulation_result.boolean_result._PILLOW_AVALIBLE = True
booldog.simulation_result.boolean_result.logger
booldog.simulation_result.boolean_result.DEFAULT_COLOURS
class booldog.simulation_result.boolean_result.BooleanStateSpace(network, state_space)

Class to contain a subspace of a Boolean Network.

network
state_space
set_node_state(node_id, state)

Set the state of a node in all states of the state space.

Parameters:
  • node_id (str) – The identifier of the node to set the state for.

  • state (int) – The state to set for the node (0 or 1).

Raises:

ValueError – If node_id is not a valid node identifier in the network, or if state is not 0 or 1.

plot_state_space(title='State Heatmap', cmap=None)

Plot the states of the Boolean network as a heatmap.

Parameters:
  • title (str, optional) – Title of the heatmap, default is “State Heatmap”.

  • cmap (ListedColormap, optional) – Colormap to use for the heatmap. Default is binary with green (1) and grey (0).

__repr__()
class booldog.simulation_result.boolean_result.BooleanSimulationResult(network, stg, initial_states)

Class to contain simulation results

network
stg
initial_states
plot_stg(file=None, booldog_style=True, plot_nodes=None, use_names=True, num_characters=5)

Plot the state transition graph.

Parameters:
  • fig (str) – File name of generated figure

  • new_style (bool) – Whether to use booldog style, or PyBoolNet style (default) to plot the state transition graph. Requires pygraphviz (If not installed, will default to PyBoolNet version.)

  • plot_nodes (None or list of str, optional) – List of identifiers of subset of nodes to plot. If None, plot all nodes. Only valid if booldog_style is True.

  • use_names (bool) – Whether to use node names instead of node identifiers in the labels. Only valid if booldog_style is True.

num_charactersint

Number of characters to use for node names in the labels. Only valid if booldog_style is True.

Returns:

The state transition graph. If booldog_style is True and pygraphviz is installed, a pygraphviz AGraph object is returned. Otherwise, a networkx graph is returned.

Return type:

networkx graph or pygraphviz AGraph

Notes

If booldog_style is True, the nodes in the state transition graph are represented as tables, with each cell representing a node in the Boolean network. The cells are coloured green for “on” nodes and red for “off” nodes. If use_names is True, the node names are used instead of the node identifiers in the labels.

plot_state_space(title='State Heatmap', cmap=None)

Plot the states of the Boolean network as a heatmap.

Parameters:
  • title (str, optional) – Title of the heatmap, default is “State Heatmap”.

  • cmap (ListedColormap, optional) – Colormap to use for the heatmap. Default is binary with green (1) and grey (0).

export(file)

Export Boolean simulation result to ??

make_animation(base_suid, gif=None, mp4=None, initial_state=None, colour_on=None, colour_off=None, cycle_repeats=3, max_steps=None, duration=400, loop=0, sleep=1)
Parameters:
  • base_suid (int) – The network SUID from Cytoscape, of the network to base the animation on.

  • gif (None or a file path) – Path to save animation (GIF) to.

  • mp4 (None or a file path) – Not recommended to use, as this feature is experimental. Path to save animation (MP4) to.

  • initial_state (str) – Initial state for the simulation. For valid initial states, see the object attributes initial_states

  • colour_on (str) – Hex code for colour of “on” nodes, default=”#b2df8a” (light green),

  • colour_off (str) – Hex code for colour of “on” nodes, default=”#6f6f6f” (light grey)

  • cycle_repeats (int) – If there’s a cycle in the simulation, how many times should it repeat, default=3,

  • max_steps=None – Maximum number of frames to include in the animation. If none, will be num_state + len(cycle)*cycle_repeats, where num_states is the number of states in the simulation, and len(cycle) is the length of the cycle (if one exists). default=None

  • duration=400 – Time on each frame (in milliseconds)

  • loop (int) – Number of loops to the animation. 0 is infinite. default=0.

  • sleep (int) – Seconds to sleep between Cytoscape network exports. (See notes).

Notes

Do not interact with Cytoscape while the networks are being rendered, as this will interfere with the selection and colouring of nodes.

Occasionally Cytoscape exports get corrupted (e.g. node borders are rendered in the wrong order, node fills are placed on the wrong node). This is independent of booldog, and it is unclear why it happens. Rerunning the function may help, and increasing the sleep parameter may also help.

Mp4 export is in development, and not recommended to use.