Antonino Ingargiola Update weights notebook and figures  about 8 years ago

Commit id: 938b679ebc4a8c36c80a3d92d6beb9fe32059e23

deletions | additions      

    Binary files a/figures/weight_fret_hist_measurement/weight_fret_hist_measurement.png and b/figures/weight_fret_hist_measurement/weight_fret_hist_measurement.png differ     Binary files a/figures/weight_fret_hist_sim_mixture/weight_fret_hist_sim_mixture.png and b/figures/weight_fret_hist_sim_mixture/weight_fret_hist_sim_mixture.png differ        

},  "outputs": [],  "source": [  "url "#url  = 'http://files.figshare.com/2182601/0023uLRpitc_NTP_20dT_0.5GndCl.hdf5'\n",  "download_file(url, 'http://files.figshare.com/4917046/smFRET_44f3da_P_20_s0_20_s20_D_6.0e11_6.0e11_E_75_30_EmTot_200k_200k_BgD1500_BgA800_t_max_600s.hdf5'\n",  "#download_file(url,  save_dir='./data')" ]  },  { 

},  "outputs": [],  "source": [  "filename "url  = './data/' + url.split('/')[-1]\n",  "filename"  ]  },  {  "cell_type": "code",  "execution_count": null,  "metadata": {  "collapsed": false  },  "outputs": [],  "source": [  "url2 = 'http://files.figshare.com/4861018/004_dsDNA_17d_green100u_red40u.hdf5'\n",  "download_file(url2, 'http://files.figshare.com/4917049/smFRET_44f3da_P_20_s0_20_s20_D_6.0e11_6.0e11_E_75_30_EmTot_160k_160k_BgD1500_BgA800_t_max_600s.hdf5'\n",  "download_file(url,  save_dir='./data')" ]  },  { 

},  "outputs": [],  "source": [  "filename2 = './data/' + url2.split('/')[-1]\n",  "filename2"  ]  },  {  "cell_type": "code",  "execution_count": null,  "metadata": {  "collapsed": true  },  "outputs": [],  "source": [  "dir_ = '/Users/anto/Google Drive/notebooks/pybromo/mixture_sim/data/'\n",  "filename = dir_ + 'smFRET_44f3da_P_20_s0_20_s20_D_6.0e-11_6.0e-11_E_75_30_EmTot_200k_200k_BgD1500_BgA800_t_max_600s.hdf5'\n",  "filename = dir_ + 'smFRET_44f3da_P_20_s0_20_s20_D_6.0e-11_6.0e-11_E_75_30_EmTot_160k_160k_BgD1500_BgA800_t_max_600s.hdf5'"  ]  },  {  "cell_type": "code",  "execution_count": null,  "metadata": {  "collapsed": true  },  "outputs": [],  "source": [  "dir_ = '/Users/anto/Google Drive/notebooks/multispot/8spot_paper/data/2012-11-26/'\n",  "filename2 = dir_ + '004_dsDNA_17d_green100u_red40u.hdf5'"  ]  },  {  "cell_type": "code",  "execution_count": null,  "metadata": {  "collapsed": true  },  "outputs": [],  "source": [  "dir_ = '/Users/anto/Google Drive/notebooks/multispot/8spot_paper/data/2012-11-26/'\n",  "filename3 = dir_ './data/'  + '008_dsDNA_22d_500pM_green100u_red40u.hdf5'"  ]  },  {  "cell_type": "markdown",  "metadata": {},  "source": [  "# Loading the Data"  ]  },  {  "cell_type": "markdown",  "metadata": {},  "source": [  "### Unweighted Estimator" url.split('/')[-1]\n",  "filename"  ]  },  { 

},  "outputs": [],  "source": [  "Eh "url2  = np.nanmean(EE, axis=1)\n",  "Eh.shape, np.nanmean(Eh), np.nanstd(Eh)*100\n",  "print('Unweighted E estimator')\n",  "print('Mean = %.5f Std.Dev. = %.4f %%' % (np.nanmean(Eh), np.nanstd(Eh)*100))"  ]  },  {  "cell_type": "markdown",  "metadata": {},  "source": [  "### Weighted Estimator" 'http://files.figshare.com/4916914/008_dsDNA_22d_500pM_green100u_red40u.hdf5'\n",  "download_file(url2, save_dir='./data')"  ]  },  { 

},  "outputs": [],  "source": [  "Ehw "filename2  = np.nansum(EE * nt, axis=1)/ np.nansum(nt, axis=1)\n",  "print('Weighted E estimator')\n",  "print('Mean = %.5f Std.Dev. = %.4f %%' % (np.nanmean(Ehw), np.nanstd(Ehw)*100))" './data/' + url2.split('/')[-1]\n",  "filename2"  ]  },  {  "cell_type": "markdown",  "metadata": {},  "source": [  "### Estimator distribution plots" "## Loading the Data"  ]  },  { 

"loader.alex_apply_period(d2)"  ]  },  {  "cell_type": "code",  "execution_count": null,  "metadata": {  "collapsed": false  },  "outputs": [],  "source": [  "d3 = loader.photon_hdf5(filename3)\n",  "loader.alex_apply_period(d3)"  ]  },  {  "cell_type": "markdown",  "metadata": {}, 

},  "outputs": [],  "source": [  "d.calc_bg(bg.exp_fit, time_s=20, time_s=40,  tail_min_us='auto', F_bg=1.7)\n", "d2.calc_bg(bg.exp_fit,time_s=20, tail_min_us='auto', F_bg=1.7)\n",  "d3.calc_bg(bg.exp_fit,  time_s=40, tail_min_us='auto', F_bg=1.7)" ]  },  { 

},  "outputs": [],  "source": [  "dplot(d2,timetrace_bg);\n",  "dplot(d3,  timetrace_bg);" ]  },  { 

"outputs": [],  "source": [  "fig, ax = default_figure()\n",  "kws = dict(hist_style='step', hist_plot_style=dict(alpha=1))\n", hist_plot_style=dict(alpha=1, drawstyle='steps-mid', marker=None))\n",  "dplot(ds, hist_fret, **kws, ax=ax)\n",  "dplot(ds, hist_fret, weights='size', ax=ax, **kws)\n",  "ax.set_title('');\n",  "sns.despine()\n",  "ax.grid(False)\n",  "ax.legend(['Unweighted', 'Weighted'],\n",  " bbox_to_anchor=(0.6, 1), 1.05),  loc=2, borderaxespad=0.)" borderaxespad=0.)\n",  "\n",  "savefig('weight_fret_hist_sim_mixture.png')"  ]  },  { 

},  "outputs": [],  "source": [  "d2.burst_search(F=4)\n",  "d3.burst_search(F=4)" "d2.burst_search(F=4)"  ]  },  { 

},  "outputs": [],  "source": [  "dd2 = bext.burst_search_and_gate(d2,F=4)\n",  "dd3 = bext.burst_search_and_gate(d3,  F=4)" ]  },  { 

},  "outputs": [],  "source": [  "d2t = dd2.select_bursts(select_bursts.time, time_s2=5000)\n", time_s2=600)\n",  "ds2 = d2t.select_bursts(select_bursts.size, th1=10)\n",  "ds2a = d2t.select_bursts(select_bursts.naa, th1=10)\n",  "ds2h "#ds2h  = d2t.select_bursts(select_bursts.size, th1=10)\n",  "ds2ha th1=20)\n",  "#ds2ha  = d2t.select_bursts(select_bursts.naa, th1=10)"  ]  },  {  "cell_type": "code",  "execution_count": null,  "metadata": {  "collapsed": false  },  "outputs": [],  "source": [  "kws = dict(hist_style='step', hist_plot_style=dict(alpha=1))\n",  "ax = dplot(ds2h, hist_fret, **kws)\n",  "dplot(ds2, hist_fret, weights='size', ax=ax, **kws)\n",  "dplot(ds2ha, hist_fret, **kws, ax=ax)\n",  "dplot(ds2a, hist_fret, weights='size', ax=ax, **kws)"  ]  },  {  "cell_type": "code",  "execution_count": null,  "metadata": {  "collapsed": false  },  "outputs": [],  "source": [  "d3t = dd3.select_bursts(select_bursts.time, time_s2=600)\n",  "ds3 = d3t.select_bursts(select_bursts.size, th1=10)\n",  "ds3a = d3t.select_bursts(select_bursts.naa, th1=10)\n",  "ds3h = d3t.select_bursts(select_bursts.size, th1=10)\n",  "ds3ha = d3t.select_bursts(select_bursts.naa, th1=10)" th1=20)"  ]  },  { 

},  "outputs": [],  "source": [  "alex_jointplot(ds3)" "alex_jointplot(ds2)"  ]  },  { 

"source": [  "# 600s, DCBS, F=4, size th1 = 10\n",  "kws = dict(hist_style='step', hist_plot_style=dict(alpha=1))\n",  "ax = dplot(ds3h, dplot(ds2,  hist_fret, **kws)\n", "dplot(ds3, "dplot(ds2,  hist_fret, weights='size', ax=ax, **kws)" ]  },  { 

"fig, ax = default_figure()\n",  "kws = dict(ax=ax, hist_style='step', \n",  " hist_plot_style=dict(alpha=1, linestyle='-', marker=None, drawstyle='steps-mid'))\n",  "dplot(ds3h, "dplot(ds2,  hist_fret, **kws)\n", "dplot(ds3, "dplot(ds2,  hist_fret, weights='size', **kws)\n", "sns.despine()\n",  "ax.set_title('')\n",  "ax.grid(False)\n",  "ax.legend(['Unweighted', 'Weighted']);" 'Weighted']);\n",  "\n",  "savefig('weight_fret_hist_measurement.png')"  ]  },  { 

"source": [  "bins = np.arange(-0.2, 1.2, 0.03)\n",  "kws = dict(bins=bins, normed=True)\n",  "counts, _ = np.histogram(ds3.E_, np.histogram(ds2.E_,  **kws)\n", "countsw, _ = np.histogram(ds3.E_, weights=ds3.burst_sizes()[0], np.histogram(ds2.E_, weights=ds2.burst_sizes()[0],  **kws)\n", "\n",  "bincenters = bins[:-1] + 0.5*(bins[1] - bins[0])\n",  "plt.plot(bincenters, counts)\n",