From 9b7cee026dcb861288bcb0c7fa1b2cf86841595c Mon Sep 17 00:00:00 2001 From: veronicavenafra Date: Wed, 4 Dec 2024 11:03:57 +0100 Subject: [PATCH 1/4] new signalingprofiler vignette --- docs/src/nc_signalingprofiler.svg | 1 + docs/src/vignettes/B_signalingprofiler.ipynb | 317 +++++++++++++++++++ 2 files changed, 318 insertions(+) create mode 100644 docs/src/nc_signalingprofiler.svg create mode 100644 docs/src/vignettes/B_signalingprofiler.ipynb diff --git a/docs/src/nc_signalingprofiler.svg b/docs/src/nc_signalingprofiler.svg new file mode 100644 index 0000000..f1584b1 --- /dev/null +++ b/docs/src/nc_signalingprofiler.svg @@ -0,0 +1 @@ +networkcommonsOne-layerTKPPOTwo-layersOKPPOTTTFirstlayerSecondlayerThree-layersKKPPKTTTOKOOThirdlayer \ No newline at end of file diff --git a/docs/src/vignettes/B_signalingprofiler.ipynb b/docs/src/vignettes/B_signalingprofiler.ipynb new file mode 100644 index 0000000..a795c9f --- /dev/null +++ b/docs/src/vignettes/B_signalingprofiler.ipynb @@ -0,0 +1,317 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Vignette B: Hierarchical network generation using SignalingProfiler" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In this vignette, we are going to use SignalingProfiler:\n", + "\n", + "> Venafra et al., SignalingProfiler 2.0 a network-based approach to bridge multi-omics data to phenotypic hallmarks. *npj Syst Biol Appl* **10**, 95 (2024). https://doi.org/10.1038/s41540-024-00417-6\n", + "\n", + " to build hierachical signaling models combining topology-based methods and CORNETO-CARNIVAL.\n", + "\n", + "This is the python implementation of the network construction step (Step2) of SignalingProfiler workflow detailed in this [R vignette](https://html-preview.github.io/?url=https://github.com/SaccoPerfettoLab/SignalingProfiler/blob/main/SignalingProfiler-2.0-tutorial/SignalingProfiler-2.0-tutorial.html) within the package SignalingProfiler. For more information, please check the [SignalingProfiler section](../methods.html#signalingprofiler) in the Methods details and the [original SignalingProfiler paper](https://doi.org/10.1038/s41540-024-00417-6)." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "import networkcommons as nc\n", + "import decoupler as dc\n", + "import pandas as pd" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "SignalingProfiler offers three types of layered networks, with increasing level of deepness and computational costs. The choice is mainly based on the molecular functions of the targets proteins in your datasets. To illustrate this aspect, this notebook is showcase two applications." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## A. Generate one-layered networks from perturbed transcription factors data" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In this notebook, we will use data from the NCI60 Human Tumor Cell Lines Screen. We will use the cell line 706-0. To have an overview of the cell lines, we can run `nc.data.omics.nci60_datasets()`. For more information, please check the [NCI60 details page](../datasets.html#nci60)." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### A1. Input preparation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We first select Omnipath PPI netwok as a prior knowledge network." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "network = nc.data.network.get_omnipath()\n", + "graph = nc.utils.network_from_df(network)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Like in the [previous vignette](2_multiple_methods.ipynb), we will use a specific contrast from the [PANACEA](../datasets.html#panacea) (Afatinib versus DMSO in ASPC cell line) to extract the transcription factors that are dysregulated." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dc_estimates = nc.data.omics.panacea_tables(cell_line='ASPC', drug='AFATINIB', type='TF_scores')\n", + "dc_estimates.set_index('items', inplace=True)\n", + "measurements = nc.utils.targetlayer_formatter(dc_estimates, act_col='act')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Afatinib targets EGFR by inhibition, so we will create a source dictionary containing the origin of perturbation, EGFR, and the sign of the perturbation (negative, therefore -1)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "source_df = pd.DataFrame({'source': ['EGFR'], \n", + " 'sign': [-1]}, columns=['source', 'sign'])\n", + "source_df.set_index('source', inplace=True)\n", + "sources = source_df['sign'].to_dict()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### A2. Generate one-layer network" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now, we will call SignalingProfiler to first restrict the OmniPath PPI network to all the paths of user-defined length (param ) from the source to the transcription factors. Then, running CORNETO-CARNIVAL only the sign-consistent paths will be retrieved. \n", + "The topology-based algorithm significantly reduces the CORNETO computation time." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "optimized = run_signalingprofiler(sources=sources, \n", + " measurements=measurements,\n", + " graph = graph, \n", + " layers = 1, \n", + " max_length=4,\n", + " betaWeight=0.1, \n", + " solver='GUROBI') " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Then, we can visualized the optimized network." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "visualizer = nc.visual.NetworkXVisualizer(optimized)\n", + "visualizer.visualize_network(sources, measurements)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## B. Generate three-layered networks from perturbed kinases, phosphatases, and transcription factors" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In this second part, we will use data modalities from the work of [Olsen et al., (2006)](https://doi.org/10.1016/j.cell.2006.09.026) where HeLa cells where stimulated with EGF treatment. " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### B1. Input preparation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We first select Omnipath PPI netwok as a prior knowledge network." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "network = nc.data.network.get_omnipath()\n", + "graph = nc.utils.network_from_df(network)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Since cells were stimulated with EGF, we set EGFR as a starting perturbed node for the model." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "source_df = pd.DataFrame({'source': ['EGFR'],\n", + " 'sign': [-1]}, columns=['source', 'sign'])\n", + "source_df.set_index('source', inplace=True)\n", + "sources = source_df['sign'].to_dict()\n", + "sources" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Using SignalingProfiler R protein activity inference pipeline, we previously inferred the activity of 56 kinases, 5 phosphatases, 3 transcription factors, and 10 other signaling proteins (see the [original publication](https://doi.org/10.1038/s41540-024-00417-6) for details). " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "protein_df = pd.read_table('./data/usecase/protein_activities.tsv', sep = '\\t')\n", + "\n", + "# Remove from proteins list the perturbed node\n", + "protein_df = protein_df.loc[protein_df['gene_name'] != 'EGFR']\n", + "\n", + "# Renaming columns\n", + "protein_df_sub = protein_df[['gene_name', 'final_score']]\n", + "protein_df_sub.columns = ['items', 'act']\n", + "\n", + "protein_df_sub.set_index('items', inplace=True)\n", + "measurements = nc.utils.targetlayer_formatter(protein_df_sub, act_col='act', n_elements = 100)\n", + "measurements" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### B2. Generate three-layers network" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Since the proteins list has kinases, phosphatases, other signaling proteins, and transcription factors, in the three-layers network SignalingProfiler will create: (i) a first layer from the perturbed receptor to kinases/phosphatases, whose length is encoded by the first argument of `max_length` parameter; (ii) a second layer with one step interactions between kinases/phosphatases and other phosphorylated proteins (not customizable); (iii) a third layer from kinases/phosphatases/other to transcription factors, whose length depends from the second argument of `max_length` parameter. Then, this network will be optimized by CARNIVAl-CORNETO to be sign-consistent with protein activities. \n", + "The topology-based algorithm significantly reduces the CORNETO computation time." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "optimized = run_signalingprofiler(sources=sources, \n", + " measurements=measurements,\n", + " graph = graph, \n", + " layers = 3, #also 2 performs correctly\n", + " max_length=[3,4],\n", + " betaWeight=0.1, \n", + " solver='GUROBI') " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Then, we can visualize the network." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "visualizer = nc.visual.NetworkXVisualizer(optimized)\n", + "visualizer.visualize_network(sources, measurements)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "networkcommons_test_SP3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.14" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From b2bc7b52e09dac013e175ef4a1b1e4bc5b79a84b Mon Sep 17 00:00:00 2001 From: veronicavenafra Date: Wed, 4 Dec 2024 11:04:13 +0100 Subject: [PATCH 2/4] update mail perfetto --- networkcommons/methods/_signalingprofiler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/networkcommons/methods/_signalingprofiler.py b/networkcommons/methods/_signalingprofiler.py index 4d42669..b4cd7fa 100644 --- a/networkcommons/methods/_signalingprofiler.py +++ b/networkcommons/methods/_signalingprofiler.py @@ -6,7 +6,7 @@ # Copyright 2024 # Heidelberg University Hospital # -# File author(s): Perfetto Lab (livia.perfetto@gmail.com) +# File author(s): Perfetto Lab (livia.perfetto@uniroma1.com) # # Distributed under the GPLv3 license # See the file `LICENSE` or read a copy at From aa0878e08a84f0eafa7211d5b9b22490171146f8 Mon Sep 17 00:00:00 2001 From: veronicavenafra Date: Wed, 4 Dec 2024 11:04:40 +0100 Subject: [PATCH 3/4] corrected descritpion according new image --- docs/src/methods.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/methods.rst b/docs/src/methods.rst index 2b55094..91b5c5b 100644 --- a/docs/src/methods.rst +++ b/docs/src/methods.rst @@ -195,7 +195,7 @@ In the one-layer network, the perturbed node is connected to every target and is The two-layers network connects the perturbed node to kinases/phosphatases/others (first layer) and then connect the latters to transcription factors (second layer). The three-layers network adds another layer between kinases/phosphatases and other signaling proteins. -In the second step, SignalingProfiler calls "CORNETO - CARNIVAL" to retrieve only sign-consistent edges from the naïve network (removing grey dashed edges). +In the second step, SignalingProfiler calls "CORNETO - CARNIVAL" to retrieve only sign-consistent edges from the naïve network (removing white dashed edges). .. raw:: html From a24d3eb68f1acda4f89b6cc605dabde425eee1cf Mon Sep 17 00:00:00 2001 From: veronicavenafra Date: Wed, 4 Dec 2024 11:05:10 +0100 Subject: [PATCH 4/4] new signalingprofiler visual --- docs/src/_static/nc_signalingprofiler.svg | 803 +--------------------- 1 file changed, 1 insertion(+), 802 deletions(-) diff --git a/docs/src/_static/nc_signalingprofiler.svg b/docs/src/_static/nc_signalingprofiler.svg index e98808b..f1584b1 100644 --- a/docs/src/_static/nc_signalingprofiler.svg +++ b/docs/src/_static/nc_signalingprofiler.svg @@ -1,802 +1 @@ - - - - -Naive network generation + CARNIVAL optimization - - - One-layer - - - - - - - - - - - - - - T - - - - - K - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PP - - - - O - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Two-layers - - - - - - O - - - - K - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PP - - - O - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - T - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - T - - - - - - - - - - - - - - - - - - - - - - - - T - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Firstlayer - Secondlayer - Three-layers - - - - - - - K - - - - K - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PP - - - - K - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - T - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - T - - - - - - - - - - - - - - - - - - - - - - - - T - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - O - - - - K - O - - - O - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Thirdlayer - - - - - - - - - - +networkcommonsOne-layerTKPPOTwo-layersOKPPOTTTFirstlayerSecondlayerThree-layersKKPPKTTTOKOOThirdlayer \ No newline at end of file