Network comparison

In some cases, it might be of interest to compare two networks with each other. For instance, you might want to compare an existing network with the Neko-generated network, or compare the resulting networks from two different network construction strategies.

The following code shows the comparison of two networks, built with different input parameters of the complete_connections function.

[1]:
%%time
from neko.core.network import Network
from neko._visual.visualize_network import NetworkVisualizer
from neko.inputs import Universe
from neko._annotations.gene_ontology import Ontology
from neko._methods.compare import compare_networks
import omnipath as op
CPU times: user 5.76 s, sys: 1.66 s, total: 7.42 s
Wall time: 5.09 s

1. Define the list of genes of interest

[2]:
genes = ["SRC", "NOTCH1", "FAK", "CDH1", "CDH2", "VIM", "MAP4K4", "LATS1", "LATS2", "PTK2B"]

2. Create networks.

Please refer to the Usage tutorial for a detailed explanation of each step.

2A. Build first network

For the first network, we specify that we do not want to take into account the concensus sign (i.e. activation vs inhibition) for the interactions.

[3]:
new_net1 = Network(genes, resources = 'omnipath')
new_net1.connect_nodes(only_signed=True, consensus_only=True)
new_net1.complete_connection(maxlen=6, algorithm="bfs", only_signed=True, connect_with_bias=True, consensus=True)

2B. Build second network

For the second network, we set the consensus argument to True.

[4]:
new_net2 = Network(genes, resources = 'omnipath')
new_net2.connect_nodes(only_signed=True, consensus_only=True)
new_net2.complete_connection(maxlen=3, algorithm="dfs", only_signed=True, connect_with_bias=True, consensus=True)

3. Compare networks

The compare_networks functions receives as input the two network objects of interest. Its output is two dataframes; one for the comparison of the edges and for the comparison of nodes.

[5]:
interaction_comparison, node_comparison = compare_networks(new_net1, new_net2)
[6]:
print(interaction_comparison)
    source  target           comparison
0     ABL1     APP  Unique to Network 2
1     ABL1     BTK  Unique to Network 2
2     ABL1    CDH2               Common
3     ABL1  CTNNB1               Common
4     ABL1    EGFR               Common
..     ...     ...                  ...
715   WNT1   ITGB4  Unique to Network 2
716   WNT1    LEF1  Unique to Network 2
717   WNT1  MAP3K7  Unique to Network 2
718   WNT1  NOTCH1  Unique to Network 2
719    ZYX     SRC               Common

[720 rows x 3 columns]
[7]:
print(node_comparison)
       node           comparison
0     IKBKB  Unique to Network 1
1     ROCK1  Unique to Network 1
2     SNAI2  Unique to Network 1
3     PRKG1  Unique to Network 1
4      TP63  Unique to Network 1
..      ...                  ...
101   PTK2B               Common
102    PTEN               Common
103    CDH2               Common
104    CDH1               Common
105  MAP4K4               Common

[106 rows x 2 columns]