repurposing.ipynb 9.63 KB
Newer Older
Maria Marin's avatar
Maria Marin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "b987b5e5-3a96-46dc-ad64-08edeb477a6c",
   "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 tabulate import tabulate\n",
    "from networkx.algorithms import bipartite\n",
    "import random\n",
    "from scipy.stats import norm\n",
    "from itertools import combinations\n",
    "import re\n",
    "from itertools import product\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fe4b1e17-fa87-42d9-a28d-e53aebb77943",
   "metadata": {},
   "source": [
    "### Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "c5bf61fe-29af-40b6-a85e-f5453c2b4b30",
   "metadata": {},
   "outputs": [],
   "source": [
    "proximity = pd.read_csv(\"../results/Proximity_results.csv\", sep = \",\")\n",
    "dge = pd.read_csv(\"../results/Filtering_by_DGE_results.csv\", sep = \",\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9a70afe4-73a7-4436-a8d9-14deba773032",
   "metadata": {},
   "source": [
    "### Filtering of drug repurposing candidates"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "06d790a3-6c11-4724-9ed3-0c764083243f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# filtering of schizophrenia data\n",
    "proximity_schizo = proximity[proximity[\"ID\"] == \"C0036341\"]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "07ae6a91-08a8-4bab-97c2-b47070875c48",
   "metadata": {},
   "source": [
    "#### 1) Proximal drugs to schizophrenia module"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "493872db-4d45-4ca6-a613-d0adafacd5c7",
   "metadata": {},
   "outputs": [],
   "source": [
    "proximal_drugs_schizo = proximity_schizo[(proximity_schizo[\"Dc_zscore\"] <= -0.15) & \n",
    "                                        (proximity_schizo[\"Treatment\"] == \"unknown\")]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4e3e28c3-f78d-4d20-9745-3d28dad6838a",
   "metadata": {},
   "source": [
    "#### 2) Distance to schizophrenia module"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "1f33226f-a0b8-4d76-be20-f82ca3851d6e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Q1 and median of closest distance for treatment drugs\n",
    "\n",
    "treatment_schizo = proximity_schizo[proximity_schizo[\"Treatment\"] == \"yes\"]\n",
    "Q1_treatment = treatment_schizo[\"Closest distance\"].quantile(0.25)\n",
    "median_treatment = treatment_schizo[\"Closest distance\"].quantile(0.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "79a8a797-2089-4c60-bcb3-690de1bdbec6",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Unknown drugs with distance to schizophrenia module between Q1 and nedian of treatment drugs\n",
    "\n",
    "closest_drugs_schizo = proximal_drugs_schizo[(proximal_drugs_schizo[\"Closest distance\"] >= Q1_treatment) &\n",
    "                                       (proximal_drugs_schizo[\"Closest distance\"] <= median_treatment)]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d6f6a702-06ee-4d94-8982-1ff4659b8dbc",
   "metadata": {},
   "source": [
    "#### 3) Targets with significant DGE in schizophrenia and correlated with its co-expression module"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "0665674b-9fbd-4855-9785-7a93b1907540",
   "metadata": {},
   "outputs": [],
   "source": [
    "drugs_in_dge = dge[\"Drugs\"].unique()\n",
    "drugs_schizo_filtered =  closest_drugs_schizo[(closest_drugs_schizo[\"Drugs\"].isin(drugs_in_dge))]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "418c6fb7-4a32-407e-bb35-9c13804d1dbf",
   "metadata": {},
   "outputs": [],
   "source": [
    "proximity_schizo_filtered = drugs_schizo_filtered.sort_values(by=\"Dc_zscore\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "c6dbe376-fca9-43c1-9c76-cad14964f703",
   "metadata": {},
   "outputs": [],
   "source": [
    "proximity_schizo_filtered = proximity_schizo_filtered.drop('ID', axis=1).drop('Treatment', axis=1).drop('Dc_std', axis=1).drop('Dc_mean', axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "05f3dce7-b0ea-4ce3-b06a-52c52f3bb7a7",
   "metadata": {},
   "outputs": [],
   "source": [
    "proximity_schizo_filtered.to_csv(\"../results/Repurposing candidates schizophrenia.csv\", index = False)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "12a5a03c-76c7-4817-a596-2e89724302d4",
   "metadata": {},
   "source": [
    "### MeSH Pharmacological Actions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "73e12501-9ea1-4d08-a87a-88a30036d1d8",
   "metadata": {},
   "outputs": [],
   "source": [
    "categories = pd.read_csv(\"../files/drug_categories.csv\", sep = \",\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2b7c78db-7596-4759-a5e1-50d9e121abb4",
   "metadata": {},
   "outputs": [],
   "source": [
    "merged_drugs = pd.merge(proximity_schizo_filtered, dge[['Drugs', 'Gene symbol']], on='Drugs')\n",
    "merged_drugs = pd.merge(merged_drugs, categories[['drug_id', 'class_name', 'type']], left_on='Drugs', right_on='drug_id')\n",
    "\n",
    "drugs_classification = merged_drugs[merged_drugs['class_name'].str.contains('Agents')]\n",
    "\n",
    "drugs_classification = drugs_classification[['Drugs', 'Closest distance', 'Dc_zscore', 'Gene symbol', 'class_name', 'type']]\n",
    "drugs_classification.columns = ['Drugs', 'Closest distance', 'Proximity', 'Gene target', 'Classification', 'Type']\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "21abf2e1-c9df-47ab-86a7-0bcf5523b0ba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "            Drugs  Closest distance   Proximity Gene target  \\\n",
      "1       CHEMBL623          0.300000 -115.579629       KCNH2   \n",
      "8       CHEMBL113          0.363636 -103.512846      PIK3CB   \n",
      "11      CHEMBL113          0.363636 -103.512846      PIK3CB   \n",
      "15      CHEMBL941          0.500000  -94.879347        DDR1   \n",
      "20  CHEMBL1628227          0.352941  -90.844253       KCNH2   \n",
      "28       CHEMBL83          0.428571  -85.950381       KCNH2   \n",
      "30       CHEMBL83          0.428571  -85.950381       KCNH2   \n",
      "34    CHEMBL23588          0.500000  -77.736571       PPARA   \n",
      "35      CHEMBL640          0.333333  -75.756252       KCNH2   \n",
      "39      CHEMBL709          0.500000  -74.365765       KCNH2   \n",
      "43   CHEMBL278819          0.333333  -65.014945        MAOA   \n",
      "44      CHEMBL652          0.500000  -51.717537       KCNH2   \n",
      "47      CHEMBL413          0.333333  -22.765103        FGF2   \n",
      "49      CHEMBL413          0.333333  -22.765103        FGF2   \n",
      "50      CHEMBL413          0.333333  -22.765103        FGF2   \n",
      "53       CHEMBL43          0.500000   -8.866920       KCNH2   \n",
      "\n",
      "                              Classification    Type  \n",
      "1   Antidepressive Agents, Second-Generation  MESHPA  \n",
      "8    Anti-Inflammatory Agents, Non-Steroidal  MESHPA  \n",
      "11                      Antimutagenic Agents  MESHPA  \n",
      "15                     Antineoplastic Agents  MESHPA  \n",
      "20          Antidepressive Agents, Tricyclic  MESHPA  \n",
      "28           Antineoplastic Agents, Hormonal  MESHPA  \n",
      "30          Bone Density Conservation Agents  MESHPA  \n",
      "34                  Anti-Inflammatory Agents  MESHPA  \n",
      "35                    Anti-Arrhythmia Agents  MESHPA  \n",
      "39                         Urological Agents  MESHPA  \n",
      "43                     Antidepressive Agents  MESHPA  \n",
      "44                    Anti-Arrhythmia Agents  MESHPA  \n",
      "47                     Anti-Bacterial Agents  MESHPA  \n",
      "49                         Antifungal Agents  MESHPA  \n",
      "50                  Immunosuppressive Agents  MESHPA  \n",
      "53                     Antineoplastic Agents  MESHPA  \n"
     ]
    }
   ],
   "source": [
    "merged_drugs = pd.merge(proximity_schizo_filtered, dge[['Drugs', 'Gene symbol']], on='Drugs')\n",
    "merged_drugs = pd.merge(merged_drugs, categories[['drug_id', 'class_name', 'type']], left_on='Drugs', right_on='drug_id')\n",
    "\n",
    "drugs_classification = merged_drugs[merged_drugs['class_name'].str.contains('Agents')]\n",
    "\n",
    "drugs_classification = drugs_classification[['Drugs', 'Closest distance', 'Dc_zscore', 'Gene symbol', 'class_name', 'type']]\n",
    "drugs_classification.columns = ['Drugs', 'Closest distance', 'Proximity', 'Gene target', 'Classification', 'Type']\n",
    "\n",
    "\n",
    "print(drugs_classification)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "447d822e-7e21-45fa-993e-53659fda6fc5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e3898d83-c1ed-4c95-88d5-eca1ae6debe6",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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
}