Skip to content

Commit

Permalink
Refactor all notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
amorehead committed Aug 16, 2024
1 parent 8441706 commit 44eb053
Show file tree
Hide file tree
Showing 12 changed files with 314 additions and 1,021 deletions.
51 changes: 28 additions & 23 deletions notebooks/casp15_inference_results_plotting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@
"outputs": [],
"source": [
"# General variables\n",
"new_methods = [\n",
"baseline_methods = [\n",
" \"diffdock\",\n",
" \"dynamicbind\",\n",
" \"neuralplexer\",\n",
" \"rfaa\",\n",
" \"tulip\",\n",
" \"vina_diffdock\",\n",
" \"vina_p2rank\",\n",
" \"consensus_ensemble\",\n",
"]\n",
"max_num_repeats_per_method = 3\n",
Expand All @@ -87,6 +88,7 @@
" \"rfaa\": \"RoseTTAFold-All-Atom\",\n",
" \"tulip\": \"TULIP\",\n",
" \"vina_diffdock\": \"DiffDock-L-Vina\",\n",
" \"vina_p2rank\": \"P2Rank-Vina\",\n",
" \"consensus_ensemble\": \"Ensemble (Con)\",\n",
"}\n",
"\n",
Expand All @@ -97,6 +99,7 @@
" \"rfaa\": \"DL-based blind\",\n",
" \"tulip\": \"Conventional blind\",\n",
" \"vina_diffdock\": \"Conventional blind\",\n",
" \"vina_p2rank\": \"Conventional blind\",\n",
" \"consensus_ensemble\": \"Hybrid blind\",\n",
"}"
]
Expand All @@ -105,7 +108,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Report test results for new methods"
"#### Report test results for each baseline method"
]
},
{
Expand All @@ -114,9 +117,9 @@
"metadata": {},
"outputs": [],
"source": [
"# load and report test results for each new method\n",
"# load and report test results for each baseline method\n",
"for config in [\"\", \"_relaxed\"]:\n",
" for method in new_methods:\n",
" for method in baseline_methods:\n",
" for repeat_index in range(1, max_num_repeats_per_method + 1):\n",
" method_title = method_mapping[method]\n",
"\n",
Expand All @@ -127,11 +130,11 @@
" \"casp15\",\n",
" f\"top_{method}{'' if 'ensemble' in method else '_ensemble'}_predictions_{repeat_index}\",\n",
" )\n",
" globals()[f\"{method}{config}_scoring_results_csv_filepath_{repeat_index}\"] = (\n",
" os.path.join(\n",
" globals()[f\"{method}_output_dir_{repeat_index}\"] + config,\n",
" \"scoring_results.csv\",\n",
" )\n",
" globals()[\n",
" f\"{method}{config}_scoring_results_csv_filepath_{repeat_index}\"\n",
" ] = os.path.join(\n",
" globals()[f\"{method}_output_dir_{repeat_index}\"] + config,\n",
" \"scoring_results.csv\",\n",
" )\n",
" globals()[f\"{method}{config}_bust_results_csv_filepath_{repeat_index}\"] = os.path.join(\n",
" globals()[f\"{method}_output_dir_{repeat_index}\"] + config,\n",
Expand Down Expand Up @@ -292,7 +295,7 @@
" globals()[f\"scoring_results_table_{repeat_index}\"] = pd.concat(\n",
" [\n",
" globals()[f\"{method}{config}_scoring_results_table_{repeat_index}\"]\n",
" for method in new_methods\n",
" for method in baseline_methods\n",
" for config in [\"\", \"_relaxed\"]\n",
" if f\"{method}{config}_scoring_results_table_{repeat_index}\" in globals()\n",
" ]\n",
Expand Down Expand Up @@ -503,7 +506,7 @@
"colors = [\"#FB8072\", \"#BEBADA\"]\n",
"\n",
"bar_width = 0.75\n",
"r1 = [item - 0.25 for item in range(2, 16, 2)]\n",
"r1 = [item - 0.25 for item in range(2, 18, 2)]\n",
"r2 = [x + bar_width for x in r1]\n",
"\n",
"for complex_type in [\"single\", \"multi\"]:\n",
Expand Down Expand Up @@ -696,7 +699,7 @@
" # add labels, titles, ticks, etc.\n",
" axis.set_xlabel(f\"{complex_type.title()}-ligand blind docking ({complex_license})\")\n",
" axis.set_ylabel(\"Percentage of predictions\")\n",
" axis.set_xlim(1, 15 + 0.1)\n",
" axis.set_xlim(1, 17 + 0.1)\n",
" axis.set_ylim(0, 100)\n",
"\n",
" axis.bar_label(casp15_rmsd_lt2_bar, fmt=\"{:,.1f}%\", label_type=\"center\")\n",
Expand All @@ -709,18 +712,19 @@
" axis.grid(axis=\"y\", color=\"#EAEFF8\")\n",
" axis.set_axisbelow(True)\n",
"\n",
" axis.set_xticks([2, 4, 6, 6 + 1e-3, 8, 10, 11, 12, 14, 14 + 1e-3])\n",
" axis.set_xticks([2, 4, 5, 6, 8, 10, 12, 12 + 1e-3, 14, 16, 16 + 1e-3])\n",
" axis.set_xticks([1 + 0.1], minor=True)\n",
" axis.set_xticklabels(\n",
" [\n",
" \"DiffDock-L\",\n",
" \"DynamicBind\",\n",
" \"NeuralPLexer\",\n",
" \"DL-based blind\",\n",
" \"NeuralPLexer\",\n",
" \"RoseTTAFold-All-Atom\",\n",
" \"TULIP\",\n",
" \"Conventional blind\",\n",
" \"DiffDock-L-Vina\",\n",
" \"Conventional blind\",\n",
" \"P2Rank-Vina\",\n",
" \"Ensemble (Con)\",\n",
" \"Hybrid blind\",\n",
" ]\n",
Expand All @@ -734,7 +738,7 @@
" axis.tick_params(axis=\"y\", which=\"major\", left=\"off\", right=\"on\", color=\"#EAEFF8\")\n",
"\n",
" # vertical alignment of xtick labels\n",
" vert_alignments = [0.0, 0.0, 0.0, -0.1, 0.0, 0.0, -0.1, 0.0, 0.0, -0.1]\n",
" vert_alignments = [0.0, 0.0, -0.1, 0.0, 0.0, 0.0, 0.0, -0.1, 0.0, 0.0, -0.1]\n",
" for tick, y in zip(axis.get_xticklabels(), vert_alignments):\n",
" tick.set_y(y)\n",
"\n",
Expand Down Expand Up @@ -783,7 +787,7 @@
" globals()[f\"bust_results_table_{repeat_index}\"] = pd.concat(\n",
" [\n",
" globals()[f\"{method}{config}_bust_results_table_{repeat_index}\"]\n",
" for method in new_methods\n",
" for method in baseline_methods\n",
" for config in [\"\", \"_relaxed\"]\n",
" if f\"{method}{config}_bust_results_table_{repeat_index}\" in globals()\n",
" ]\n",
Expand Down Expand Up @@ -829,7 +833,7 @@
"colors = [\"#FB8072\", \"#BEBADA\"]\n",
"\n",
"bar_width = 0.75\n",
"r1 = [item - 0.25 for item in range(2, 16, 2)]\n",
"r1 = [item - 0.25 for item in range(2, 18, 2)]\n",
"r2 = [x + bar_width for x in r1]\n",
"\n",
"for complex_type in [\"single\", \"multi\"]:\n",
Expand Down Expand Up @@ -1012,7 +1016,7 @@
" # add labels, titles, ticks, etc.\n",
" axis.set_xlabel(f\"{complex_type.title()}-ligand blind docking ({complex_license})\")\n",
" axis.set_ylabel(\"Percentage of complex predictions\")\n",
" axis.set_xlim(1, 15 + 0.1)\n",
" axis.set_xlim(1, 17 + 0.1)\n",
" axis.set_ylim(0, 100)\n",
"\n",
" axis.bar_label(casp15_pb_valid_bar, fmt=\"{:,.1f}%\", label_type=\"center\")\n",
Expand All @@ -1025,18 +1029,19 @@
" axis.grid(axis=\"y\", color=\"#EAEFF8\")\n",
" axis.set_axisbelow(True)\n",
"\n",
" axis.set_xticks([2, 4, 6, 6 + 1e-3, 8, 10, 11, 12, 14, 14 + 1e-3])\n",
" axis.set_xticks([2, 4, 5, 6, 8, 10, 12, 12 + 1e-3, 14, 16, 16 + 1e-3])\n",
" axis.set_xticks([1 + 0.1], minor=True)\n",
" axis.set_xticklabels(\n",
" [\n",
" \"DiffDock-L\",\n",
" \"DynamicBind\",\n",
" \"NeuralPLexer\",\n",
" \"DL-based blind\",\n",
" \"NeuralPLexer\",\n",
" \"RoseTTAFold-All-Atom\",\n",
" \"TULIP\",\n",
" \"Conventional blind\",\n",
" \"DiffDock-L-Vina\",\n",
" \"Conventional blind\",\n",
" \"P2Rank-Vina\",\n",
" \"Ensemble (Con)\",\n",
" \"Hybrid blind\",\n",
" ]\n",
Expand All @@ -1050,7 +1055,7 @@
" axis.tick_params(axis=\"y\", which=\"major\", left=\"off\", right=\"on\", color=\"#EAEFF8\")\n",
"\n",
" # vertical alignment of xtick labels\n",
" vert_alignments = [0.0, 0.0, 0.0, -0.1, 0.0, 0.0, -0.1, 0.0, 0.0, -0.1]\n",
" vert_alignments = [0.0, 0.0, -0.1, 0.0, 0.0, 0.0, 0.0, -0.1, 0.0, 0.0, -0.1]\n",
" for tick, y in zip(axis.get_xticklabels(), vert_alignments):\n",
" tick.set_y(y)\n",
"\n",
Expand Down
Binary file modified notebooks/casp15_method_interaction_analysis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions notebooks/casp15_method_interaction_analysis_plotting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"outputs": [],
"source": [
"# General variables\n",
"new_methods = [\n",
"baseline_methods = [\n",
" \"diffdock\",\n",
" \"dynamicbind\",\n",
" \"neuralplexer\",\n",
Expand Down Expand Up @@ -269,8 +269,8 @@
"metadata": {},
"outputs": [],
"source": [
"# calculate and cache CASP15 interaction statistics for each new method\n",
"for method in new_methods:\n",
"# calculate and cache CASP15 interaction statistics for each baseline method\n",
"for method in baseline_methods:\n",
" for repeat_index in range(1, max_num_repeats_per_method + 1):\n",
" method_title = method_mapping[method]\n",
"\n",
Expand Down Expand Up @@ -404,7 +404,7 @@
"\n",
"\n",
"# load data from files\n",
"for method in new_methods:\n",
"for method in baseline_methods:\n",
" for repeat_index in range(1, max_num_repeats_per_method + 1):\n",
" method_title = method_mapping[method]\n",
" file_path = f\"{method}_casp15_interaction_dataframes_{repeat_index}.h5\"\n",
Expand Down
Binary file not shown.
Loading

0 comments on commit 44eb053

Please sign in to comment.