Candidate Mechanism Generation

This module provides functions for generating subgraphs based around a single node, most likely a biological process.

Subgraphs induced around biological processes should prove to be subgraphs of the NeuroMMSig/canonical mechanisms and provide an even more rich mechanism inventory.

pybel_tools.generation.remove_unweighted_leaves(graph, key)[source]
Parameters:
  • graph (pybel.BELGraph) – A BEL graph
  • key (str) – The key in the node data dictionary representing the experimental data
pybel_tools.generation.is_unweighted_source(graph, node, key)[source]
Parameters:
  • graph (pybel.BELGraph) – A BEL graph
  • node (tuple) – A BEL node
  • key (str) – The key in the node data dictionary representing the experimental data
pybel_tools.generation.get_unweighted_sources(graph, key)[source]

Gets unannotated nodes on the periphery of the subgraph

Parameters:
  • graph (pybel.BELGraph) – A BEL graph
  • key (str) – The key in the node data dictionary representing the experimental data
Returns:

An iterator over BEL nodes that are unannotated and on the periphery of this subgraph

Return type:

iter[tuple]

pybel_tools.generation.remove_unweighted_sources(graph, key)[source]

Prunes unannotated nodes on the periphery of the subgraph

Parameters:
  • graph (pybel.BELGraph) – A BEL graph
  • key (str) – The key in the node data dictionary representing the experimental data
pybel_tools.generation.prune_mechanism_by_data(graph, key)[source]

Removes all leaves and source nodes that don’t have weights. Is a thin wrapper around remove_unweighted_leaves() and remove_unweighted_sources()

Parameters:
  • graph (pybel.BELGraph) – A BEL Graph
  • key (str) – The key in the node data dictionary representing the experimental data. If none, does not prune unannotated nodes after generation

Equivalent to:

>>> remove_unweighted_leaves(graph, key)
>>> remove_unweighted_sources(graph, key)
pybel_tools.generation.generate_mechanism(graph, node, key=None)[source]

Generates a mechanistic subgraph upstream of the given node

Parameters:
  • graph (pybel.BELGraph) – A BEL Graph
  • node (tuple) – The target BEL node for generation
  • key (str) – The key in the node data dictionary representing the experimental data. If none, does not prune unannotated nodes after generation
Returns:

A subgraph grown around the target BEL node

Return type:

pybel.BELGraph

pybel_tools.generation.generate_bioprocess_mechanisms(graph, key=None)[source]

Generates a mechanistic subgraph for each biological process in the graph using generate_mechanism()

Parameters:
  • graph (pybel.BELGraph) – A BEL Graph
  • key (str) – The key in the node data dictionary representing the experimental data. If none, does not prune unannotated nodes after generation
Returns:

A dictionary from {tuple bioprocess node: BELGraph candidate mechanism}

Return type:

dict[tuple, pybel.BELGraph]