Skip to content

Commit

Permalink
Add network comparison tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
Eirinits committed Jul 23, 2024
1 parent fa6c5b4 commit f5ed938
Showing 1 changed file with 63 additions and 92 deletions.
155 changes: 63 additions & 92 deletions notebooks/8_Compare_networks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 4,
"id": "3c317de8",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CPU times: user 10.9 s, sys: 410 ms, total: 11.3 s\n",
"Wall time: 12.3 s\n"
"CPU times: user 40 µs, sys: 0 ns, total: 40 µs\n",
"Wall time: 44.6 µs\n"
]
}
],
Expand All @@ -49,7 +49,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 5,
"id": "79c09e13",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -79,14 +79,14 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 6,
"id": "fcf68a99-8454-41e3-8816-c3f976d04c0b",
"metadata": {},
"outputs": [],
"source": [
"new_net1 = Network(genes)\n",
"new_net1.connect_nodes(only_signed=True, consensus_only=True)\n",
"new_net1.complete_connection(maxlen=6, k_mean=\"tight\", only_signed=True, connect_node_when_first_introduced=True, consensus=False)"
"new_net1.complete_connection(maxlen=6, algorithm=\"bfs\", only_signed=True, connect_with_bias=True, consensus=True)"
]
},
{
Expand All @@ -101,14 +101,14 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 8,
"id": "5d13c798-975b-43ef-a841-1fc6176578af",
"metadata": {},
"outputs": [],
"source": [
"new_net2 = Network(genes)\n",
"new_net2.connect_nodes(only_signed=True, consensus_only=True)\n",
"new_net2.complete_connection(maxlen=6, k_mean=\"tight\", only_signed=True, connect_node_when_first_introduced=True, consensus=True)"
"new_net2.complete_connection(maxlen=3, algorithm=\"dfs\", only_signed=True, connect_with_bias=True, consensus=True)"
]
},
{
Expand All @@ -119,115 +119,86 @@
"## 3. Compare networks"
]
},
{
"cell_type": "markdown",
"id": "9c1d69b5-1e70-456c-a702-61cb37f52dc3",
"metadata": {},
"source": [
"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. "
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 9,
"id": "381a43b7-032f-40f7-8846-924901ff0161",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"interaction_comparison, node_comparison = compare_networks(new_net1, new_net2)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "3aa53d75-38bb-4210-90fa-2cf4535d49e7",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" source target comparison\n",
"0 ABL1 CTNNB1 Common\n",
"1 ABL1 CTNND1 Unique to Network 2\n",
"2 ABL1 EGFR Unique to Network 2\n",
"3 ABL1 MAP3K1 Common\n",
"4 ABL1 MET Unique to Network 2\n",
".. ... ... ...\n",
"199 WWTR1 RUNX2 Common\n",
"200 WWTR1 SMAD3 Common\n",
"201 YAP1 CTNNB1 Common\n",
"202 YAP1 ITCH Unique to Network 1\n",
"203 YAP1 RUNX2 Common\n",
" source target comparison\n",
"0 SRC PTK2 Common\n",
"1 CDH1 SRC Common\n",
"2 SRC CDH2 Common\n",
"3 SRC PTK2B Common\n",
"4 NOTCH1 CDH2 Common\n",
"... ... ... ...\n",
"1008 PAK2 MAPK14 Unique to Network 2\n",
"1009 PDPK1 AKT3 Unique to Network 2\n",
"1010 HNF4A SDC2 Unique to Network 2\n",
"1011 LATS2 AMOTL2 Unique to Network 2\n",
"1012 AMOTL2 SRC Unique to Network 2\n",
"\n",
"[204 rows x 3 columns]\n",
" node comparison\n",
"0 PRKCA Unique to Network 1\n",
"1 STAT3 Unique to Network 1\n",
"2 TP53 Unique to Network 1\n",
"3 HIF1A Unique to Network 1\n",
"4 CDON Unique to Network 1\n",
"5 ITCH Unique to Network 1\n",
"6 STK3 Unique to Network 2\n",
"7 ITGAE Unique to Network 2\n",
"8 NF2 Unique to Network 2\n",
"9 MET Unique to Network 2\n",
"10 PTPRH Unique to Network 2\n",
"11 EGFR Unique to Network 2\n",
"12 PRKD1 Unique to Network 2\n",
"13 PTPN1 Unique to Network 2\n",
"14 PDPK1 Unique to Network 2\n",
"15 NUAK1 Unique to Network 2\n",
"16 ITGB1 Unique to Network 2\n",
"17 ITGB4 Unique to Network 2\n",
"18 PPP2CA Unique to Network 2\n",
"19 STK4 Unique to Network 2\n",
"20 CTNND1 Unique to Network 2\n",
"21 RAF1 Unique to Network 2\n",
"22 PTK2 Common\n",
"23 ABL1 Common\n",
"24 WWTR1 Common\n",
"25 ITGB7 Common\n",
"26 PRKCD Common\n",
"27 PAK2 Common\n",
"28 SMAD3 Common\n",
"29 CDH1 Common\n",
"30 MAPK8 Common\n",
"31 LATS2 Common\n",
"32 SRC Common\n",
"33 CTNNB1 Common\n",
"34 MAP3K7 Common\n",
"35 CSK Common\n",
"36 LATS1 Common\n",
"37 RUNX2 Common\n",
"38 PRKACA Common\n",
"39 MAP3K1 Common\n",
"40 YAP1 Common\n",
"41 DAB1 Common\n",
"42 VIM Common\n",
"43 CDH2 Common\n",
"44 NOTCH1 Common\n",
"45 AMOTL2 Common\n",
"46 AKT1 Common\n",
"47 PEBP1 Common\n",
"48 PTK2B Common\n",
"49 MAP4K4 Common\n"
"[1013 rows x 3 columns]\n"
]
}
],
"source": [
"interaction_comparison, node_comparison = compare_networks(new_net1, new_net2)\n",
"print(interaction_comparison)\n",
"print(node_comparison)"
"print(interaction_comparison)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "20b296c0-adf7-40ee-9767-6728ace0cc8b",
"execution_count": 11,
"id": "8a16da4d-c34f-466a-8e0f-4dfa42a635be",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "df7472721e424dee9c1828d4202cbab7",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"GraphWidget(layout=Layout(height='800px', width='100%'))"
]
},
"metadata": {},
"output_type": "display_data"
"name": "stdout",
"output_type": "stream",
"text": [
" node comparison\n",
"0 RHOA Unique to Network 1\n",
"1 MOB1A Unique to Network 1\n",
"2 PIK3R1 Unique to Network 1\n",
"3 MAP3K8 Unique to Network 1\n",
"4 SNAI2 Unique to Network 1\n",
".. ... ...\n",
"95 LATS1 Common\n",
"96 MAPK8 Common\n",
"97 RELB Common\n",
"98 SRC Common\n",
"99 ITGB1 Common\n",
"\n",
"[100 rows x 2 columns]\n"
]
}
],
"source": [
"NetworkVisualizer.vis_comparison(interaction_comparison, node_comparison,\"hierarchic\", True)"
"print(node_comparison)"
]
}
],
Expand All @@ -247,7 +218,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.10.13"
}
},
"nbformat": 4,
Expand Down

0 comments on commit f5ed938

Please sign in to comment.