File size: 5,966 Bytes
032c0ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [],
   "source": [
    "from datasets import load_dataset\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [],
   "source": [
    "# import json\n",
    "# import os\n",
    "\n",
    "# # Read in the organ to conditions mapping JSON file\n",
    "# with open(\"clin-oracle-tahoe-hack-2025/data/organ_to_conditions_mapping.json\", \"r\") as f:\n",
    "#     organ_to_conditions = json.load(f)\n",
    "    \n",
    "# # Display basic information about the mapping\n",
    "# print(f\"Loaded organ to conditions mapping with {len(organ_to_conditions)} organs\")\n",
    "# print(f\"Sample organ: {list(organ_to_conditions.keys())[0]}\")\n",
    "# print(f\"Sample conditions: {organ_to_conditions[list(organ_to_conditions.keys())[0]][:3]}...\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [],
   "source": [
    "drug_metadata = pd.DataFrame(load_dataset(\"tahoebio/Tahoe-100M\",\"drug_metadata\", split=\"train\"))\n",
    "drug_metadata = drug_metadata.loc[drug_metadata[\"targets\"].notna()]\n",
    "target_to_drug = dict(zip(drug_metadata[\"targets\"], drug_metadata[\"drug\"]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.read_csv(\"/home/ubuntu/tahoe/clin-oracle-tahoe-hack-2025/indication_to_organ_mapping_confident.tsv\", sep='\\t')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [],
   "source": [
    "indic = pd.read_csv(\"genetic_support/data/indic.tsv\", sep='\\t')\n",
    "assoc = pd.read_csv(\"genetic_support/data/assoc.tsv.gz\", sep='\\t')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [],
   "source": [
    "assoc = assoc.merge(df, left_on=\"mesh_term\", right_on=\"indication_mesh_term\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "189"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(target_to_drug)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [],
   "source": [
    "assoc[\"drug\"] = assoc[\"gene\"].map(target_to_drug)\n",
    "assoc[\"drug_organ\"] = assoc[\"drug\"] + \"_\" + assoc[\"organ\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [],
   "source": [
    "assoc = assoc.loc[assoc[\"drug_organ\"].notna()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "assoc[[\"drug_organ\",]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "arow                                                                 3885\n",
       "gene                                                                 ABL1\n",
       "mesh_id                                                           D014012\n",
       "source                                                                OTG\n",
       "original_trait          Tinnitus / tiniitis | non-cancer illness code,...\n",
       "original_link           https://genetics.opentargets.org/study/NEALE2_...\n",
       "extra_info                                                            NaN\n",
       "l2g_rank                                                              4.0\n",
       "l2g_share                                                            0.12\n",
       "pval                                                                  0.0\n",
       "year                                                               2018.0\n",
       "beta                                                                  NaN\n",
       "odds_ratio                                                       4.072184\n",
       "pic_qtl_pval                                                          NaN\n",
       "pic_h4                                                                NaN\n",
       "af_gnomad_nfe                                                     0.02489\n",
       "mesh_term                                                        Tinnitus\n",
       "indication_mesh_term                                             Tinnitus\n",
       "organ                                                           CNS/Brain\n",
       "drug                                                Flumatinib (mesylate)\n",
       "drug_organ                                Flumatinib (mesylate)_CNS/Brain\n",
       "Name: 234, dtype: object"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "assoc.iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [],
   "source": [
    "assoc[\"is_associated_with_indication\"] = 1\n",
    "assoc[[\"drug_organ\",\"is_associated_with_indication\"]].to_csv(\"/home/ubuntu/tahoe/clin-oracle-tahoe-hack-2025/data_for_classifier/assoc_drug_organ_label.tsv\", sep='\\t', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.12.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}