Commit fa8ad6fb authored by Maria Marin's avatar Maria Marin

Upload New File

parent a1f06f03
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "50a451f7-1809-46d2-973e-74e901d97204",
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"import seaborn as sns\n",
"import matplotlib.pyplot as plt\n",
"import networkx as nx\n",
"from networkx.algorithms import bipartite\n",
"import nxpd\n",
"import funciones_reposicionamiento\n",
"import re"
]
},
{
"cell_type": "markdown",
"id": "422cca8f-611e-4e02-8fa5-e90641cb3fb2",
"metadata": {},
"source": [
"### Enfermedades estudiadas\n",
"\n",
"<div style=\"text-align: center;\">\n",
" \n",
"| Condition | Concept ID |\n",
"|------------------- |------------|\n",
"| Dementia | C0497327 |\n",
"| Bipolar Disorder | C0005586 |\n",
"| Epilepsy | C0014544 |\n",
"| Schizophrenia | C0036341 |\n",
"\n",
"</div>\n"
]
},
{
"cell_type": "markdown",
"id": "62ae066d-075e-45c9-a878-6b971f837d8a",
"metadata": {},
"source": [
"### Datos"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "ce71be78-0f8c-4f42-ae9e-e730de08e7fe",
"metadata": {},
"outputs": [],
"source": [
"#Cargo los archivos que contienen las matrices de SPL\n",
"spl_enf_dis_gen = pd.read_csv('Data/Matrices SPL/SPL enf en bipartita enf-gen.csv', sep=\",\")\n",
"spl_gen_dis_gen = pd.read_csv('Data/Matrices SPL/SPL genes en bipartita enf-gen.csv', sep=\",\")\n",
"spl_enf_dis_dru = pd.read_csv('Data/Matrices SPL/SPL enf en bipartita enf-dru.csv', sep=\",\")\n",
"spl_dru_dis_dru = pd.read_csv('Data/Matrices SPL/SPL fármacos en bipartita enf-dru.csv', sep=\",\")\n",
"spl_enf_dse_sym = pd.read_csv('Data/Matrices SPL/SPL enf en bipartita enf-sym.csv', sep=\",\")\n",
"spl_sym_dse_sym = pd.read_csv('Data/Matrices SPL/SPL síntomas en bipartita enf-sym.csv', sep=\",\")\n",
"spl_dis_gen_proj = pd.read_csv('Data/Matrices SPL/SPL enf en proyectada enf-gen.csv', sep=\",\")\n",
"spl_dis_dru_proj = pd.read_csv('Data/Matrices SPL/SPL enf en proyectada enf-dru.csv', sep=\",\")\n",
"spl_dse_sym_proj = pd.read_csv('Data/Matrices SPL/SPL enf en proyectada enf-sym.csv', sep=\",\")"
]
},
{
"cell_type": "markdown",
"id": "041b026c-bd1b-495d-89c1-2887a43995f5",
"metadata": {},
"source": [
"### Fármacos candidatos"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4681667a-28e9-45f2-8792-22280a657c8c",
"metadata": {},
"outputs": [],
"source": [
"#cargo el archivo obtenido en la celda anterior\n",
"resultados_proximidad_targets = pd.read_csv('Resultados proximidad y targets en módulo.csv', sep=\",\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5b55709c-6c2b-4225-a0e6-d46c5c29a876",
"metadata": {},
"outputs": [],
"source": [
"candidatos_dementia = funciones_reposicionamiento.farmacos_candidatos(resultados_proximidad_targets, \"Demencia\", dis_dru_the)\n",
"candidatos_bipolar = funciones_reposicionamiento.farmacos_candidatos(resultados_proximidad_targets, \"Bipolaridad\", dis_dru_the)\n",
"candidatos_epilepsy = funciones_reposicionamiento.farmacos_candidatos(resultados_proximidad_targets, \"Epilepsia\", dis_dru_the)\n",
"candidatos_schizo = funciones_reposicionamiento.farmacos_candidatos(resultados_proximidad_targets, \"Esquizofrenia\", dis_dru_the)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "222c2ca3-3711-47b2-a1ec-5d72f7dcd652",
"metadata": {},
"outputs": [],
"source": [
"enfermedades = ['Demencia', 'Bipolaridad', 'Epilepsia', 'Esquizofrenia']\n",
"\n",
"df_resultados_candidatos = pd.DataFrame()\n",
"\n",
"# Itero sobre las cuatro enfermedades\n",
"for enfermedad in enfermedades:\n",
" # Utilizo la función farmacos_candidatos para cada enfermedad neurológica y concateno los resultados\n",
" resultados_enfermedad = funciones_reposicionamiento.farmacos_candidatos(resultados_proximidad_targets, enfermedad, dis_dru_the)\n",
" df_resultados_candidatos = pd.concat([df_resultados_candidatos, resultados_enfermedad], ignore_index=True)\n",
"\n",
"df_resultados_candidatos.to_csv(\"Fármacos y enfermedades candidatos de reposicionamiento.csv\", index = False)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "fb9495ea-efcc-42c0-97f2-e24d0e231ef1",
"metadata": {},
"outputs": [],
"source": [
"#cargo el archivo de fármacos candidatos de reposicionamiento\n",
"candidatos = pd.read_csv('Fármacos y enfermedades candidatos de reposicionamiento.csv', sep=\",\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "77745258-518c-4642-8b5a-a825b1750390",
"metadata": {},
"outputs": [],
"source": [
"#calculo los SPLs en las tres redes proyectadas entre las enfermedades neurológicas estudiadas y las enfermedades tratadas por los\n",
"#fármacos candidatos de reposicionamiento.\n",
"id_enfermedades = {\n",
" 'Demencia': \"C0497327\",\n",
" 'Bipolaridad': \"C0005586\",\n",
" 'Epilepsia': \"C0014544\",\n",
" 'Esquizofrenia': \"C0036341\"\n",
"}\n",
"\n",
"spls_files = [spl_dis_gen_proj, spl_dis_dru_proj, spl_dse_sym_proj]\n",
"\n",
"spls_enfermedades_candidatas = funciones_reposicionamiento.spl_candidatos(spls_files, id_enfermedades, candidatos)\n",
"spls_enfermedades_candidatas.to_csv(\"SPLs enfermedades candidatas de reposicionamiento.csv\", index = False)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "ad63dea1-2fb0-414d-b461-a40d728154b4",
"metadata": {},
"outputs": [],
"source": [
"#cargo el archivo con los resultados de la celda anterior\n",
"spls_enfermedades_candidatas = pd.read_csv(\"SPLs enfermedades candidatas de reposicionamiento.csv\", sep=\",\")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "19977544-f4b8-4401-9d16-02e4c65a3e64",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Fármacos candidatos Demencia</th>\n",
" <th>Total enfermedades tratadas</th>\n",
" <th>Enfermedades en red proyectada enf-genes</th>\n",
" <th>Enfermedades en red proyectada enf-dru</th>\n",
" <th>Enfermedades en red proyectada enf-sym</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>CHEMBL118</td>\n",
" <td>138</td>\n",
" <td>136</td>\n",
" <td>138</td>\n",
" <td>116</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>CHEMBL606</td>\n",
" <td>33</td>\n",
" <td>33</td>\n",
" <td>33</td>\n",
" <td>27</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>CHEMBL1983350</td>\n",
" <td>25</td>\n",
" <td>25</td>\n",
" <td>25</td>\n",
" <td>22</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>CHEMBL254219</td>\n",
" <td>22</td>\n",
" <td>22</td>\n",
" <td>22</td>\n",
" <td>18</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>CHEMBL222863</td>\n",
" <td>9</td>\n",
" <td>9</td>\n",
" <td>9</td>\n",
" <td>6</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Fármacos candidatos Demencia Total enfermedades tratadas \\\n",
"2 CHEMBL118 138 \n",
"1 CHEMBL606 33 \n",
"3 CHEMBL1983350 25 \n",
"4 CHEMBL254219 22 \n",
"0 CHEMBL222863 9 \n",
"\n",
" Enfermedades en red proyectada enf-genes \\\n",
"2 136 \n",
"1 33 \n",
"3 25 \n",
"4 22 \n",
"0 9 \n",
"\n",
" Enfermedades en red proyectada enf-dru \\\n",
"2 138 \n",
"1 33 \n",
"3 25 \n",
"4 22 \n",
"0 9 \n",
"\n",
" Enfermedades en red proyectada enf-sym \n",
"2 116 \n",
"1 27 \n",
"3 22 \n",
"4 18 \n",
"0 6 "
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#calculo la cantidad de enfermedades tratadas por fármacos candidatos de reposcinamiento en cada una de las redes proyectadas.\n",
"enf_candidatas_dementia = funciones_reposicionamiento.distribucion_enf_candidatas(spls_enfermedades_candidatas, \"Demencia\")\n",
"enf_candidatas_dementia.sort_values(by=\"Total enfermedades tratadas\", ascending=False).head()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "a793cc37-4ab0-4a14-af35-4d0d7426e38f",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Fármacos candidatos Bipolaridad</th>\n",
" <th>Total enfermedades tratadas</th>\n",
" <th>Enfermedades en red proyectada enf-genes</th>\n",
" <th>Enfermedades en red proyectada enf-dru</th>\n",
" <th>Enfermedades en red proyectada enf-sym</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>CHEMBL53463</td>\n",
" <td>198</td>\n",
" <td>197</td>\n",
" <td>198</td>\n",
" <td>164</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>CHEMBL452231</td>\n",
" <td>37</td>\n",
" <td>37</td>\n",
" <td>37</td>\n",
" <td>31</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>CHEMBL1184</td>\n",
" <td>33</td>\n",
" <td>33</td>\n",
" <td>33</td>\n",
" <td>21</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>CHEMBL1201544</td>\n",
" <td>12</td>\n",
" <td>10</td>\n",
" <td>12</td>\n",
" <td>10</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>CHEMBL1465</td>\n",
" <td>7</td>\n",
" <td>7</td>\n",
" <td>7</td>\n",
" <td>6</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Fármacos candidatos Bipolaridad Total enfermedades tratadas \\\n",
"0 CHEMBL53463 198 \n",
"1 CHEMBL452231 37 \n",
"2 CHEMBL1184 33 \n",
"4 CHEMBL1201544 12 \n",
"3 CHEMBL1465 7 \n",
"\n",
" Enfermedades en red proyectada enf-genes \\\n",
"0 197 \n",
"1 37 \n",
"2 33 \n",
"4 10 \n",
"3 7 \n",
"\n",
" Enfermedades en red proyectada enf-dru \\\n",
"0 198 \n",
"1 37 \n",
"2 33 \n",
"4 12 \n",
"3 7 \n",
"\n",
" Enfermedades en red proyectada enf-sym \n",
"0 164 \n",
"1 31 \n",
"2 21 \n",
"4 10 \n",
"3 6 "
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"enf_candidatas_bipolar = funciones_reposicionamiento.distribucion_enf_candidatas(spls_enfermedades_candidatas, \"Bipolaridad\")\n",
"enf_candidatas_bipolar.sort_values(by=\"Total enfermedades tratadas\", ascending=False).head()"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "247f0db4-3993-4e1b-9c42-0369d814e5c0",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Fármacos candidatos Epilepsia</th>\n",
" <th>Total enfermedades tratadas</th>\n",
" <th>Enfermedades en red proyectada enf-genes</th>\n",
" <th>Enfermedades en red proyectada enf-dru</th>\n",
" <th>Enfermedades en red proyectada enf-sym</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>CHEMBL548</td>\n",
" <td>38</td>\n",
" <td>38</td>\n",
" <td>38</td>\n",
" <td>30</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>CHEMBL957</td>\n",
" <td>30</td>\n",
" <td>30</td>\n",
" <td>30</td>\n",
" <td>23</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>CHEMBL1762</td>\n",
" <td>19</td>\n",
" <td>19</td>\n",
" <td>19</td>\n",
" <td>13</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>CHEMBL334966</td>\n",
" <td>7</td>\n",
" <td>7</td>\n",
" <td>7</td>\n",
" <td>7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>CHEMBL1200810</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Fármacos candidatos Epilepsia Total enfermedades tratadas \\\n",
"4 CHEMBL548 38 \n",
"2 CHEMBL957 30 \n",
"3 CHEMBL1762 19 \n",
"1 CHEMBL334966 7 \n",
"0 CHEMBL1200810 3 \n",
"\n",
" Enfermedades en red proyectada enf-genes \\\n",
"4 38 \n",
"2 30 \n",
"3 19 \n",
"1 7 \n",
"0 3 \n",
"\n",
" Enfermedades en red proyectada enf-dru \\\n",
"4 38 \n",
"2 30 \n",
"3 19 \n",
"1 7 \n",
"0 3 \n",
"\n",
" Enfermedades en red proyectada enf-sym \n",
"4 30 \n",
"2 23 \n",
"3 13 \n",
"1 7 \n",
"0 3 "
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"enf_candidatas_epilepsy = funciones_reposicionamiento.distribucion_enf_candidatas(spls_enfermedades_candidatas, \"Epilepsia\")\n",
"enf_candidatas_epilepsy.sort_values(by=\"Total enfermedades tratadas\", ascending=False).head()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "03517b87-5069-41b1-95a3-d71ada80ce47",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Fármacos candidatos Esquizofrenia</th>\n",
" <th>Total enfermedades tratadas</th>\n",
" <th>Enfermedades en red proyectada enf-genes</th>\n",
" <th>Enfermedades en red proyectada enf-dru</th>\n",
" <th>Enfermedades en red proyectada enf-sym</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>CHEMBL1069</td>\n",
" <td>65</td>\n",
" <td>64</td>\n",
" <td>65</td>\n",
" <td>41</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>CHEMBL1234886</td>\n",
" <td>46</td>\n",
" <td>43</td>\n",
" <td>46</td>\n",
" <td>34</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>CHEMBL1743082</td>\n",
" <td>7</td>\n",
" <td>7</td>\n",
" <td>7</td>\n",
" <td>7</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>CHEMBL861</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>CHEMBL1201237</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" <td>4</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Fármacos candidatos Esquizofrenia Total enfermedades tratadas \\\n",
"0 CHEMBL1069 65 \n",
"1 CHEMBL1234886 46 \n",
"2 CHEMBL1743082 7 \n",
"3 CHEMBL861 4 \n",
"4 CHEMBL1201237 4 \n",
"\n",
" Enfermedades en red proyectada enf-genes \\\n",
"0 64 \n",
"1 43 \n",
"2 7 \n",
"3 4 \n",
"4 4 \n",
"\n",
" Enfermedades en red proyectada enf-dru \\\n",
"0 65 \n",
"1 46 \n",
"2 7 \n",
"3 4 \n",
"4 4 \n",
"\n",
" Enfermedades en red proyectada enf-sym \n",
"0 41 \n",
"1 34 \n",
"2 7 \n",
"3 4 \n",
"4 4 "
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"enf_candidatas_schizo = funciones_reposicionamiento.distribucion_enf_candidatas(spls_enfermedades_candidatas, \"Esquizofrenia\")\n",
"enf_candidatas_schizo.sort_values(by=\"Total enfermedades tratadas\", ascending=False).head()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment