Skip to content

Commit

Permalink
Replaced slider with dropdown menu
Browse files Browse the repository at this point in the history
  • Loading branch information
wjm41 committed Feb 27, 2022
1 parent f4f3ed6 commit 1f9c8ac
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 274 deletions.
247 changes: 13 additions & 234 deletions example_multiple_columns.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -37,190 +37,9 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"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>Aryl_halide_SMILES</th>\n",
" <th>Additive_SMILES</th>\n",
" <th>Base_SMILES</th>\n",
" <th>Ligand_SMILES</th>\n",
" <th>yield</th>\n",
" </tr>\n",
" <tr>\n",
" <th>entry</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>49</th>\n",
" <td>FC(F)(F)c1ccc(Cl)cc1</td>\n",
" <td>o1nccc1c2ccccc2</td>\n",
" <td>CN(C)P(N(C)C)(N(C)C)=NP(N(C)C)(N(C)C)=NCC</td>\n",
" <td>CC(C)C1=CC(C(C)C)=CC(C(C)C)=C1C2=C(P(C3CCCCC3)...</td>\n",
" <td>10.657812</td>\n",
" </tr>\n",
" <tr>\n",
" <th>50</th>\n",
" <td>FC(F)(F)c1ccc(Br)cc1</td>\n",
" <td>o1nccc1c2ccccc2</td>\n",
" <td>CN(C)P(N(C)C)(N(C)C)=NP(N(C)C)(N(C)C)=NCC</td>\n",
" <td>CC(C)C1=CC(C(C)C)=CC(C(C)C)=C1C2=C(P(C3CCCCC3)...</td>\n",
" <td>14.747896</td>\n",
" </tr>\n",
" <tr>\n",
" <th>51</th>\n",
" <td>FC(F)(F)c1ccc(I)cc1</td>\n",
" <td>o1nccc1c2ccccc2</td>\n",
" <td>CN(C)P(N(C)C)(N(C)C)=NP(N(C)C)(N(C)C)=NCC</td>\n",
" <td>CC(C)C1=CC(C(C)C)=CC(C(C)C)=C1C2=C(P(C3CCCCC3)...</td>\n",
" <td>18.278686</td>\n",
" </tr>\n",
" <tr>\n",
" <th>52</th>\n",
" <td>COc1ccc(Cl)cc1</td>\n",
" <td>o1nccc1c2ccccc2</td>\n",
" <td>CN(C)P(N(C)C)(N(C)C)=NP(N(C)C)(N(C)C)=NCC</td>\n",
" <td>CC(C)C1=CC(C(C)C)=CC(C(C)C)=C1C2=C(P(C3CCCCC3)...</td>\n",
" <td>2.475058</td>\n",
" </tr>\n",
" <tr>\n",
" <th>53</th>\n",
" <td>COc1ccc(Br)cc1</td>\n",
" <td>o1nccc1c2ccccc2</td>\n",
" <td>CN(C)P(N(C)C)(N(C)C)=NP(N(C)C)(N(C)C)=NCC</td>\n",
" <td>CC(C)C1=CC(C(C)C)=CC(C(C)C)=C1C2=C(P(C3CCCCC3)...</td>\n",
" <td>6.119058</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4603</th>\n",
" <td>Brc1ccccn1</td>\n",
" <td>COC(=O)c1cc(on1)c2sccc2</td>\n",
" <td>CN1CCCN2CCCN=C12</td>\n",
" <td>CC(C1=C(C2=C(OC)C=CC(OC)=C2P(C34CC5CC(C4)CC(C5...</td>\n",
" <td>57.426670</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4604</th>\n",
" <td>Ic1ccccn1</td>\n",
" <td>COC(=O)c1cc(on1)c2sccc2</td>\n",
" <td>CN1CCCN2CCCN=C12</td>\n",
" <td>CC(C1=C(C2=C(OC)C=CC(OC)=C2P(C34CC5CC(C4)CC(C5...</td>\n",
" <td>86.233157</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4605</th>\n",
" <td>Clc1cccnc1</td>\n",
" <td>COC(=O)c1cc(on1)c2sccc2</td>\n",
" <td>CN1CCCN2CCCN=C12</td>\n",
" <td>CC(C1=C(C2=C(OC)C=CC(OC)=C2P(C34CC5CC(C4)CC(C5...</td>\n",
" <td>1.440081</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4606</th>\n",
" <td>Brc1cccnc1</td>\n",
" <td>COC(=O)c1cc(on1)c2sccc2</td>\n",
" <td>CN1CCCN2CCCN=C12</td>\n",
" <td>CC(C1=C(C2=C(OC)C=CC(OC)=C2P(C34CC5CC(C4)CC(C5...</td>\n",
" <td>43.538365</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4607</th>\n",
" <td>Ic1cccnc1</td>\n",
" <td>COC(=O)c1cc(on1)c2sccc2</td>\n",
" <td>CN1CCCN2CCCN=C12</td>\n",
" <td>CC(C1=C(C2=C(OC)C=CC(OC)=C2P(C34CC5CC(C4)CC(C5...</td>\n",
" <td>69.795902</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>3955 rows × 5 columns</p>\n",
"</div>"
],
"text/plain": [
" Aryl_halide_SMILES Additive_SMILES \\\n",
"entry \n",
"49 FC(F)(F)c1ccc(Cl)cc1 o1nccc1c2ccccc2 \n",
"50 FC(F)(F)c1ccc(Br)cc1 o1nccc1c2ccccc2 \n",
"51 FC(F)(F)c1ccc(I)cc1 o1nccc1c2ccccc2 \n",
"52 COc1ccc(Cl)cc1 o1nccc1c2ccccc2 \n",
"53 COc1ccc(Br)cc1 o1nccc1c2ccccc2 \n",
"... ... ... \n",
"4603 Brc1ccccn1 COC(=O)c1cc(on1)c2sccc2 \n",
"4604 Ic1ccccn1 COC(=O)c1cc(on1)c2sccc2 \n",
"4605 Clc1cccnc1 COC(=O)c1cc(on1)c2sccc2 \n",
"4606 Brc1cccnc1 COC(=O)c1cc(on1)c2sccc2 \n",
"4607 Ic1cccnc1 COC(=O)c1cc(on1)c2sccc2 \n",
"\n",
" Base_SMILES \\\n",
"entry \n",
"49 CN(C)P(N(C)C)(N(C)C)=NP(N(C)C)(N(C)C)=NCC \n",
"50 CN(C)P(N(C)C)(N(C)C)=NP(N(C)C)(N(C)C)=NCC \n",
"51 CN(C)P(N(C)C)(N(C)C)=NP(N(C)C)(N(C)C)=NCC \n",
"52 CN(C)P(N(C)C)(N(C)C)=NP(N(C)C)(N(C)C)=NCC \n",
"53 CN(C)P(N(C)C)(N(C)C)=NP(N(C)C)(N(C)C)=NCC \n",
"... ... \n",
"4603 CN1CCCN2CCCN=C12 \n",
"4604 CN1CCCN2CCCN=C12 \n",
"4605 CN1CCCN2CCCN=C12 \n",
"4606 CN1CCCN2CCCN=C12 \n",
"4607 CN1CCCN2CCCN=C12 \n",
"\n",
" Ligand_SMILES yield \n",
"entry \n",
"49 CC(C)C1=CC(C(C)C)=CC(C(C)C)=C1C2=C(P(C3CCCCC3)... 10.657812 \n",
"50 CC(C)C1=CC(C(C)C)=CC(C(C)C)=C1C2=C(P(C3CCCCC3)... 14.747896 \n",
"51 CC(C)C1=CC(C(C)C)=CC(C(C)C)=C1C2=C(P(C3CCCCC3)... 18.278686 \n",
"52 CC(C)C1=CC(C(C)C)=CC(C(C)C)=C1C2=C(P(C3CCCCC3)... 2.475058 \n",
"53 CC(C)C1=CC(C(C)C)=CC(C(C)C)=C1C2=C(P(C3CCCCC3)... 6.119058 \n",
"... ... ... \n",
"4603 CC(C1=C(C2=C(OC)C=CC(OC)=C2P(C34CC5CC(C4)CC(C5... 57.426670 \n",
"4604 CC(C1=C(C2=C(OC)C=CC(OC)=C2P(C34CC5CC(C4)CC(C5... 86.233157 \n",
"4605 CC(C1=C(C2=C(OC)C=CC(OC)=C2P(C34CC5CC(C4)CC(C5... 1.440081 \n",
"4606 CC(C1=C(C2=C(OC)C=CC(OC)=C2P(C34CC5CC(C4)CC(C5... 43.538365 \n",
"4607 CC(C1=C(C2=C(OC)C=CC(OC)=C2P(C34CC5CC(C4)CC(C5... 69.795902 \n",
"\n",
"[3955 rows x 5 columns]"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"df = pd.read_csv('https://raw.githubusercontent.com/b-shields/edbo/master/experiments/data/aryl_amination/experiment_index.csv',\n",
" index_col=0)\n",
Expand All @@ -236,7 +55,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -287,7 +106,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -303,7 +122,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -319,28 +138,17 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"RandomForestRegressor()"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"model = RandomForestRegressor()\n",
"model.fit(X_train, Y_train)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -352,36 +160,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we can use molplotly to see all the components corresponding to each point in the scatter plot!"
"Now we can use molplotly to see all the components corresponding to each point in the scatter plot! Select the SMILES columns you'd like to plot by choosing from the dropdown menu :)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <iframe\n",
" width=\"100%\"\n",
" height=\"1000\"\n",
" src=\"http://127.0.0.1:8751/\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x25ea7779cd0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"fig_scatter = px.scatter(df_test,\n",
" x=\"yield\",\n",
Expand All @@ -400,13 +186,6 @@
"# change the arguments here to run the dash app on an external server and/or change the size of the app!\n",
"app_scatter.run_server(mode='inline', port=8751, height=1000)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now changing the slider value changes which column is used for displaying the structure of the molecule."
]
}
],
"metadata": {
Expand All @@ -428,7 +207,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.10.0"
},
"orig_nbformat": 4
},
Expand Down
Loading

0 comments on commit 1f9c8ac

Please sign in to comment.