booldog.io.interaction_networks
Read standard networks formats/objects (networkx, igraph, graphml, SIF) and convert to Boolean network.
Attributes
Functions
|
Convert a NetworkX Graph into a nested dictionary of interactions. |
|
Convert an igraph Graph into a list of interactions. |
|
Create Network from interactions (list) |
|
Reads in a SIF file of interactions |
|
Create BooleanNetwork from a igraph Graph object. |
|
Create BooleanNetwork from a networkx (Di)Graph object. |
|
Extract relavent parts for a Boolean network from a graphml file. |
Module Contents
- booldog.io.interaction_networks._IGRAPH_AVAILABLE = True
- booldog.io.interaction_networks.logger
- booldog.io.interaction_networks.networkx2interactions(g, edge_type_key='interaction', **_)
Convert a NetworkX Graph into a nested dictionary of interactions.
- Parameters:
g (networkx.(Di)Graph) – The input graph object from the Networkx library. (Assumed to be directed.)
edge_type_key (str, optional) – The edge attribute key to use for interaction values (e.g., weight, type). Default is “interaction”.
**_ (dict) – Additional keyword arguments (ignored).
- Returns:
A nested dictionary where interactions[source][target] = symbol, with symbol being the edge attribute specified by edge_type_key.
- Return type:
dict of dict
- booldog.io.interaction_networks.igraph2interactions(g, node_id_key='name', edge_type_key='interaction')
Convert an igraph Graph into a list of interactions.
- Parameters:
g (igraph.Graph) – The input graph object from the igraph library.
node_id_key (str, optional) – The vertex attribute key that contains the primary identifier to use for node identifiers. Default is “name”.
edge_type_key (str, optional) – The edge attribute key to use for interaction type (e.g., weight, type). Default is “interaction”.
- Returns:
A nested dictionary where interactions[source][target] = symbol, with symbol being the edge attribute specified by edge_type_key.
- Return type:
dict of dict
- booldog.io.interaction_networks.read_interactions(interactions_input, node_names=None, **kwargs)
Create Network from interactions (list)
- Parameters:
interactions_input (list or str) – A list of interactions in the network. Each interaction should be a tuple of (source, target, sign), where source and target are node identifiers and sign is either activator_symbol or inhibitor_symbol. Or a path to a JSON file containing such a list of interactions.
activator_symbol (int, optional) – The value representing activation in the network. Default is 1.
inhibitor_symbol (int, optional) – The value representing inhibition in the network. Default is -1.
**kwargs (dict) – Additional keyword arguments (ignored).
- Returns:
n – A BoolDogModel object representing the Boolean network.
- Return type:
Notes
Uses SQUAD logic to obtain Boolean network.
- booldog.io.interaction_networks.read_sif(file, delim='\t', source_col=0, target_col=1, interaction_col=2, header=True, **kwargs)
Reads in a SIF file of interactions
- Parameters:
file (str) – Path to the SIF file
delim (str, optional) – Delimiter used in the SIF file (default=” “)
header (bool, optional) – If the first line of the file is a header (default=True)
source_col (int or str, optional) – Column index (if int) or column name (if str) of source node (default=0)
target_col (int or str, optional) – Column index (if int) or column name (if str) of target node (default=1)
interaction_col (int, optional) – Column index (if int) or column name (if str) of interaction type (symbol) (default=2)
activator_symbol (str, optional) – Symbol of activation edges in interaction_col (default=”1”)
inhibitor_symbol (str, optional) – Symbol of inhibition edges in interaction_col (default=”-1”)
**kwargs (dict) – Additional keyword arguments (ignored).
Notes
Uses SQUAD logic to obtain Boolean network.
- booldog.io.interaction_networks.read_igraph(g, node_id_key='name', edge_type_key='interaction', node_name_key='name', **kwargs)
Create BooleanNetwork from a igraph Graph object.
- Parameters:
g (igraph.Graph) – The input graph object from the igraph library.
node_id_key (str, optional) – The vertex attribute key that contains the primary identifier to use for node names. Default is “name”.
node_name_key (str, optional) – The vertex attribute key that contains the node name (e.g. display label). Default is “name”.
edge_type_key (str, optional) – The edge attribute key to use for interaction values (e.g., weight, type). Default is “interaction”.
activator_symbol (str, optional) – Symbol or value of activation edges in edge_type_key of g (default=”1”)
inhibitor_symbol (str, optional) – Symbol or value of inhibition edges in edge_type_key of g (default=”-1”)
**kwargs (dict) – Additional keyword arguments (ignored).
Notes
Uses SQUAD logic to obtain Boolean network.
- booldog.io.interaction_networks.read_networkx(g, edge_type_key='interaction', node_name_key='name', **kwargs)
Create BooleanNetwork from a networkx (Di)Graph object.
- Parameters:
g (networkx.(Di)Graph) – The input graph object from the networkx library.
edge_type_key (str, optional) – The edge attribute key to use for interaction values (e.g., weight, type). Default is “interaction”.
activator_symbol (str, optional) – Symbol or value of activation edges in edge_type_key of g (default=”1”)
inhibitor_symbol (str, optional) – Symbol or value of inhibition edges in edge_type_key of g (default=”-1”)
node_name_key (str, optional) – The vertex attribute key that contains the node name (display label). Default is “name”.
**kwargs (dict) – Additional keyword arguments (ignored).
- Returns:
n – A BoolDogModel object representing the Boolean network.
- Return type:
Notes
Uses SQUAD logic to obtain Boolean network.
- booldog.io.interaction_networks.read_graphml(file, edge_type_key='interaction', node_id_key='name', node_name_key='name', yEd_labels=False, yEd_arrow_head=False, use_labels=True, **kwargs)
Extract relavent parts for a Boolean network from a graphml file.
Since graphml is not well defined for Boolean networks (or even standard for interaction networks), this read functionality has limited support.
- Parameters:
file (str) – Path to the graphml file
edge_type_key (str, optional) – The edge attribute key to use for interaction type (e.g., weight, type). Default is “interaction”. Only if yEd=False (yEd uses the arrow head symbol).
node_id_key (str, optional) – The vertex attribute key that contains the primary identifier to use for node names. Default is “name”.
node_name_key (str, optional) – The vertex attribute key that contains the node name (e.g. display label). Default is “name”.
yEd_labels (bool, optional) – If graphml file originates as a yEd export, the node attribute “y:NodeLabel” is used to determine node names (default=False)
yEd_arrow_head (bool, optional) – If graphml file originates as a yEd export, the edge attribute “y:Arrows” is used to determine interaction type (default=False)
activator_symbol (int or str, optional) – Symbol or value of activation edges. If yEd=True, default=”standard”, else default is 1.
inhibitor_symbol (int or str, optional) – Symbol or value of inhibition edges. If yEd=True, default=”t_shape”, else default is -1.
- Returns:
n – A BoolDogModel object representing the Boolean network.
- Return type:
Notes
Uses igraph to parse the graphml file, and extracts node and edge attributes to determine interactions.
If yEd_label=True, it also parses the yEd-specific attributes to extract node labels (y:NodeLabel) for node names.
If yEd_arrow_head=True, it parses the yEd-specific edge arrow types (arrow head symbols of y:Arrows) to determine interaction types (activation/inhibition).