Multi-Dendrix Logo

This Page

multi_dendrix.evaluate.network.avg_pair_dist_ratio

multi_dendrix.evaluate.network.avg_pair_dist_ratio(network, collection)[source]

Calculates the ratio of the average pairwise distance among genes within the same gene set and genes within different gene sets.

Parameters:
  • network (NetworkX Graph.) – PPI network (original or permuted).
  • collection – collection of gene sets to be tested.
Type :

collection: list of lists

Returns:

\(\rho(\mathbf{P})\) (float) - see definition below.

Test statistic:
For a collection of gene sets \(\mathbf{P}\):
  • Let \(\alpha'(\mathbf{P})=\) average pairwise distance among pairs of genes in the same gene set.
  • Let \(\beta'(\mathbf{P})=\) average pairwise distance among pairs of genes in different gene sets.

Then the average pairwise distance ratio \(\rho(\mathbf{P}) = \alpha'(\mathbf{P})-\beta'(\mathbf{P})\). Lower values of \(\rho(\mathbf{P})\) indicate stronger collections.

Note: if no path exists between any genes in the collection, the average pairwise distance ratio will go to infinity since the distance between two nodes in different components (or nodes not in the graph) is ill-defined.

Examples:
A view of example input:
>>> import networkx as nx
>>> collection = [["G1", "G2"], ["G3", "G4"]]
>>> G = nx.Graph()
>>> G.add_edges_from([("G1", "G2"), ("G3", "G4"), ("G2", "G5"), ("G4", "G5")])
>>> nx.draw_circular(G, node_size=125, font_size=8)
../../_images/direct_interactions_test_graph.png
Calculating \(\alpha'(\mathbf{P})\) and \(\beta'(\mathbf{P})\):
>>> dist_within = sum_dist(G, pairs_within(collection))
>>> alpha_prime  = float(dist_within) / float(len(pairs_within(collection)))
>>> (dist_within, alpha_prime)
(2, 1.0)
>>> dist_between = sum_dist(G, pairs_between(collection))
>>> beta_prime  = float(dist_between) / float(len(pairs_between(collection)))
>>> (dist_between, beta_prime)
(12, 3.0)
The direct interactions test statistic:
>>> avg_pair_dist_ratio(G, collection)
0.33

See also: direct_interactions_test(), eval_gene_sets_by_interactions().