Skip to content

Commit

Permalink
tsne split into multiple code cells
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulaKramer committed Jan 28, 2025
1 parent 08064e2 commit faf2594
Showing 1 changed file with 41 additions and 9 deletions.
50 changes: 41 additions & 9 deletions notebooks/custom_kinfraglib/2_2_custom_filters_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1900,24 +1900,56 @@
" fragment_library_concat = pd.concat(fragment_library).reset_index(drop=True)\n",
"fragment_library_concat[\"maccs\"] = fragment_library_concat.ROMol.apply(\n",
" MACCSkeys.GenMACCSKeys\n",
")\n",
"\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e22eeca4",
"metadata": {},
"outputs": [],
"source": [
"pca = PCA(n_components=50)\n",
"crds = pca.fit_transform(list(fragment_library_concat[\"maccs\"]))\n",
"\n",
"crds = pca.fit_transform(list(fragment_library_concat[\"maccs\"]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "17fc249a",
"metadata": {},
"outputs": [],
"source": [
"crds_embedded = TSNE(\n",
" n_components=2, init=\"pca\", learning_rate=\"auto\"\n",
").fit_transform(crds)\n",
"\n",
").fit_transform(crds)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2bbe496c",
"metadata": {},
"outputs": [],
"source": [
"tsne_df = pd.DataFrame(crds_embedded, columns=[\"X\", \"Y\"])\n",
"# add bool column from filter steps\n",
"filters = []\n",
"if \"bool_pains\" in saved_filter_results.columns:\n",
" tsne_df[\"pains\"] = saved_filter_results[\"bool_pains\"]\n",
" filters.append(\"pains\")\n",
"\n",
"tsne_df[\"smiles\"] = saved_filter_results[\"smiles\"]\n",
"\n",
"tsne_df[\"smiles\"] = saved_filter_results[\"smiles\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "31a37fc6",
"metadata": {},
"outputs": [],
"source": [
"# create the plots for all filters\n",
"# plt.figure(figsize=(15, 21))\n",
"i = 0\n",
Expand All @@ -1939,7 +1971,7 @@
" color=\"lightcoral\",\n",
" label=\"rejected\",\n",
" )\n",
" plt.show()\n"
" plt.show()"
]
},
{
Expand Down

0 comments on commit faf2594

Please sign in to comment.