Algorithms

NeuroMMSig

An implementation of the NeuroMMSig mechanism enrichment algorithm [DomingoFernandez2017].

[DomingoFernandez2017]Domingo-Fernández, D., et al (2017). Multimodal mechanistic signatures for neurodegenerative diseases (NeuroMMSig): A web server for mechanism enrichment. Bioinformatics, 33(22), 3679–3681.
pybel_tools.analysis.neurommsig.algorithm.get_neurommsig_scores_prestratified(it, genes, ora_weight=None, hub_weight=None, top=None, topology_weight=None)[source]

Takes a graph stratification and runs neurommsig on each

Parameters:
  • it (iter[tuple[str,pybel.BELGraph]]) – A pre-stratified set of graphs
  • genes (list[tuple]) – A list of gene nodes
  • ora_weight (Optional[float]) – The relative weight of the over-enrichment analysis score from neurommsig_gene_ora(). Defaults to 1.0.
  • hub_weight (Optional[float]) – The relative weight of the hub analysis score from neurommsig_hubs(). Defaults to 1.0.
  • top (Optional[float]) – The percentage of top genes to use as hubs. Defaults to 5% (0.05).
  • topology_weight (Optional[float]) – The relative weight of the topolgical analysis core from neurommsig_topology(). Defaults to 1.0.
  • preprocess (bool) – If true, preprocess the graph.
Returns:

A dictionary from {annotation value: NeuroMMSig composite score}

Return type:

Optional[dict[str, float]]

Pre-processing steps:

  1. Infer the central dogma with :func:``
  2. Collapse all proteins, RNAs and miRNAs to genes with :func:``
  3. Collapse variants to genes with :func:``
pybel_tools.analysis.neurommsig.algorithm.get_neurommsig_scores(graph, genes, annotation='Subgraph', ora_weight=None, hub_weight=None, top=None, topology_weight=None, preprocess=False)[source]

Preprocesses the graph, stratifies by the given annotation, then runs the NeuroMMSig algorithm on each.

Parameters:
  • graph (pybel.BELGraph) – A BEL graph
  • genes (list[tuple]) – A list of gene nodes
  • annotation (str) – The annotation to use to stratify the graph to subgraphs
  • ora_weight (Optional[float]) – The relative weight of the over-enrichment analysis score from neurommsig_gene_ora(). Defaults to 1.0.
  • hub_weight (Optional[float]) – The relative weight of the hub analysis score from neurommsig_hubs(). Defaults to 1.0.
  • top (Optional[float]) – The percentage of top genes to use as hubs. Defaults to 5% (0.05).
  • topology_weight (Optional[float]) – The relative weight of the topolgical analysis core from neurommsig_topology(). Defaults to 1.0.
  • preprocess (bool) – If true, preprocess the graph.
Returns:

A dictionary from {annotation value: NeuroMMSig composite score}

Return type:

Optional[dict[str, float]]

Pre-processing steps:

  1. Infer the central dogma with :func:``
  2. Collapse all proteins, RNAs and miRNAs to genes with :func:``
  3. Collapse variants to genes with :func:``
pybel_tools.analysis.neurommsig.algorithm.get_neurommsig_score(graph, target_genes, ora_weight=None, hub_weight=None, top=None, topology_weight=None)[source]

Calculates the composite NeuroMMSig Score for a given list of genes.

Parameters:
  • graph (pybel.BELGraph) – A BEL graph
  • target_genes (list[tuple]) – A list of gene nodes
  • ora_weight (Optional[float]) – The relative weight of the over-enrichment analysis score from neurommsig_gene_ora(). Defaults to 1.0.
  • hub_weight (Optional[float]) – The relative weight of the hub analysis score from neurommsig_hubs(). Defaults to 1.0.
  • top (Optional[float]) – The percentage of top genes to use as hubs. Defaults to 5% (0.05).
  • topology_weight (Optional[float]) – The relative weight of the topolgical analysis core from neurommsig_topology(). Defaults to 1.0.
Returns:

The NeuroMMSig composite score

Return type:

float

EpiCom

An implementation of chemical-based mechanism enrichment with NeuroMMSig [HoytDomingoFernandez2018].

This algorithm has multiple steps:

  1. Select NeuroMMSig networks for AD, PD, and epilepsy
  2. Select drugs from DrugBank, and their targets
  3. Run NeuroMMSig algorithm on target list for each network and each mechanism
  4. Store in database
[HoytDomingoFernandez2018]Charles Tapley Hoyt, Daniel Domingo-Fernández, Nora Balzer, Anka Güldenpfennig, Martin Hofmann-Apitius; A systematic approach for identifying shared mechanisms in epilepsy and its comorbidities, Database, Volume 2018, 1 January 2018, bay050
pybel_tools.analysis.epicom.algorithm.epicom_on_graph(graph, dtis, preprocess=True)[source]
Parameters:
Return type:

iter[tuple[str,str,float]]

pybel_tools.analysis.epicom.algorithm.multi_run_epicom(graphs, path)[source]

Run EpiCom analysis on many graphs

Parameters:
pybel_tools.analysis.epicom.algorithm.run_epicom(graph, directory)[source]
Parameters:
  • graph (pybel.BELGraph) – A BEL Graph
  • directory (str) – The directory in which the algorithm is run
Return type:

iter[tuple[str,str,str,float]]

Reverse Causal Reasoning

An implementation of Reverse Causal Reasoning (RCR) [Catlett2013].

[Catlett2013]Catlett, N. L., et al (2013). Reverse causal reasoning: applying qualitative causal knowledge to the interpretation of high-throughput data. BMC Bioinformatics, 14(1), 340.
pybel_tools.analysis.rcr.run_rcr(graph, tag='dgxp')[source]

Runs the reverse causal reasoning algorithm on a graph.

Steps:

  1. Get all downstream controlled things into map (that have at least 4 downstream things)
  2. calculate population of all things that are downstream controlled

Note

Assumes all nodes have been pre-tagged with data

Parameters:
  • graph (pybel.BELGraph) –
  • tag (str) – The key for the nodes’ data dictionaries that corresponds to the integer value for its differential expression.

Sample of Spanning Trees

An implementation of the sampling of spanning trees (SST) algorithm [Vasilyev2014]_.

pybel_tools.analysis.sst.rank_edges(edges, edge_ranking=None)[source]

Returns the highest ranked edge from a multiedge

Parameters:
  • edges (dict) – dictionary with all edges between two nodes
  • edge_ranking (dict) – A dictionary of {relationship: score}
Returns:

Highest ranked edge

Return type:

tuple: (edge id, relation, score given ranking)

class pybel_tools.analysis.sst.Effect[source]

Represents the possible effect of a root node on a target

pybel_tools.analysis.sst.get_path_effect(graph, path, relationship_dict)[source]

Calculates the final effect of the root node to the sink node in the path

Parameters:
  • graph (pybel.BELGraph) – A BEL graph
  • path (list) – Path from root to sink node
  • relationship_dict (dict) – dictionary with relationship effects
Return type:

Effect

pybel_tools.analysis.sst.run_cna(graph, root, targets, relationship_dict=None)[source]

Returns the effect from the root to the target nodes represented as {-1,1}

Parameters:
  • graph (pybel.BELGraph) – A BEL graph
  • root (BaseEntity) – The root node
  • targets (iter) – The targets nodes
  • relationship_dict (dict) – dictionary with relationship effects
Return list[tuple]:
 
pybel_tools.analysis.sst.get_random_walk_spanning_tree(graph)[source]

Generates a spanning tree from the directed graph using the random walk appropach proposed independently by by Broder (1989) and Aldous (1990). It simply generates random walks until all nodes have been covered.

Algorithm:

  1. Choose a starting vertex s arbitrarily. Set T_V ← {s} and T_E ← ∅.
  2. Do a simple random walk starting at s. Whenever we cross an edge e = {u, v} with v ∈ V ,
    add v to TV and add e to TE.
  3. Stop the random walk when TV = V . Output T = (T_V , T_E) as our spanning tree
Parameters:graph (networkx.DiGraph) – The input graph
Return type:networkx.DiGraph
pybel_tools.analysis.sst.rank_causalr_hypothesis(graph, node_to_regulation, regulator_node)[source]

Returns the results of testing the regulator hypothesis of the given node on the input data. Note: this method returns both +/- signed hypotheses evaluated The algorithm is described in G Bradley et al. (2017)

Algorithm

  1. Calculate the shortest path between the regulator node and each node in observed_regulation

2. Calculate the concordance of the causal network and the observed regulation when there is path between target node and regulator node

Parameters:
  • graph (networkx.DiGraph) – A causal graph
  • node_to_regulation (dict) – Nodes to score (1,-1,0)
  • graph – A causal graph
Return Dictionaries with hypothesis results (keys:
 

score, correct, incorrect, ambiguous)

Return type:

dict