From 9c256e291c571ca7c58cdd8865e0effcd2766fe2 Mon Sep 17 00:00:00 2001 From: Hannah Bruce Macdonald <43652597+hannahbrucemacdonald@users.noreply.github.com> Date: Mon, 31 Aug 2020 10:33:54 +0100 Subject: [PATCH 1/2] Adding plot of BAR overlap I'm not sure the input for the function is right -- maybe x and y should be passed in, rather than whole json --- covid_moonshot/analysis/fah_plotting.py | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/covid_moonshot/analysis/fah_plotting.py b/covid_moonshot/analysis/fah_plotting.py index b1356ce9..938cce84 100644 --- a/covid_moonshot/analysis/fah_plotting.py +++ b/covid_moonshot/analysis/fah_plotting.py @@ -195,3 +195,30 @@ def plot_cumulative_distributions(results, minimum=None, maximum=5, cmap='PiYG', plt.ylabel('Cumulative $N$ ligands') plt.title(title) _produce_plot(f"{filename}") + +def plot_bar_distributions(results, title=''): + """Plots solvent BAR overlap against complex BAR overlap with marginal distribution + + >>> results = json.load(open('analysis.json','r')) + >>> plot_bar_distributions(results, 'Sprint 3') + + Parameters + ---------- + results : list(dict) + Contents of analysis.json + title : str, default='' + Title for plot + + """ + import numpy as np + import seaborn as sns + sns.set(style="ticks") + + x = [r['analysis']['solvent_phase']['free_energy']['bar_overlap'] for r in results] + y = [r['analysis']['complex_phase']['free_energy']['bar_overlap'] for r in results] + + # BAR overlap has range of 0. to 1. so set limits to represent this + sns.jointplot(x, y,kind='scatter', color="#4CB391",xlim=(0.,1.),ylim=(0.,1.)).set_axis_labels(f"Solvent BAR overlap\n{title}", "Complex BAR overlap") + plt.show() + + From 1cba9f3433c47958e7e5ff40bfdc28ec8fd53396 Mon Sep 17 00:00:00 2001 From: Hannah Bruce Macdonald <43652597+hannahbrucemacdonald@users.noreply.github.com> Date: Mon, 31 Aug 2020 10:36:40 +0100 Subject: [PATCH 2/2] Update fah_plotting.py using _produce_plot --- covid_moonshot/analysis/fah_plotting.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/covid_moonshot/analysis/fah_plotting.py b/covid_moonshot/analysis/fah_plotting.py index 938cce84..7cf18d1e 100644 --- a/covid_moonshot/analysis/fah_plotting.py +++ b/covid_moonshot/analysis/fah_plotting.py @@ -196,7 +196,7 @@ def plot_cumulative_distributions(results, minimum=None, maximum=5, cmap='PiYG', plt.title(title) _produce_plot(f"{filename}") -def plot_bar_distributions(results, title=''): +def plot_bar_distributions(results, title='', filename='BARoverlap'): """Plots solvent BAR overlap against complex BAR overlap with marginal distribution >>> results = json.load(open('analysis.json','r')) @@ -208,7 +208,8 @@ def plot_bar_distributions(results, title=''): Contents of analysis.json title : str, default='' Title for plot - + filename : str, default='BARoverlap' + Location to save fille """ import numpy as np import seaborn as sns @@ -219,6 +220,6 @@ def plot_bar_distributions(results, title=''): # BAR overlap has range of 0. to 1. so set limits to represent this sns.jointplot(x, y,kind='scatter', color="#4CB391",xlim=(0.,1.),ylim=(0.,1.)).set_axis_labels(f"Solvent BAR overlap\n{title}", "Complex BAR overlap") - plt.show() + _produce_plot(filename)