Skip to content

Commit

Permalink
Rename PIP2 Pip2 in all plots
Browse files Browse the repository at this point in the history
  • Loading branch information
fjclark committed Jul 29, 2024
1 parent 56bbfac commit ab5db5b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 48 deletions.
69 changes: 28 additions & 41 deletions analysis/adaptive/adaptive_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
" \"MDM2-Nutlin\": \"mdm2_nutlin_notprot\",\n",
"}\n",
"\n",
"REF_COST = 0.21 # GPU hours per ns"
"REF_COST = 0.21 # GPU hours per ns\n",
"\n",
"# Define how we want to rename some systems for display\n",
"rename = {\"PDE2A\": \"PDE2a\", \"MDM2-PIP2\": \"MDM2-Pip2\"}"
]
},
{
Expand Down Expand Up @@ -207,7 +210,8 @@
" )\n",
" # Vertical line at the equilibration time\n",
" ax1.axvline(equil_time, linestyle = \"--\", label = \"Equil. time (paired $t$)\", color = \"black\")\n",
" ax1.set_title(f\"{lig} {leg_str} {stage_str}\")\n",
" lig_title = rename.get(lig, lig)\n",
" ax1.set_title(f\"{lig_title} {leg_str} {stage_str}\")\n",
" ax1.set_ylabel(\"$\\Delta G$ (kcal/mol)\")\n",
" # Hide all x axis labels to avoid overlap\n",
" ax1.get_xaxis().set_visible(False)\n",
Expand Down Expand Up @@ -289,7 +293,8 @@
" )\n",
" # Vertical line at the equilibration time\n",
" ax1.axvline(equil_time, linestyle = \"--\", label = \"Equil. time (paired $t$)\", color = \"black\")\n",
" ax1.set_title(f\"{lig} {leg_str} {stage_str}\")\n",
" lig_title = rename.get(lig, lig)\n",
" ax1.set_title(f\"{lig_title} {leg_str} {stage_str}\")\n",
" ax1.set_ylabel(\"$\\Delta G$ (kcal/mol)\")\n",
" # Red vertical lines at the individual run Chodera equilibration times\n",
" for z, equil_idx_chodera_indiv in enumerate(equil_times_chodera_indiv[lig][leg][stage]):\n",
Expand Down Expand Up @@ -435,6 +440,7 @@
"# Change the title of PDE2A to PDE2a\n",
"axs = fig.get_axes()\n",
"axs[-4].set_title(\"PDE2a Bound Vanish\")\n",
"axs[-6].set_title(\"MDM2-Pip2 Bound Vanish\")\n",
"\n",
"# Add a legend to the figure, off to the bottom of the last plot\n",
"axs = fig.get_axes()\n",
Expand Down Expand Up @@ -490,7 +496,7 @@
" label = method if method == \"Chodera\" else \"Paired $t$\"\n",
" ax.bar(x + i*width, results_overall[method], width, label = label)\n",
"ax.set_xticks(x + width/2)\n",
"ax.set_xticklabels(ligs.keys())\n",
"ax.set_xticklabels([rename.get(lig, lig) for lig in ligs.keys()])\n",
"ax.set_ylabel(\"Absolute difference in $\\Delta G$ Compared \\nto 30 ns Result / kcal mol$^{-1}$\")\n",
"ax.legend()\n",
"fig.tight_layout()\n",
Expand Down Expand Up @@ -568,7 +574,7 @@
"# Turn results summary into a dataframe\n",
"results_summary_df = pd.DataFrame(results_summary).T\n",
"# Replace PDE2A with PDE2a\n",
"results_summary_df = results_summary_df.rename(index={\"PDE2A\": \"PDE2a\"})\n",
"results_summary_df = results_summary_df.rename(index={\"PDE2A\": \"PDE2a\", \"MDM2-PIP2\": \"MDM2-Pip2\"})\n",
"results_summary_df.to_latex(\"final_analysis/results_summary.tex\", escape=False)"
]
},
Expand Down Expand Up @@ -609,7 +615,7 @@
" results_summary_detailed[title][r\"Exp. $\\Delta G^o_\\textrm{Bind}$\"] = exp_res\n",
"\n",
"results_summary_detailed_df = pd.DataFrame(results_summary_detailed).T\n",
"results_summary_detailed_df = results_summary_detailed_df.rename(index={\"PDE2A\": \"PDE2a\"})\n",
"results_summary_detailed_df = results_summary_detailed_df.rename(index={\"PDE2A\": \"PDE2a\", \"MDM2-PIP2\": \"MDM2-Pip2\"})\n",
"results_summary_detailed_df.to_latex(\"final_analysis/results_summary_detailed.tex\", escape=False)"
]
},
Expand Down Expand Up @@ -640,7 +646,7 @@
" lam_vals_local = lam_vals[lig][leg][stage]\n",
" axs[k, i].plot(lambda_idx, lam_vals_local, label = leg_str, marker = \"o\")\n",
" axs[k, i].plot(lambda_idx, linear, linestyle = \"--\", color = \"black\")\n",
" axs[k, i].set_title(f\"{lig} {stage_str}\")\n",
" axs[k, i].set_title(f\"{rename.get(lig, lig)} {stage_str}\")\n",
" axs[k, i].set_xlabel(\"Window Index\")\n",
" axs[k, i].set_ylabel(\"$\\lambda$\")\n",
" # Add text stating the number of windows\n",
Expand All @@ -664,13 +670,6 @@
"## Relative Costs"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -679,6 +678,8 @@
"source": [
"# Plot bar plot of costs\n",
"costs_df = pd.DataFrame(costs)\n",
"# Rename columns as required\n",
"costs_df = costs_df.rename(columns = {lig: rename.get(lig, lig) for lig in ligs})\n",
"# Change row names to Bound Leg and Free Leg\n",
"costs_df.index = [\"Bound Leg\", \"Free Leg\"]\n",
"# Nice black outline round bars\n",
Expand Down Expand Up @@ -719,7 +720,7 @@
" ax.bar(lam_vals_local, times, label = \"Total sampling time\", edgecolor = \"black\", width = width)\n",
" # Plot the equilibration times\n",
" ax.bar(lam_vals_local, equil_times, label = \"Equilibration time\", edgecolor = \"black\", width = width, hatch = \"///////\")\n",
" ax.set_title(f\"{lig} {leg_str} {stage_str}\")\n",
" ax.set_title(f\"{rename.get(lig, lig)} {leg_str} {stage_str}\")\n",
" ax.set_xlabel(\"$\\lambda$\")\n",
" ax.set_ylabel(\"GPU Hours\")\n",
"\n",
Expand Down Expand Up @@ -752,12 +753,7 @@
" ax.bar(x + (i * width), tot_times_free, width, label=f\"Free {stage.split('.')[1].capitalize()}\", edgecolor=\"k\", alpha=1, color=color, hatch=\"///////\")\n",
"\n",
"ax.set_xticks(x + width)\n",
"x_labels = []\n",
"for system in sampling_times:\n",
" if system != \"PDE2A\":\n",
" x_labels.append(system)\n",
" else:\n",
" x_labels.append(\"PDE2a\")\n",
"x_labels = [rename.get(system, system) for system in sampling_times]\n",
"ax.set_xticklabels(x_labels)\n",
"ax.set_ylabel(\"Total Sampling Time / GPU Hours\")\n",
"# Put label off to right of plot\n",
Expand Down Expand Up @@ -787,12 +783,7 @@
" ax.bar(x + (i * width), tot_times_free, width, label=f\"Free {stage.split('.')[1].capitalize()}\", edgecolor=\"k\", alpha=1, color=color, hatch=\"///////\")\n",
"\n",
"ax.set_xticks(x + 1.5*width)\n",
"x_labels = []\n",
"for system in sampling_times:\n",
" if system != \"PDE2A\":\n",
" x_labels.append(system)\n",
" else:\n",
" x_labels.append(\"PDE2a\")\n",
"x_labels = [rename.get(system, system) for system in sampling_times]\n",
"ax.set_xticklabels(x_labels)\n",
"ax.set_ylabel(\"Total Sampling Time / GPU Hours\")\n",
"# Put label off to right of plot\n",
Expand Down Expand Up @@ -826,12 +817,7 @@
" ax.bar(x + (i * width), tot_times_free_per_window, width, label=f\"Free {stage.split('.')[1].capitalize()}\", edgecolor=\"k\", alpha=1, color=color, hatch=\"///////\")\n",
"\n",
"ax.set_xticks(x + width)\n",
"x_labels = []\n",
"for system in sampling_times:\n",
" if system != \"PDE2A\":\n",
" x_labels.append(system)\n",
" else:\n",
" x_labels.append(\"PDE2a\")\n",
"x_labels = [rename.get(system, system) for system in sampling_times]\n",
"ax.set_xticklabels(x_labels)\n",
"ax.set_ylabel(\"Total Sampling Time per Window / GPU Hours\")\n",
"# Put label off to right of plot\n",
Expand Down Expand Up @@ -862,12 +848,7 @@
" ax.bar(x + (i * width), tot_times_free_per_window, width, label=f\"Free {stage.split('.')[1].capitalize()}\", edgecolor=\"k\", alpha=1, color=color, hatch=\"///////\")\n",
"\n",
"ax.set_xticks(x + 1.5*width)\n",
"x_labels = []\n",
"for system in sampling_times:\n",
" if system != \"PDE2A\":\n",
" x_labels.append(system)\n",
" else:\n",
" x_labels.append(\"PDE2a\")\n",
"x_labels = [rename.get(system, system) for system in sampling_times]\n",
"ax.set_xticklabels(x_labels)\n",
"ax.set_ylabel(\"Total Sampling Time per Window / GPU Hours\")\n",
"# Put label off to right of plot\n",
Expand Down Expand Up @@ -960,7 +941,12 @@
" ax.set_ylabel(r\"$\\Delta G$ / kcal mol$^{-1}$\")\n",
" stage_str = stage.split(\".\")[1].capitalize()\n",
" leg_str = leg.split(\".\")[1].capitalize()\n",
" system_title = system if system != \"PDE2A\" else \"PDE2a\"\n",
" if system == \"PDE2A\":\n",
" system_title = \"PDE2a\"\n",
" elif system == \"MDM2-PIP2\":\n",
" system_title = \"MDM2-Pip2\"\n",
" else:\n",
" system_title = system\n",
" ax.set_title(f\"{system_title} {leg_str} {stage_str}\")\n",
" ax.legend()\n",
" plt.tight_layout()\n",
Expand Down Expand Up @@ -1403,7 +1389,8 @@
" # Label the plot\n",
" ax.set_xlabel(\"GPU Hours\")\n",
" ax.set_ylabel(r\"95 % CI of $\\Delta G$ / kcal mol$^{-1}$\")\n",
" ax.set_title(f\"{system}\")\n",
" sys_title = rename.get(system, system)\n",
" ax.set_title(f\"{sys_title}\")\n",
" ax.legend()\n",
" # Ensure that the bottom of the scale is 0\n",
" plt.tight_layout()\n",
Expand Down
27 changes: 21 additions & 6 deletions analysis/non_adaptive/non_adaptive_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
"plt.rc('text.latex', preamble=r'\\usepackage{amsmath}')\n",
"from typing import List, Tuple, Dict, Callable, Union\n",
"%matplotlib inline\n",
"from scipy.stats import linregress, kruskal, t, sem"
"from scipy.stats import linregress, kruskal, t, sem\n",
"\n",
"# Define how we want to rename some systems\n",
"rename = {\"PDE2A\": \"PDE2a\", \"MDM2-PIP2\": \"MDM2-Pip2\"}"
]
},
{
Expand Down Expand Up @@ -139,7 +142,7 @@
"# Turn results summary into a dataframe\n",
"results_summary_df = pd.DataFrame(results_summary).T\n",
"# Replace PDE2A with PDE2a\n",
"results_summary_df = results_summary_df.rename(index={\"PDE2A\": \"PDE2a\"})\n",
"results_summary_df = results_summary_df.rename(index={\"PDE2A\": \"PDE2a\", \"MDM2-PIP2\": \"MDM2-Pip2\"})\n",
"results_summary_df.to_latex(\"final_analysis/results_summary.tex\", escape=False)"
]
},
Expand Down Expand Up @@ -180,7 +183,7 @@
" results_summary_detailed[title][r\"Exp. $\\Delta G^o_\\textrm{Bind}$\"] = exp_res\n",
"\n",
"results_summary_detailed_df = pd.DataFrame(results_summary_detailed).T\n",
"results_summary_detailed_df = results_summary_detailed_df.rename(index={\"PDE2A\": \"PDE2a\"})\n",
"results_summary_detailed_df = results_summary_detailed_df.rename(index={\"PDE2A\": \"PDE2a\", \"MDM2-PIP2\": \"MDM2-Pip2\"})\n",
"results_summary_detailed_df.to_latex(\"final_analysis/results_summary_detailed.tex\", escape=False)"
]
},
Expand Down Expand Up @@ -236,6 +239,15 @@
"## Convergence Analysis"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dgs_conv_nonequil.keys()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -282,7 +294,8 @@
" ax.set_ylabel(r\"$\\Delta G$ / kcal mol$^{-1}$\")\n",
" stage_str = stage.split(\".\")[1].capitalize()\n",
" leg_str = leg.split(\".\")[1].capitalize()\n",
" ax.set_title(f\"{system} {leg_str} {stage_str}\")\n",
" sys_title = [rename.get(system, system)]\n",
" ax.set_title(f\"{sys_title} {leg_str} {stage_str}\")\n",
" ax.legend()\n",
" plt.tight_layout()\n",
"\n",
Expand Down Expand Up @@ -389,8 +402,10 @@
" if stage != \"restrain\":\n",
" ax.bar(x + (i * width), [sig_diff[system][\"30 ns\"][\"free\"][stage] for system in systems], width, label=f\"Free {stage.capitalize()}\", edgecolor=\"k\", alpha=1, color=color, hatch=\"///////\")\n",
"\n",
"# Set the names to display\n",
"system_names = [rename.get(system, system) for system in systems]\n",
"ax.set_xticks(x + width)\n",
"ax.set_xticklabels(systems)\n",
"ax.set_xticklabels(system_names)\n",
"ax.set_ylabel(\"% Windows with Significant Inter-run \\n Differences Between Gradient Distributions\")\n",
"# Put label off to right of plot\n",
"ax.legend(bbox_to_anchor=(1.03, 0.7))\n",
Expand Down Expand Up @@ -476,7 +491,7 @@
" if free_only:\n",
" offset = 0.04\n",
" ax.text(0.965, 0.935 + offset, f\"IF {leg.capitalize()}: {av_improvement_factor:.2f} $\\pm$ {sd_improvement_factor:.2f}\", transform=ax.transAxes, horizontalalignment=\"right\", verticalalignment=\"top\")\n",
" sys_title = system if system != \"PDE2A\" else \"PDE2a\"\n",
" sys_title = rename.get(system, system)\n",
" ax.set_title(f\"{sys_title} {stage.capitalize()}\")\n",
" ax.set_xlabel(r\"$\\lambda$\")\n",
" ylabel = r\"$\\sqrt{t_\\lambda}\\sigma\\left(\\left\\langle\\frac{\\partial H}{\\partial \\lambda}\\right\\rangle_\\lambda\\right)$ / kcal mol$^{-1}$ ns$^{\\frac{1}{2}}$\" if len_type == \"SEM\" else r\"$\\sigma\\left(\\frac{\\partial H}{\\partial \\lambda}\\right)$ / kcal mol$^{-1}$\"\n",
Expand Down
3 changes: 2 additions & 1 deletion analysis/non_adaptive/non_adaptive_preprocessing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3"
"pygments_lexer": "ipython3",
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down

0 comments on commit ab5db5b

Please sign in to comment.