diff --git a/Plots_Droplet_FRAP.ipynb b/Plots_Droplet_FRAP.ipynb index dc130c2927ab36b25d77cbcfd54e597b9fe5fba9..4382dc530e6a5ff705d938de105f00553a78829d 100644 --- a/Plots_Droplet_FRAP.ipynb +++ b/Plots_Droplet_FRAP.ipynb @@ -14,6 +14,7 @@ "import numpy as np\n", "import pandas as pd\n", "import seaborn as sns\n", + "from scipy.interpolate import interp1d\n", "fol = '/Users/hubatsch/Desktop/DropletFRAP/Latex/Figures/'\n", "# sns.set_style(\"ticks\")\n", "rcParams['axes.linewidth'] = 0.75\n", @@ -59,8 +60,8 @@ " plt.ylim(yli)\n", " plt.tick_params(axis='both', which='major', labelsize=fs)\n", "\n", - "def save_nice_fig(name):\n", - " plt.savefig(name, format='pdf', dpi=300, bbox_inches='tight',\n", + "def save_nice_fig(name, form='pdf'):\n", + " plt.savefig(name, format=form, dpi=300, bbox_inches='tight',\n", " transparent=True)" ] }, @@ -339,6 +340,22 @@ "lars = pd.read_csv('/Users/hubatsch/Desktop/DropletFRAP/Latex/Figures/Fig1/Lars.csv')" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Calculate rough molecular radius, based on Stokes-Einstein and Louise's\n", + "# viscosity data from the Science paper supplement (Fig. S5G), email from Louise:\n", + "# earliest point is 10.4 Pa*s .\n", + "# Einstein kinetic theory: D=kB*T/(6*pi*eta*r)\n", + "D = lars.D[lars.conc==75].mean()\n", + "eta = 10.4\n", + "kBT = 4.11*10**-21\n", + "r = kBT/(D*6*np.pi*eta)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -349,7 +366,7 @@ "ax2 = ax1.twinx()\n", "plt.sca(ax1)\n", "sns.lineplot(x=\"conc\", y=\"D\", data=lars, color=sns.color_palette()[1])\n", - "sns.scatterplot(x=\"conc\", y=\"D\", data=lars, color=sns.color_palette()[1], alpha=0.7)\n", + "sns.scatterplot(x=\"conc\", y=\"D\", data=lars, color=sns.color_palette()[1], alpha=0.8)\n", "plt.xlabel('$c_\\mathrm{salt}\\; [\\mathrm{mM}]$')\n", "plt.ylabel('$D_{\\mathrm{in}} \\;[\\mathrm{\\mu m^2\\cdot s^{-1}}]$', color=red)\n", "plt.yticks([0, 0.05, 0.1], rotation=90, color = pa[1])\n", @@ -358,11 +375,11 @@ "ax1.patch.set_visible(False)\n", "plt.sca(ax2)\n", "sns.lineplot(x=\"conc\", y=\"vis\", data=louise, color=grey, label='data from Jawerth \\net al. 2018')\n", - "nice_fig('c_\\mathrm{salt} [\\mathrm{mM}]', '$\\eta^{-1} \\;[Pa\\cdot s]^{-1}$', [40,190], [0,7.24], [3*2.3,3*2])\n", + "nice_fig('c_\\mathrm{salt} [\\mathrm{mM}]', '$\\eta^{-1} \\;[Pa\\cdot s]^{-1}$', [40,190], [0,7.24], [2.3,2])\n", "plt.yticks(color = grey)\n", "plt.ylabel('$\\eta^{-1} \\;[\\mathrm{Pa\\cdot s}]^{-1}$ ', color = grey)\n", "plt.legend(frameon=False, fontsize=9)\n", - "# save_nice_fig(fol+'Fig1/Lars_vs_Louise.pdf')" + "save_nice_fig(fol+'Fig1/Lars_vs_Louise.pdf')" ] }, { @@ -398,7 +415,7 @@ "sns.stripplot(data=coacervates, palette=[green, blue], jitter=0.35,**{'marker': '.', 'size': 10})\n", "ax = sns.barplot(data=coacervates, palette=pa, facecolor=(1, 1, 1, 0), edgecolor=[pa[0], pa[2]], capsize=.15, ci='sd', errwidth=1.5)\n", "plt.setp(ax.lines, zorder=100)\n", - "nice_fig(None, '$D_\\mathrm{in} \\;[\\mathrm{\\mu m^2\\cdot s^{-1}}]$', [None, None], [0,6], [2.3,2])\n", + "nice_fig(None, '$D_\\mathrm{in} \\;[\\mathrm{\\mu m^2\\cdot s^{-1}}]$', [None, None], [0,7], [2.3,2])\n", "plt.xticks([0,1], ('CMD/PLYS', 'PLYS/ATP'), rotation=20)\n", "ax.get_xticklabels()[0].set_color(green)\n", "ax.get_xticklabels()[1].set_color(blue)\n", @@ -425,7 +442,7 @@ "l_fit = plt.plot(CMD_fit[:, 0], CMD_fit[:, 1::2], '-', lw=1, c='k')\n", "plt.plot(range(0, 10), np.ones(10)*np.min(CMD_fit[:, 1]), linestyle='--', color=grey, lw=1.5)\n", "plt.legend([l_sim[0], l_fit[0]], ['data', 'fit'], ncol=2, loc=(0, 0.85), frameon=False)\n", - "nice_fig('radial distance $r$ [$\\mathrm{\\mu m}$]', 'intensity (a.u)', [0,np.max(CMD_fit[:, 0])], [0,0.6], [2.3,2])\n", + "nice_fig('radial distance $r$ [$\\mathrm{\\mu m}$]', 'intensity (a.u)', [0,np.max(CMD_fit[:, 0])], [0,0.65], [2.3,2])\n", "save_nice_fig(fol+'Fig1/CMD_spat_recov.pdf')" ] }, @@ -448,10 +465,52 @@ "l_fit = plt.plot(PGL_fit[:, 0], PGL_fit[:, 1::2], '-', lw=1, c='k')\n", "plt.plot(range(0, 10), np.ones(10)*np.min(PGL_fit[:, 1]), linestyle='--', color=grey, lw=1.5)\n", "plt.legend([l_sim[0], l_fit[0]], ['data', 'fit'], ncol=2, loc=(0.015, 0.865), frameon=False)\n", - "nice_fig('radial distance $r$ [$\\mathrm{\\mu m}$]', 'intensity (a.u)', [0,np.max(PGL_fit[:, 0])], [0, 0.6], [2.3,2])\n", + "nice_fig('radial distance $r$ [$\\mathrm{\\mu m}$]', 'intensity (a.u)', [0,np.max(PGL_fit[:, 0])], [0, 0.7], [2.3,2])\n", "save_nice_fig(fol+'Fig1/PGL_spat_recov.pdf')" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "l_sim = plt.plot(PGL[:, 0], PGL[:, 1], '-', c=red)\n", + "nice_fig('', '', [0,np.max(PGL_fit[:, 0])], [0, 0.55], [0.7,0.7], fs=5)\n", + "plt.yticks([0, 0.5], ['', ''])\n", + "plt.xticks([0, 3], ['', ''])\n", + "plt.gca().tick_params(direction='in', length=3, width=1)\n", + "save_nice_fig(fol+'Fig1/PGL_spat_90.pdf')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "l_sim = plt.plot(PGL[:, 0], PGL[:, 4], '-', c=red)\n", + "nice_fig('', '', [0,np.max(PGL_fit[:, 0])], [0, 0.55], [0.7,0.7], fs=5)\n", + "plt.yticks([0, 0.5], ['', ''])\n", + "plt.xticks([0, 3], ['', ''])\n", + "plt.gca().tick_params(direction='in', length=3, width=1)\n", + "save_nice_fig(fol+'Fig1/PGL_spat_300.pdf')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "l_sim = plt.plot(PGL[:, 0], PGL[:, 7], '-', c=red)\n", + "nice_fig('', '', [0,np.max(PGL_fit[:, 0])], [0, 0.55], [0.7,0.7], fs=5)\n", + "plt.yticks([0, 0.5], ['', ''])\n", + "plt.xticks([0, 3], ['', ''])\n", + "plt.gca().tick_params(direction='in', length=3, width=1)\n", + "save_nice_fig(fol+'Fig1/PGL_spat_510.pdf')" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -465,9 +524,9 @@ "metadata": {}, "outputs": [], "source": [ - "PGL = np.loadtxt(fol+'/Fig1/PGL_tot.csv', delimiter=',')\n", - "ATP = np.loadtxt(fol+'/Fig1/ATP_tot.csv', delimiter=',')\n", - "CMD = np.loadtxt(fol+'/Fig1/CMD_tot.csv', delimiter=',')\n", + "PGL = np.loadtxt(fol+'/Fig1/PGL_bc.csv', delimiter=',')\n", + "ATP = np.loadtxt(fol+'/Fig1/ATP_bc.csv', delimiter=',')\n", + "CMD = np.loadtxt(fol+'/Fig1/CMD_bc.csv', delimiter=',')\n", "# fig, ax1 = plt.subplots()\n", "# ax2 = ax1.twiny()\n", "# plt.sca(ax1)\n", @@ -479,7 +538,22 @@ "plt.plot(CMD[::5, 0]/np.max(CMD[:, 0]), CMD[::5,1], '.', label='CMD/PLYS', c='#7F2845', markersize=3, alpha=0.7, lw=2)\n", "plt.legend(frameon=False, fontsize=9)\n", "plt.xlim(0, 1)\n", - "save_nice_fig(fol+'Fig1/tot_recov.pdf')" + "# save_nice_fig(fol+'Fig1/tot_recov.pdf')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "PGL = []\n", + "for i in range(8):\n", + " PGL.append(np.loadtxt(fol+'/Fig1/PGL_bc'+str(i+1)+'.csv', delimiter=','))\n", + "conc = np.loadtxt(fol+'/Fig1/PGL_conc.csv', delimiter=',')\n", + "rads = [25, 24, 29, 26, 25, 53, 33, 26]\n", + "# PGL = [PGL[i] for i in [0, 1, 2, 3, 4, 5, 7]]\n", + "# rads = " ] }, { @@ -488,12 +562,21 @@ "metadata": {}, "outputs": [], "source": [ - "nice_fig('time $t$ [s]', 'intensity (a.u)', [0,200], [0,0.62], [1,2])\n", + "nice_fig('time $t$ [s]', 'intensity (a.u)', [0,140], [0,0.82], [1,2])\n", + "temp = sns.color_palette()\n", + "sns.set_palette(sns.color_palette(\"rocket\", 9))\n", "# plt.sca(ax2)\n", "# ax2.tick_params(axis=\"x\",direction=\"in\")\n", - "plt.plot(PGL[::10, 0], PGL[::10,1], '.', label='PGL-3', c='#CC406E', markersize=3, alpha=0.7, lw=2)\n", - "plt.legend(frameon=False, fontsize=9, handletextpad=0.4)\n", - "save_nice_fig(fol+'Fig1/tot_recov_PGL.pdf')" + "# plt.plot(PGL[::10, 0], PGL[::10,1], '.', label='PGL-3', c='#CC406E', markersize=3, alpha=0.7, lw=2)\n", + "for jj, i in enumerate(PGL):\n", + " if jj != 10:\n", + " plt.plot(i[::, 0]/(0.136*rads[jj])**2, i[::,1], '-', color=sns.color_palette()[jj], lw=1.5)\n", + "plt.legend([str(x)[:-2] for x in conc], columnspacing=0.2, frameon=False,\n", + " fontsize=7, handletextpad=0.4, handlelength=0.5, labelspacing=0.1,\n", + " loc=(0.3, 0), ncol=2) \n", + "# plt.xticks([0, 500])\n", + "save_nice_fig(fol+'Fig1/tot_recov_PGL.pdf')\n", + "sns.set_palette(temp)" ] }, { @@ -502,10 +585,10 @@ "metadata": {}, "outputs": [], "source": [ - "nice_fig('time $t$ [s]', 'intensity (a.u)', [0,10], [0,0.62], [1,2])\n", - "plt.plot(ATP[::1, 0], ATP[::1,1], '.', label='PLYS/ATP', c='#FF508A', markersize=3, alpha=0.7, lw=2)\n", - "plt.plot(CMD[::5, 0], CMD[::5,1], '.', label='CMD/PLYS', c='#7F2845', markersize=3, alpha=0.7, lw=2)\n", - "plt.legend(frameon=False, fontsize=9, loc=(-0.08, 0), handletextpad=0)\n", + "nice_fig('time $t$ [s]', 'intensity (a.u)', [0,10], [0,0.72], [1,2])\n", + "plt.plot(ATP[::1, 0], ATP[::1,1], '-', label='PLYS/ATP', c=blue, markersize=3, alpha=0.7, lw=1.5)\n", + "plt.plot(CMD[::5, 0], CMD[::5,1], '-', label='CMD/PLYS', c=green, markersize=3, alpha=0.7, lw=1.5)\n", + "plt.legend(frameon=False, fontsize=7, loc=(0.1, 0), handletextpad=0.5)\n", "plt.yticks([]); plt.ylabel('')\n", "save_nice_fig(fol+'Fig1/tot_recov_coac.pdf')" ] @@ -555,6 +638,62 @@ "save_nice_fig(fol+'Fig2/snap_shot.pdf')" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "l_fit = plt.plot(model[:, 0], model[:, 1], '-', lw=1,\n", + " c=dark_grey, label='Simulation')\n", + "plt.plot(model[:, 0], model[:, -1], 'k', lw=2)\n", + "nice_fig('radial distance $r/R$', 'volume fraction $\\phi_\\mathrm{u}$', [0, 2],\n", + " [0,1], [2.3,2])\n", + "plt.title('$t=0.22 \\;R^2/D_\\mathrm{in}$')\n", + "plt.text(1.45, 0.02, '$\\phi_\\mathrm{u}$', fontsize=10)\n", + "plt.gca().fill_between(model[:, 0], 0, model[:, -1], color=green)\n", + "plt.gca().fill_between(model[:, 0], model[:, -1], model[:, 1], color=grey)\n", + "plt.annotate('$\\phi_\\mathrm{tot}$', (1, 0.5), (1.5,0.5), fontsize=10)\n", + "save_nice_fig(fol+'Fig2/snap_shot_bleach.pdf')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "l_fit = plt.plot(model[:, 0], model[:, -2], '-', lw=1,\n", + " c=dark_grey, label='Simulation')\n", + "plt.plot(model[:, 0], model[:, -1], 'k', lw=2)\n", + "nice_fig('radial distance $r/R$', 'volume fraction $\\phi_\\mathrm{u}$', [0, 2],\n", + " [0,1], [2.3,2])\n", + "plt.title('$t=0.22 \\;R^2/D_\\mathrm{in}$')\n", + "plt.text(0.47, 0.4, '$\\phi_\\mathrm{u}$', fontsize=10)\n", + "plt.gca().fill_between(model[:, 0], 0, model[:, -2], color=green)\n", + "plt.gca().fill_between(model[:, 0], model[:, -2], model[:, -1], color=grey)\n", + "plt.annotate('$\\phi_\\mathrm{tot}$', (1, 0.5), (1.5,0.5), fontsize=10)\n", + "save_nice_fig(fol+'Fig2/snap_shot_late.pdf')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# l_fit = plt.plot(model[:, 0], model[:, -2], '-', lw=1,\n", + "# c=dark_grey, label='Simulation')\n", + "plt.plot(model[:, 0], model[:, -1], 'k', lw=2)\n", + "nice_fig('radial distance $r/R$', 'volume fraction $\\phi_\\mathrm{u}$', [0, 2],\n", + " [0,1], [2.3,2])\n", + "plt.title('$t=0.22 \\;R^2/D_\\mathrm{in}$')\n", + "plt.text(0.47, 0.4, '$\\phi_\\mathrm{u}$', fontsize=10)\n", + "plt.gca().fill_between(model[:, 0], 0, model[:, -1], color=green)\n", + "plt.annotate('$\\phi_\\mathrm{tot}$', (1, 0.5), (1.5,0.5), fontsize=10)\n", + "save_nice_fig(fol+'Fig2/snap_shot_before.pdf')" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -569,6 +708,25 @@ "**Panel: data time course with full model.**" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "CMD = np.loadtxt(fol+'Fig4/CMD_timecourse.csv', delimiter=',')\n", + "CMD_fit = np.loadtxt(fol+'Fig4/CMD_fit_timecourse.csv', delimiter=',')\n", + "l_data = plt.plot(CMD[:, 0], CMD[:, 1:], c=green, lw=2,\n", + " label='Experiment')\n", + "l_fit = plt.plot(CMD_fit[:, 0], CMD_fit[:, 1:], '-', lw=1,\n", + " c=dark_grey, label='Simulation')\n", + "nice_fig('radial distance $r$ [$\\mathrm{\\mu m}$]', 'intensity [a.u]',\n", + " [0, 2.4*np.max(CMD[:, 0])], [0,0.5], [2.3,2])\n", + "plt.legend([l_data[0], l_fit[0]], ['CMD/PLYS', 'Full model'], frameon=False,\n", + " fontsize=9, handletextpad=0.4, handlelength=0.8, loc=(0.52, 0.7))\n", + "save_nice_fig(fol+'Fig4/CMD_spat_recov_new.pdf')" + ] + }, { "cell_type": "code", "execution_count": null, @@ -577,15 +735,58 @@ "source": [ "PLYS = np.loadtxt(fol+'Fig4/PLYS_timecourse.csv', delimiter=',')\n", "PLYS_fit = np.loadtxt(fol+'Fig4/PLYS_fit_timecourse.csv', delimiter=',')\n", - "l_data = plt.plot(PLYS[:, 0], PLYS[:, 1:], c=blue, lw=2,\n", + "PLYS_t = np.loadtxt(fol+'Fig4/PLYS_fit_time.csv', delimiter=',')\n", + "l_data = plt.plot(PLYS[:, 0], PLYS[:, 1::30], c=blue, lw=2)\n", + "l_fit = plt.plot(PLYS_fit[:, 0], PLYS_fit[:, 2::30], '-', lw=1,\n", + " c=dark_grey, label='Simulation') # time course\n", + "l_fit = plt.plot(PLYS_fit[:, 0], PLYS_fit[:, 1], '-', lw=1,\n", + " c=dark_grey) # Initial condition\n", + "nice_fig('radial distance $r$ [$\\mathrm{\\mu m}$]', 'intensity [a.u]',\n", + " [0, 2.4*np.max(PLYS[:, 0])], [0,0.75], [2.3,2])\n", + "plt.legend([l_data[0], l_fit[0]], ['ATP/PLYS', 'Full model'], frameon=False,\n", + " fontsize=9, handletextpad=0.4, handlelength=0.8, loc=(0.52, 0.7))\n", + "# save_nice_fig(fol+'Fig4/PLYS_spat_recov_new.pdf')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for i in range(np.shape(PLYS)[1]):\n", + " l_data = plt.plot(PLYS[:, 0], PLYS[:, 1+i], c=blue, lw=2)\n", + " l_fit = plt.plot(PLYS_fit[:, 0], PLYS_fit[:, 2+i], '-', lw=1,\n", + " c=dark_grey, label='Simulation') # time course\n", + " nice_fig('radial distance $r$ [$\\mathrm{\\mu m}$]', 'intensity [a.u]',\n", + " [0, 2.4*np.max(PLYS[:, 0])], [0,0.9], [2.3,2.005])\n", + " plt.legend([l_data[0], l_fit[0]], ['ATP/PLYS', 'Full model'], frameon=False,\n", + " fontsize=9, handletextpad=0.4, handlelength=0.8, loc=(0.52, 0.7))\n", + " t = str(np.round(PLYS_t[i+1], 2))\n", + " plt.text(0.5, 0.785, t.ljust(4, '0') + ' s')\n", + " save_nice_fig(fol+'Fig4/PLYSATP_mov/PLYS_spat_recov_mov_'+str(i)+'.png', form='png')\n", + " plt.show();" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "PGL = np.loadtxt(fol+'Fig4/PGL_timecourse.csv', delimiter=',')\n", + "PGL_fit = np.loadtxt(fol+'Fig4/PGL_fit_timecourse.csv', delimiter=',')\n", + "l_data = plt.plot(PGL[:, 0], PGL[:, 1::4], c=red, lw=2,\n", " label='Experiment')\n", - "l_fit = plt.plot(PLYS_fit[:, 0], PLYS_fit[:, 1:], '-', lw=1,\n", + "l_fit = plt.plot(PGL_fit[:, 0], PGL_fit[:, 2::4], '-', lw=1,\n", " c=dark_grey, label='Simulation')\n", - "nice_fig('radial distance $r$ [$\\mathrm{\\mu m}$]', 'intensity (a.u)', [0, 2.4*np.max(PLYS[:, 0])],\n", - " [0,0.7], [2.3,2])\n", - "plt.legend([l_data[0], l_fit[0]], ['ATP/PLYS', 'Full model'], frameon=False,\n", - " fontsize=9, handletextpad=0.4, handlelength=0.8)\n", - "save_nice_fig(fol+'Fig4/PLYS_spat_recov_new.pdf')" + "plt.plot(PGL_fit[:, 0], PGL_fit[: 1], '-', lw=1, c=dark_grey)\n", + "nice_fig('radial distance $r$ [$\\mathrm{\\mu m}$]', 'intensity (a.u)',\n", + " [0, 2.5*np.max(PGL[:, 0])], [0,0.65], [2.3,2])\n", + "plt.legend([l_data[0], l_fit[0]], ['PGL', 'Full model'],\n", + " frameon=False, fontsize=9, handletextpad=0.4,\n", + " handlelength=0.8, loc=(0.54, 0.7))\n", + "save_nice_fig(fol+'Fig4/PGL_spat_recov.pdf')" ] }, { @@ -615,14 +816,19 @@ "plt.sca(ax1)\n", "sns.lineplot(x=\"P\", y=\"D_out\", data=CMD, color=green, ci='sd')\n", "sns.lineplot(x=\"P\", y=\"D_out\", data=PLYS, color=blue, ci='sd')\n", - "plt.plot(np.logspace(1, 2, 10), 2*np.logspace(1, 2, 10), '--', c='grey')\n", + "plt.plot(np.logspace(1, 3, 10), 1.5*np.logspace(1, 3, 10), '--', c='grey', alpha=0.5)\n", + "# plt.plot(np.logspace(0, 2, 10), 0.2*np.logspace(0, 2, 10)**2, '--', c='grey')\n", "ax1.set_yscale('log')\n", "ax1.set_xscale('log')\n", - "nice_fig('Partition coefficient $P$', '$D_\\mathrm{out} \\;[\\mathrm{\\mu m^2s^{-1}}]$', [1,100], [0.1,100], [2.3,2])\n", - "plt.legend(['CMD/PLYS', 'PLYS/ATP'], frameon=False, fontsize=9, loc=(0.48,0.))\n", - "plt.text(1.02, 1.7, '$D_\\mathrm{in, PLYS}$')\n", - "plt.text(1.02, 6, '$D_\\mathrm{in, CMD}$')\n", + "nice_fig('Partition coefficient $P$', '$D_\\mathrm{out} \\;[\\mathrm{\\mu m^2s^{-1}}]$',\n", + " [1,340], [0.08,450], [2.3,2])\n", + "plt.legend(['CMD/PLYS', 'ATP/PLYS'], frameon=False, fontsize=9, loc=(0.44,0.05))\n", + "plt.text(1.1, 2, '$D_\\mathrm{in, P/A}$', color=blue)\n", + "plt.text(1.1, 7, '$D_\\mathrm{in, C/P}$', color=green)\n", + "# plt.plot([1, 9], [1.7, 1.7], '--', color=blue)\n", + "# plt.plot([1, 12], [6, 6], '--', color=green)\n", "plt.xticks([1, 10, 100]);\n", + "plt.yticks([0.1, 1, 10, 100]);\n", "save_nice_fig(fol+'Fig4/PLYS_CMD.pdf')" ] }, @@ -658,31 +864,92 @@ "fig, ax1 = plt.subplots()\n", "plt.sca(ax1)\n", "temp = sns.color_palette()\n", - "sns.set_palette(sns.color_palette(\"Oranges\", 9))\n", - "l50 = sns.lineplot(x=\"P\", y=\"D_out\", data=PGL_50, color=sns.color_palette()[1], ci=None)\n", - "l60 = sns.lineplot(x=\"P\", y=\"D_out\", data=PGL_60, color=sns.color_palette()[2], ci=None)\n", - "l75 = sns.lineplot(x=\"P\", y=\"D_out\", data=PGL_75, color=sns.color_palette()[3], ci=None)\n", - "l90 = sns.lineplot(x=\"P\", y=\"D_out\", data=PGL_90, color=sns.color_palette()[4], ci=None)\n", - "leg1 = plt.legend(['50 mM', '60 mM', '75 mM', '90 mM'], labelspacing=0.3,\n", - " loc=(0.65, 0.0), handletextpad=0.4, handlelength=0.5, frameon=0)\n", - "l100 = sns.lineplot(x=\"P\", y=\"D_out\", data=PGL_100, color=sns.color_palette()[5], ci=None)\n", - "l120 = sns.lineplot(x=\"P\", y=\"D_out\", data=PGL_120, color=sns.color_palette()[6], ci=None)\n", - "l150 = sns.lineplot(x=\"P\", y=\"D_out\", data=PGL_150, color=sns.color_palette()[7], ci=None)\n", - "l180 = sns.lineplot(x=\"P\", y=\"D_out\", data=PGL_180, color=sns.color_palette()[8], ci=None)\n", - "plt.plot(np.logspace(0, 3, 10), 0.07*np.logspace(0, 3, 10), '--', c='grey')\n", + "sns.set_palette(sns.color_palette(\"rocket\", 9))\n", + "l50 = sns.lineplot(x=\"P\", y=\"D_out\", data=PGL_50,\n", + " color=sns.color_palette()[1], ci=None)\n", + "l60 = sns.lineplot(x=\"P\", y=\"D_out\", data=PGL_60,\n", + " color=sns.color_palette()[2], ci=None)\n", + "l75 = sns.lineplot(x=\"P\", y=\"D_out\", data=PGL_75,\n", + " color=sns.color_palette()[3], ci=None)\n", + "l90 = sns.lineplot(x=\"P\", y=\"D_out\", data=PGL_90,\n", + " color=sns.color_palette()[4], ci=None)\n", + "l100 = sns.lineplot(x=\"P\", y=\"D_out\", data=PGL_100,\n", + " color=sns.color_palette()[5], ci=None)\n", + "leg1 = plt.legend(['50 mM', '60 mM', '75 mM', '90 mM', '100 mM'],\n", + " labelspacing=0.3, loc=(0.63, 0.0),\n", + " handletextpad=0.4, handlelength=0.5, frameon=0)\n", + "\n", + "l120 = sns.lineplot(x=\"P\", y=\"D_out\", data=PGL_120,\n", + " color=sns.color_palette()[6], ci=None)\n", + "l150 = sns.lineplot(x=\"P\", y=\"D_out\", data=PGL_150,\n", + " color=sns.color_palette()[7], ci=None)\n", + "l180 = sns.lineplot(x=\"P\", y=\"D_out\", data=PGL_180,\n", + " color=sns.color_palette()[8], ci=None)\n", + "plt.plot(np.logspace(0, 4, 10), 0.07*np.logspace(0, 4, 10),\n", + " '--', c='grey', alpha=0.5)\n", "# plt.plot(np.logspace(2, 3, 10), 30*np.ones(10), '--', c='m', lw=2)\n", "ax1.set_yscale('log')\n", "ax1.set_xscale('log')\n", - "nice_fig('Partition coefficient $P$', '$D_\\mathrm{out} \\;[\\mathrm{\\mu m^2 s^{-1}}]$', [1,1000], [0.0003,200], [2.3,2])\n", - "plt.xticks([1, 10, 100, 1000]);\n", + "nice_fig('Partition coefficient $P$',\n", + " '$D_\\mathrm{out} \\;[\\mathrm{\\mu m^2 s^{-1}}]$',\n", + " [1,10000], [0.0003,600], [2.3,2])\n", + "plt.xticks([1, 10, 100, 1000, 10000]);\n", "plt.legend(loc=1)\n", - "plt.legend(['50 mM', '60 mM', '75 mM', '90 mM', '100 mM', '120 mM', '150 mM', '180 mM'], labelspacing=0.3,\n", - " loc=(0, 0.56), handletextpad=0.4, handlelength=0.5, frameon=0)\n", + "plt.legend(['50 mM', '60 mM', '75 mM', '90 mM', '100 mM',\n", + " '120 mM', '150 mM', '180 mM'], labelspacing=0.3,\n", + " loc=(0, 0.66), handletextpad=0.4, handlelength=0.5, frameon=0)\n", "plt.gca().add_artist(leg1)\n", - "save_nice_fig(fol+'Fig4/PGL-3.pdf')\n", + "# plt.plot([700, 10000], [30, 30], color=(1, 0, 0))\n", + "# plt.plot([700, 10000], [70, 70], color=(1, 0, 0))\n", + "# plt.plot([700, 700], [30, 70], color=(1, 0, 0))\n", + "# plt.plot([10000, 10000], [30, 70], color=(1, 0, 0))\n", + "# save_nice_fig(fol+'Fig4/PGL-3.pdf')\n", "sns.set_palette(temp)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "le_egfp = 239\n", + "le_pgl3 = 693\n", + "ratio = le_egfp/(le_egfp+le_pgl3)\n", + "D_factor = np.sqrt(ratio)\n", + "D_GFPw = 87 # micron^2/s, Arrio-Dupont et al. 2000 BJ, GFP in water\n", + "D = D_GFPw*np.sqrt(ratio)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "P = PGL_50['P']\n", + "def i_P(df, Pa):\n", + " return interp1d(np.array(df.groupby('P').mean()).flatten(),\n", + " P.unique(), bounds_error=False,\n", + " fill_value=\"extrapolate\")(Pa)\n", + "Ps_15 = [i_P(PGL, 30) for PGL in [PGL_50, PGL_60, PGL_75, PGL_90,\n", + " PGL_100, PGL_120, PGL_150, PGL_180]]\n", + "Ps_30 = [i_P(PGL, 60) for PGL in [PGL_50, PGL_60, PGL_75, PGL_90,\n", + " PGL_100, PGL_120, PGL_150, PGL_180]]\n", + "salts = [50, 60, 75, 90, 100, 120, 150, 180]\n", + "nice_fig('$c_\\mathrm{salt} \\; [\\mathrm{mM}]$', 'Partition coefficient $P$',\n", + " [50, 180], [0,20000], [2.3,2])\n", + "plt.plot(salts, Ps_15, color=red)\n", + "plt.plot(salts, Ps_30, color=red)\n", + "plt.gca().fill_between(salts, Ps_15, Ps_30, color=red, alpha=0.2)\n", + "plt.yticks(rotation=45)\n", + "plt.text(110, 6200, '$D_\\mathrm{out}=30\\;\\mathrm{\\mu m^2/s}$',\n", + " color=red, size=8)\n", + "plt.text(54, 700, '$D_\\mathrm{out}=15\\;\\mathrm{\\mu m^2/s}$',\n", + " color=red, size=8)\n", + "# save_nice_fig(fol+'Fig4/PGL-3_part.pdf')" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -703,7 +970,10 @@ "metadata": {}, "outputs": [], "source": [ - "P_Do = np.loadtxt(fol+'/Fig4/Part_vs_Do.csv', delimiter=',')\n", + "sns.set_palette(sns.color_palette(\"Set2\"))\n", + "P_Do = np.loadtxt(fol+'/Fig4/Part_vs_Do_220121.csv', delimiter=',')\n", + "sns.set_style(\"white\")\n", + "sns.set_palette([sns.color_palette()[i] for i in [3, 0, 1, 2]])\n", "P = [5, 150, 5, 150]\n", "D_o = [0.1, 0.1, 1, 1]\n", "plt.gca().set_prop_cycle(None)\n", @@ -737,17 +1007,31 @@ "metadata": {}, "outputs": [], "source": [ - "P_Cost = np.loadtxt(fol+'/Fig4/Part_vs_Cost.csv', delimiter=',')\n", - "nice_fig('Partition coefficient $P$', 'Cost function [a.u.]', [0.9,320], [0.000000001,0.01], [2.3,2])\n", + "P_Cost = np.loadtxt(fol+'/Fig4/Part_vs_Cost_220121.csv', delimiter=',')\n", + "nice_fig('Partition coefficient $P$', '$Cost_\\mathrm{min} (P)$ [a.u.]', [0.9,320], [0.000000001,0.01], [2.3,2])\n", "lines = plt.loglog(P_Cost[0, :], P_Cost[1:, :].transpose())\n", - "plt.legend([lines[2], lines[0], lines[3], lines[1]],\n", - " ['0.2', '0.02', '0.0067', '0.00067'], ncol=2, frameon=False,\n", - " title=r'$D_\\mathrm{out}$/P set to:', columnspacing=0.5, labelspacing=0.3,\n", - " loc=(0.081, 0), handletextpad=0.4, handlelength=0.5)\n", + "# plt.legend([lines[2], lines[0], lines[3], lines[1]],\n", + "# ['0.2', '0.02', '0.0067', '0.00067'], ncol=2, frameon=False,\n", + "# title=r'$D_\\mathrm{out}$/P set to:', columnspacing=0.5, labelspacing=0.3,\n", + "# loc=(0.081, 0), handletextpad=0.4, handlelength=0.5)\n", "plt.xticks([1, 10, 100]);\n", "save_nice_fig(fol+'Fig4/D_vs_Cost.pdf')" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "P_Cost = np.loadtxt(fol+'/Fig4/Part_vs_Cost_220121.csv', delimiter=',')\n", + "nice_fig('Partition coefficient $P$', '$Cost_\\mathrm{min} (P)$ [a.u.]', [0.9,100], [0,2], [2.3,2])\n", + "lines = plt.plot(P_Cost[0], P_Cost[1:].transpose()/[x[0] for x in P_Cost[1:]])\n", + "plt.gca().set_xscale('log')\n", + "plt.plot([150, 150], [0, 1], '--', lw=2, c=grey)\n", + "save_nice_fig(fol+'Fig4/D_vs_Cost_single.pdf')" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -761,12 +1045,13 @@ "metadata": {}, "outputs": [], "source": [ - "con = np.loadtxt(fol+'Fig4/Valley.csv', delimiter=',')\n", - "levels = MaxNLocator(nbins=15).tick_values(np.log10(con[:, 2:].min()), np.log10(con[:, 2:].max()))\n", - "nice_fig('Partition coefficient $P$', '$D_\\mathrm{out} \\;[\\mu m^2 s^{-1}]$', [1, 3], [-2,1], [2.3,2])\n", + "con = np.loadtxt(fol+'Fig4/Valley_220121.csv', delimiter=',')\n", + "levels = MaxNLocator(nbins=100).tick_values(np.log10(con[:, 2:].min()), np.log10(con[:, 2:].max()))\n", + "nice_fig('Partition coefficient $P$', '$D_\\mathrm{out} \\;[\\mathrm{\\mu m^2 s^{-1}}]$', [1, 3], [-2,1], [2.3,2])\n", "CS = plt.contourf(np.log10(con[:, 0]), np.log10(con[:, 1]), np.log10(con[:, 2:]), levels=levels, cmap=cm.coolwarm)\n", - "plt.plot(np.log10(150), np.log10(10**-1), 'y*', label='Initial Simul.', markersize=6)\n", + "plt.plot(np.log10(150), np.log10(10**-1), 'd', c=sns.color_palette()[1], label='Initial Simul.', markersize=6)\n", "le = plt.legend(loc=(0, 0.83), frameon=False, handletextpad=0.4)\n", + "# plt.plot(np.log10(P_Do[0, :]), np.log10(P_Do[2, :].transpose()), '--', c=green, lw = 1)\n", "le.get_texts()[0].set_color('white')\n", "plt.xticks([1, 2, 3], ['$10^1$', '$10^2$', '$10^3$'])\n", "plt.yticks([-2, -1, 0, 1], ['$10^{-2}$', '$10^{-1}$', '$10^0$', '$10^1$'])\n", @@ -790,12 +1075,12 @@ "metadata": {}, "outputs": [], "source": [ - "levels = MaxNLocator(nbins=15).tick_values(np.log10(con[:, 2:].min()), np.log10(con[:, 2:].max()))\n", + "# levels = MaxNLocator(nbins=15).tick_values(np.log10(con[:, 2:].min()), np.log10(con[:, 2:].max()))\n", "nice_fig('Partition coefficient $P$', '', [1.9, 2.4], [-1.5,-0.5], [2.3,2])\n", "CS = plt.contourf(np.log10(con[16:-27, 0]), np.log10(con[16:-27, 1]),\n", " np.log10(con[16:-27, 2+16:-27]), levels=levels,\n", " cmap=cm.coolwarm, vmax=-1.5)\n", - "plt.plot(np.log10(150), np.log10(10**-1), 'y*', label='Initial Simul.', markersize=6)\n", + "plt.plot(np.log10(150), np.log10(10**-1), 'd', c=sns.color_palette()[1], label='Initial Simul.', markersize=6)\n", "le = plt.legend(loc=(0, 0.83), frameon=False, handletextpad=0.4)\n", "le.get_texts()[0].set_color('white')\n", "plt.xticks([2, 2.25], ['$10^2$', '$10^{2.25}$'])\n", @@ -804,7 +1089,30 @@ "fig1 = plt.gcf()\n", "clb = fig1.colorbar(CS, ticks=[-2, -4, -6])\n", "clb.ax.set_title('Cost')\n", - "save_nice_fig(fol+'Fig4/Sim_D_out_P_inset.pdf')" + "# save_nice_fig(fol+'Fig4/Sim_D_out_P_inset.pdf')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "con_fine = np.loadtxt(fol+'Fig4/Valley_fine_210121.csv', delimiter=',')\n", + "# nice_fig('Partition coefficient $P$', '', [2.172, 2.1795], [-1.005,-0.9955], [2.3,2])\n", + "P = np.log10(con_fine[:,0])\n", + "D_o = np.log10(con_fine[:,1])\n", + "fval = np.log10(con_fine[:,2])\n", + "# levels = np.linspace(-fval.max(), -fval.min(), 100)\n", + "levels = MaxNLocator(nbins=50).tick_values(fval.min(), fval.max())\n", + "plt.plot(np.log10(150), np.log10(10**-1), 'd', c=sns.color_palette()[1], label='Initial Simul.', markersize=6)\n", + "cs = plt.tricontourf(P, D_o, -fval, levels=np.flip(-levels))\n", + "plt.yticks([-1.005, -1, -0.996], ['$10^{-1.005}$', '$10^{-1}$', '$10^{-0.996}$'], rotation=30)\n", + "plt.xticks([2.173, 2.178], ['$10^{2.173}$', '$10^{2.178}$'])\n", + "plt.tick_params(axis='x',direction='out', which='minor', length=10)\n", + "fig1 = plt.gcf()\n", + "clb = fig1.colorbar(cs, ticks=[5, 7, 9, 11])\n", + "clb.ax.set_title('Cost')" ] }, {