Usage¶
This notebook provides the steps to build a network starting from a list of genes, and using the default functionalities of NeKo.
%%time
from neko.core.network import Network
from neko._visual.visualize_network import NetworkVisualizer
import omnipath as op
CPU times: user 3.58 s, sys: 898 ms, total: 4.48 s Wall time: 4.48 s
1. Define the list of genes of interest¶
genes = ["SRC", "NOTCH1", "FAK", "CDH1", "CDH2", "VIM", "MAP4K4", "LATS1", "LATS2", "PTK2B"]
2. Create a network using as input the gene set.¶
Note
NB! If no resource is specified, the default used resource by the package is omnipath.interactions.Omnipath(). To add new resources, please see the Add resources tutorial.
2A. Import genes as network nodes¶
new_net1 = Network(genes, resources = 'omnipath')
#Print node dataframe
new_net1.nodes
| Genesymbol | Uniprot | Type | |
|---|---|---|---|
| 0 | SRC | P12931 | NaN |
| 1 | NOTCH1 | P46531 | NaN |
| 2 | PTK2 | Q05397 | NaN |
| 3 | CDH1 | P12830 | NaN |
| 4 | CDH2 | P19022 | NaN |
| 5 | VIM | P08670 | NaN |
| 6 | MAP4K4 | O95819 | NaN |
| 7 | LATS1 | O95835 | NaN |
| 8 | LATS2 | Q9NRM7 | NaN |
| 9 | PTK2B | Q14289 | NaN |
2B. Explore if the nodes are connected without introducing new intermidiate nodes¶
%%time
new_net1.connect_nodes(only_signed=True, consensus_only=True)
CPU times: user 189 ms, sys: 6 μs, total: 189 ms Wall time: 188 ms
2C. Visualize the network with the following command.¶
The network picture is also exported in the working repository, in pdf format.
visualizer = NetworkVisualizer(new_net1, color_by='effect', noi=True)
visualizer.render()
2D. Connect disconnected nodes by importing intermediate nodes.¶
maxlen is the mandatory maximum path length in edges.
path_policy controls which resource paths are selected when a connection is
missing: one_shortest selects one stable shortest path, all_shortest
selects the edge union of every shortest alternative, and all_bounded
selects every simple path through maxlen.
reuse_policy controls which topology can prevent later searches:
none keeps pair searches independent, discovered_paths reuses explicitly
selected paths, and induced_subgraph also exposes direct resource interactions
among all selected nodes.
only_signed restricts the search to signed interactions. consensus requires
sign consensus between references when the resource provides it. Stable
unweighted ordering improves reproducibility but is not a biological ranking.
%%time
new_net1.complete_connection(maxlen=3, path_policy="one_shortest", reuse_policy="discovered_paths", only_signed=True, consensus=True)
3. Visualize final network¶
#Visualize a specific nodes and
visualizer1 = NetworkVisualizer(new_net1,color_by='effect', noi=True)
visualizer1.render()
#Visualize a specific nodes and
visualizer1 = NetworkVisualizer(new_net1, predefined_node = "SRC",color_by='effect')
visualizer1.render()
#We can access to the edges of the network
new_net1.edges
| source | target | Type | Effect | References | Provenance | |
|---|---|---|---|---|---|---|
| 0 | P12931 | Q05397 | None | stimulation | Adhesome:10085298;Adhesome:10592173;Adhesome:1... | None |
| 1 | P12830 | P12931 | None | stimulation | ACSN:16039586;ACSN:16099633;ACSN:17143292;ACSN... | None |
| 2 | P12931 | P19022 | None | inhibition | ACSN:15782139;ACSN:16371504;ACSN:16492141;ACSN... | None |
| 3 | P12931 | Q14289 | None | stimulation | Adhesome:10329689;Adhesome:10521452;Adhesome:1... | None |
| 4 | Q14289 | Q05397 | None | stimulation | Adhesome:16760434;HPRD:16760434;KEA:12960434;K... | None |
| ... | ... | ... | ... | ... | ... | ... |
| 221 | P01106 | O95863 | None | stimulation | NaN | None |
| 222 | P61586 | P42336 | None | stimulation | NaN | None |
| 223 | P42336 | P61586 | None | stimulation | NaN | None |
| 224 | P05305 | P61586 | None | stimulation | NaN | None |
| 225 | Q13043 | O15151 | None | stimulation | NaN | None |
226 rows × 6 columns