Skip to content

Commit

Permalink
Updated figures for revised manuscript
Browse files Browse the repository at this point in the history
  • Loading branch information
SamiralVdB committed Jul 16, 2024
1 parent 283818c commit 4a2d203
Show file tree
Hide file tree
Showing 21 changed files with 562 additions and 236 deletions.
Binary file modified Figures/Figure1_toy-model.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 30 additions & 17 deletions Figures/Figure1_toy_ec_pam.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from cobra import Model, Reaction, Metabolite
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
from PIL import Image
Image.MAX_IMAGE_PIXELS = None #to make sure the image is loaded properly in high quality

Expand Down Expand Up @@ -79,7 +80,7 @@ def build_toy_gem():
r1.add_metabolites({Metabolite('Substrate'): 1})
# R2:
r2 = model.reactions.get_by_id('R2')
r2.add_metabolites({Metabolite('Substrate'): -1, Metabolite('Intermediate'): 1, Metabolite('CO2'): 1})
r2.add_metabolites({Metabolite('Substrate'): -1, Metabolite('Intermediate'): 1, Metabolite('ATP'): 0.5})
# R3:
r3 = model.reactions.get_by_id('R3')
r3.add_metabolites({Metabolite('Intermediate'): -1, Metabolite('Byproduct'):1, Metabolite('ATP'):1})
Expand All @@ -106,7 +107,7 @@ def build_toy_gem():
return model

def build_active_enzyme_sector(Config):
kcat_fwd = [1, 0.5, 1, 1, 0.5 ,0.45, 1.5] # High turnover for exchange reactions
kcat_fwd = [1, 0.5, 1, 1, 0.5 ,0.45, 1.5] # High turnover for exchange reactions [1, 0.5, 1, 1, 0.5 ,0.45, 1.5]
kcat_rev = [kcat for kcat in kcat_fwd]
rxn2kcat = {}
for i in range(n-3): # all reactions have an enzyme, except excretion reactions
Expand Down Expand Up @@ -161,9 +162,9 @@ def run_simulations(pamodel, substrate_axis):
'Ccsc':Ccsc, 'Cesc':Cesc,
'x_axis_csc': x_axis_csc,'x_axis_esc': x_axis_esc}

def plot_sensitivities(fig, grdspec, glc_rates, mu_list, tot_prot_csc, substrate_csc, e1_esc):
def plot_sensitivities(fig, grdspec, glc_rates, mu_list, tot_prot_csc, substrate_csc, e1_esc, pie_data, pie_labels):
gs = gridspec.GridSpecFromSubplotSpec(2, 1,
height_ratios=[1,1], hspace=0, subplot_spec=grdspec)
height_ratios=[1,2], hspace=0, subplot_spec=grdspec)
sens_ax = fig.add_subplot(gs[1, 0]) # sensitivity coefficient linegraph
mu_ax = fig.add_subplot(gs[0, 0], sharex=sens_ax) # mu vs v_s linegraph

Expand All @@ -173,28 +174,35 @@ def plot_sensitivities(fig, grdspec, glc_rates, mu_list, tot_prot_csc, substrate
mu = mu_ax.plot(glc_rates, mu_list, color = 'black', linewidth= 3)#(35/255,158/255,137/255)
mu_ax.xaxis.set_visible(False)
# mu_ax.legend([mu], labels=['growth rate'], loc='center left')
mu_ax.set_ylabel('$v_{biomass} $ $(h^{-1})$', fontsize = FONTSIZE)
mu_ax.set_ylabel('$v_{biomass} $ $(h^{-1})$', fontsize = FONTSIZE*3/4)
# add B panel annotation
mu_ax.annotate('B', xy=(0.01, 0.01), xycoords='data',
xytext=(-0.1, 1.05), textcoords='axes fraction',
mu_ax.annotate('B', xy=(-0.1, 0.1), xycoords='figure fraction',
xytext=(-0.1, 1.5), textcoords='axes fraction',
va='top', ha='left', fontsize=FONTSIZE*1.5, weight='bold')
mu_ax.set_ylim([0.03,0.07])

# plot the sensitivity coefficients
vs = sens_ax.plot(glc_rates, substrate_csc, color ='orange', linewidth= 3) #(62/255,174/255, 137/255)
e1 = sens_ax.plot(glc_rates, e1_esc, color =(68 / 255, 1 / 255, 84 / 255), linewidth= 3, linestyle ='dashed')
e1 = sens_ax.plot(glc_rates, e1_esc, color =(0.00,0.45,0.81), linewidth= 3, linestyle ='dashed')
e_tot = sens_ax.plot(glc_rates, tot_prot_csc, color ='darkred', linewidth= 3, linestyle ='dotted')#(62/255, 64/255, 137/255)

sens_ax.legend([vs, e1, e_tot], labels=['$FCSC_{v_{1}}$','$ESC_{E_{1}}$','$PCSC$'], loc='center left')
sens_ax.set_ylim([-0.1,1.3])
sens_ax.set_ylabel('Sensitivity Coefficients', fontsize = FONTSIZE)
sens_ax.set_xlabel('$v_{substrate,max}$ $(mmol_{substrate}/g_{CDW}/h)$', fontsize = FONTSIZE)
sens_ax.set_xlim([0.04,0.1])
sens_ax.set_ylabel('Sensitivity Coefficients', fontsize = FONTSIZE*3/4)
sens_ax.set_xlabel('$v_{substrate,max}$ $(mmol_{substrate}/g_{CDW}/h)$', fontsize = FONTSIZE*3/4)

# Add a pie chart showing the enzyme sensitivities as an inset in the sensitivity linegraph
inset_ax = inset_axes(sens_ax, width="50%", height="50%", loc='center right')
inset_ax.pie(pie_data, labels=pie_labels, textprops={'fontweight': 'bold'}, startangle=90, labeldistance = 0.6)

return fig

if __name__ == "__main__":

#NOTE:RUN THIS SCRIPT FROM THE MAIN DIRECTORY IN THE COMMAND LINE.
# otherwise the relative paths set in this script will result in errors
FONTSIZE = 16
width = 7
width = 10
height = 12
model = build_toy_gem()
active_enzyme = build_active_enzyme_sector(Config)
Expand All @@ -215,14 +223,14 @@ def plot_sensitivities(fig, grdspec, glc_rates, mu_list, tot_prot_csc, substrate
# gridspec inside gridspec
fig = plt.figure()

gs0 = gridspec.GridSpec(2, 1, figure=fig, height_ratios=[1,1])
gs0 = gridspec.GridSpec(2, 1, figure=fig, height_ratios=[3,2])
gs_toymodel = gs0[0]
gs_sensitivities = gs0[1]

image_path = 'Figure1_toy-model.png'
image_path = 'Figures/Figure1_toy-model.png'
toy_model = np.asarray(Image.open(image_path))
ax_fig = fig.add_subplot(gs_toymodel)
ax_fig.imshow(toy_model)
ax_fig.imshow(toy_model, aspect='equal')
ax_fig.annotate('A', xy=(2, 1), xycoords='data',
xytext=(-0.1, 1), textcoords='axes fraction',
va='top', ha='left', fontsize=FONTSIZE*1.5, weight='bold')
Expand All @@ -236,16 +244,21 @@ def plot_sensitivities(fig, grdspec, glc_rates, mu_list, tot_prot_csc, substrate
if 'R1_flux_ub' in id:
substrate_csc = [row[index] for row in simulation_results['Ccsc']]

pielabels = []
for index, id in enumerate(simulation_results['x_axis_esc']):
if 'E1' in id:
e1_esc = [row[index] for row in simulation_results['Cesc']]
if 'E3' in id:
pielabels.append('')
else:
pielabels.append(id)


fig = plot_sensitivities(fig, gs_sensitivities, simulation_results['substrate_axis'], simulation_results['mu_list'],
tot_prot_csc, substrate_csc, e1_esc)
tot_prot_csc, substrate_csc, e1_esc, simulation_results['Cesc'][-1], pielabels)
fig.set_figwidth(width)
fig.set_figheight(height)
plt.tight_layout()

fig.savefig('Figure1_toy_model-sensitivities.png',bbox_inches='tight')
fig.savefig('Figures/Figure1_toy_model-sensitivities.png',bbox_inches='tight')
plt.show()
Loading

0 comments on commit 4a2d203

Please sign in to comment.