Skip to content Skip to sidebar Skip to footer

Gene Network Topological Overlap Python

In a complex gene network how can we find a topological overlap. Input data as follows code code weight 3423 3455 3453 2344 2353 45 3432 3453 456 3235 4566 34532 2345 8

Solution 1:

I must confess that I wasn't familiar with the term topological overlap so I had to look it up:

A pair of nodes in a network is said to have high topological overlap if they are both strongly connected to the same group of nodes. (Source)

NetworkX doesn't seem to have a builtin method which lets you find pairs of nodes with topological overlap but it can easily find strongly connected components. For example:

In [1]: import networkx as nx
In [2]: edge_list = [(1, 2), (2, 1), (3, 1), (1, 3), (2, 4), (1, 4), (5, 6)]
In [3]: G = nx.DiGraph()
In [4]: G.add_edges_from(edge_list)
In [5]: components = nx.strongly_connected_components(G)
In [6]: components
Out[6]: [[1, 3, 2], [4], [6], [5]]

If you have an undirected graph you can use nx.connected_components instead.

Now you have components, it is straightforward to find all lists of pairs with toplogical overlap. For example, generate all pairs of nodes from lists in components:

In [7]: from itertools import combinations
In [8]: top_overlap = [list(combinations(c, 2)) for c in components if len(c) > 1]
In [9]: top_overlap = [item for sublist in top_overlap for item in sublist]
In [10]: top_overlap
Out[10]: [(1, 3), (1, 2), (3, 2)]

Post a Comment for "Gene Network Topological Overlap Python"