interaction_graphs¶
- activities2animation(igraph: DiGraph, activities, fname_gif: str, fname_tmp: str = 'tmp*.jpg', delay: int = 50, loop: int = 0)¶
Generates an animated gif from the sequence of Activities by mapping the activities on the respective components of the interaction graph using add_style_activities. The activities may be given in dict or str format, see states, subspaces and paths for details. Requires the program convert from the ImageMagick software suite. The argument FnameTMP is the string that is used for generating the individual frames. Use “*” to indicate the position of the frame counter. The default “tmp*.jpg” will result in the creation of the files:
tmp01.jpg, tmp02.jpg, ...
The files will be deleted after the gif is generated. The Delay parameter sets the frame rate and Loop the number of repititions, both are parameters that are directly passed to convert.
- arguments:
igraph: interaction graph
Activities: sequence of activities
Delay: number of 1/100s between each frame
Loop: number of repetitions, use 0 for infinite
FnameTMP: name for temporary image files, use “*” to indicate counter
FnameGIF: name of the output gif file
example:
>>> activities = ["11--1-0", "111-1-0", "11111-0", "1111100"] >>> activities2animation(igraph, activities, "animation.gif")
- add_style_activities(igraph: DiGraph, activities: Union[str, dict], color_active: str = '/paired10/5', color_inactive: str = '/paired10/1')¶
Sets attributes for the color and fillcolor of nodes to indicate which variables are activated and which are inhibited in Activities. All activated or inhibited components get the attribute “color”=”black”. Activated components get the attribute “fillcolor”=”red” and inactivated components get the attribute “fillcolor”=”blue”. Interactions involving activated or inhibited nodes get the attribute “color”=”gray” to reflect that they are ineffective.
- arguments:
igraph: interaction graph
activities: activated and inhibited nodes
color_active: color in dot format for active components
color_inactive: color in dot format for inactive components
example:
>>> activities = {"ERK":1, "MAPK":0} >>> add_style_activities(igraph, activities)
- add_style_anonymous(igraph: DiGraph)¶
Creates an anonymous interaction graph with circular nodes without labels.
- arguments:
igraph: interaction graph
example:
>>> add_style_anonymous(igraph)
- add_style_constants(igraph: DiGraph)¶
Sets the attribute “style”=”plaintext” with “fillcolor”=”none” and “fontname”=”Times-Italic” for all constants.
- arguments:
igraph: interaction graph
example:
>>> add_style_constants(igraph)
- add_style_default(igraph: DiGraph)¶
A convenience function that adds styles for interaction signs, SCCs, inputs, outputs and constants.
- arguments:
igraph: interaction graph
example:
>>> add_style_default(igraph, path)
- add_style_inputs(igraph: DiGraph)¶
Adds a subgraph to the dot representation of igraph that contains all inputs. Nodes that belong to the same dot subgraph are contained in a rectangle and treated separately during layout computations. In addition, the subgraph is labeled by a “Inputs” in bold font.
- arguments:
igraph: interaction graph
example:
>>> add_style_inputs(igraph)
- add_style_interactionsigns(igraph: DiGraph)¶
Sets attributes for the arrow head and edge color of interactions to indicate the interaction sign. Activating interactions get the attributes “arrowhead”=”normal” and “color”=”black”, inhibiting interactions get the attributes “arrowhead”=”tee” and “color”=”red”, and ambivalent interaction get the attributes “arrowhead”=”dot” and “color”=”blue”.
- arguments:
igraph: interaction graph
example:
>>> add_style_interactionsigns(igraph)
- add_style_outputs(igraph: DiGraph)¶
Adds a subgraph to the dot representation of igraph that contains all outputs. Nodes that belong to the same dot subgraph are contained in a rectangle and treated separately during layout computations. In addition, the subgraph is labeled by a “Outputs” in bold font.
- arguments:
igraph: interaction graph
example:
>>> add_style_outputs(igraph)
- add_style_path(igraph: DiGraph, path: List[str], color: str)¶
Sets the color of all nodes and edges involved in the given path to color.
- arguments:
igraph: interaction graph
path: sequence of component names
color: color of the path
example:
>>> path = ["Raf", "Ras", "Mek"] >>> add_style_path(igraph, path, "red")
- add_style_sccs(igraph: DiGraph)¶
Adds a subgraph for every non-trivial strongly connected component (SCC) to the dot representation of igraph. Nodes that belong to the same dot subgraph are contained in a rectangle and treated separately during layout computations. Each subgraph is filled by a shade of gray that gets darker with an increasing number of SCCs that are above it in the condensation graph. Shadings repeat after a depth of 9.
- arguments:
igraph: interaction graph
example:
>>> add_style_sccs(igraph)
- add_style_subgraphs(igraph: DiGraph, subgraphs)¶
Adds the subgraphs given in subgraphs to igraph - or overwrites them if they already exist. Nodes that belong to the same dot subgraph are contained in a rectangle and treated separately during layout computations. subgraphs must consist of tuples of the form NodeList, Attributs where NodeList is a list of graph nodes and Attributes is a dictionary of subgraph attributes in dot format.
Note
subgraphs must satisfy the following property: Any two subgraphs have either empty intersection or one is a subset of the other. The reason for this requirement is that dot can not draw intersecting subgraphs.
- arguments:
igraph: interaction graph
subgraphs: pairs of lists and subgraph attributes
example:
>>> sub1 = (["v1","v2"], {"label":"Genes"}) >>> sub2 = (["v3","v4"], {}) >>> subgraphs = [sub1,sub2] >>> add_style_subgraphs(igraph, subgraphs)
- copy_ig(igraph: DiGraph) DiGraph ¶
Creates a copy of igraph including all dot attributes.
- arguments:
igraph: interaction graph
- returns:
new_igraph: new interaction graph
example:
>>> igraph2 = copy_ig(igraph)
- create_empty_igraph(primes: dict) DiGraph ¶
creates an empty igraph with default attributes
- create_image(primes: dict, fname_image: str, styles: List[str] = ['interactionsigns'], layout_engine: str = 'fdp')¶
A convenience function for drawing interaction graphs directly from the prime implicants. styles must be a sublist of [“interactionsigns”, “inputs”, “outputs”, “constants”, “sccs”, “anonymous”].
- arguments:
primes: prime implicants
fname_image: name of image
styles the styles to be applied
layout_engine: one of “dot”, “neato”, “fdp”, “sfdp”, “circo”, “twopi”
example:
>>> create_image(primes, "mapk_igraph.pdf", styles=["interactionsigns", "anonymous"])
- find_minimal_autonomous_nodes(igraph: DiGraph, core: Set[str]) List[Set[str]] ¶
Returns the minimal autonomous node sets of igraph. See Klarner2015(b) Sec. 5.2 for a formal definition and details. Minimal autonomous sets generalize inputs, which are autonomous sets of size 1. If Superset is specified then all autonomous sets that are not supersets of it are ignored.
- arguments:
igraph: interaction graph
core: all autonomous sets must be supersets of these components
- returns:
autonomous_nodes (list of sets): the minimal autonomous node sets of igraph
example:
>>> find_minimal_autonomous_nodes(igraph) [set(["raf"]), set(["v1","v8","v9"])]
- igraph2dot(igraph: DiGraph, fname_dot: Optional[str] = None) str ¶
Generates a dot file from igraph and saves it as fname_dot or returns it as a string.
- arguments:
igraph: interaction graph
fname_dot: name of dot file
- returns:
dot: contents of dot file as text
example:
>>> igraph2dot(igraph, "irma.dot") >>> dotfile = igraph2dot(igraph)
- igraph2image(igraph: DiGraph, fname_image: str, layout_engine='fdp')¶
Creates an image file from igraph using Graphviz and the force directed layout engine fdp. To find out which file formats are supported call
$ dot -T?
.- arguments:
igraph: interaction graph
fname_image: name of image
layout_engine: one of “dot”, “neato”, “fdp”, “sfdp”, “circo”, “twopi”
example:
>>> igraph2image(igraph, "mapk_igraph.pdf") >>> igraph2image(igraph, "mapk_igraph.jpg") >>> igraph2image(igraph, "mapk_igraph.svg")
- local_igraph_of_state(primes: dict, state: Union[dict, str]) DiGraph ¶
Computes the local interaction graph dF/dx of a state x.
- arguments:
primes: prime implicants
state: a state
- returns:
local_igraph: the local interaction graph
example:
>>> primes = get_primes("remy_tumorigenesis") >>> state = random_state(primes) >>> local_igraph = local_igraph_of_state(primes, state) >>> add_style_interactionsigns(local_igraph) >>> igraph2image(local_igraph, "local_igraph.pdf") created local_igraph.pdf
- local_igraph_of_states(primes: dict, states: List[Union[dict, str]])¶
Computes the local interaction graph of a states.
- primes2igraph(primes: dict) DiGraph ¶
Creates the interaction graph from the prime implicants of a network. Interaction graphs are implemented as NetworkX digraph objects. Edges are given the attribute sign whose value is a Python set containing 1 or -1 or both, depending on whether the interaction is activating or inhibiting or both.
- arguments:
primes: prime implicants
- returns:
igraph: interaction graph
example:
>>> bnet = "\n".join(["v1, v1","v2, 1", "v3, v1&!v2 | !v1&v2"]) >>> primes = bnet2primes(bnet) >>> igraph = primes2igraph(primes) >>> igraph.nodes() ["v1", "v2", "v3"] >>> igraph.edges() [("v1", "v1"), ("v1", "v3"), ("v2", "v3"), ("v3", "v1")] >>> igraph.adj["v1"]["v3"]["sign"] set([1, -1])