bax_bgsub = subtract_background(bax_only_set, buffer_background) # Fret efficiency fret_means = np.zeros(len(bax_lipos_names)) conc_list = np.zeros(len(bax_lipos_names)) fret_sds = np.zeros(len(bax_lipos_names)) for i, cond_name in enumerate(bax_lipos_names): conc_list[i] = float(cond_name.split(' ')[1]) f_da = np.mean(bax_lipos_bgsub[cond_name][VALUE]) f_da_sd = np.std(bax_lipos_bgsub[cond_name][VALUE], ddof=1) f_d = np.mean(bax_bgsub[bax_only_names[i]][VALUE]) f_d_sd = np.std(bax_bgsub[bax_only_names[i]][VALUE], ddof=1) fret_means[i] = fret = 1 - (f_da / f_d) fret_sds[i] = error_propagation.calc_ratio_sd(f_da, f_da_sd, f_d, f_d_sd) def plot_data(): def myfig(): figure(figsize=(9, 6)) myfig() plot_all(timecourse_wells) title("Raw timecourses") myfig() plot_all(timecourse_averages, errors=timecourse_stds) title("Raw timecourses, averaged") if __name__ == '__main__':
color='b', label='Alexa 488 Bax') plot(np.log10(conc_list), np.log10(bax_lipos_means), marker='o', color='r', label='Alexa 488 Bax + Rho-PE liposomes') xlabel('log10([Bax])') ylabel('log10(RFU)') title('Steady-state fluorescence vs. [Bax]') legend(loc='lower right') # Fret by comparison with controls figure() fret = 1 - (bax_lipos_means / bax_only_means) num_pts = len(bax_lipos_means) ratio_sds = np.zeros(num_pts) for i in range(num_pts): ratio_sds[i] = error_propagation.calc_ratio_sd( bax_lipos_means[i], bax_lipos_sds[i], bax_only_means[i], bax_only_sds[i]) # Log scale figure() errorbar(np.log10(conc_list), fret, yerr=ratio_sds, color='r') #plot(np.log10(conc_list), hill(conc_list), color='g') #fit_concs = 10 ** np.linspace(-1, 3.5, 100) #plot(np.log10(fit_concs), quad(fit_concs), color='g') xlabel('log10([Bax]) (nM)') ylabel('$F_{D+A} / F_D$') title('Bax/liposome FRET, 30C, 20-60sec avg') # ----------------------------------- # FRET by comparison with expected F0 from fold-change fold_changes = [] for well_name in bax_only.trunc_wells.keys():
def plot_initial_rates(activator): plt.ion() #nbd_sites = ['WT', '15'] nbd_sites = ['WT', '3', '5', '15', '36', '47', '54', '62', '68', '79', '120', '122', '126', '138', '151', '175', '179', '184', '188'] replicates = range(1, 4) count = 0 num_pts = 4 fit_results =[] for nbd_index, nbd_site in enumerate(nbd_sites): rn_ratios = [] nr_ratios = [] r_maxs = [] n_maxs = [] rn_errs = [] nr_errs = [] r_errs = [] n_errs = [] for rep_index in replicates: rt = df[(activator, 'Release', nbd_site, rep_index, 'TIME')].values ry = df[(activator, 'Release', nbd_site, rep_index, 'VALUE')].values r_lin = scipy.stats.linregress(rt[0:num_pts], ry[0:num_pts]) r_int = r_lin[1] r_max = np.max(ry) r_slope = r_lin[0] r_maxs.append(r_slope) r_slope_err = r_lin[4] r_errs.append(r_slope_err) fit_results.append(FitResult(None, activator, nbd_site, rep_index, 'Tb release', 'Initial rate (first %d pts)' % num_pts, r_slope, r_slope_err)) if nbd_site == 'WT': n_maxs.append(0) n_errs.append(0) rn_ratios.append(0) rn_errs.append(0) nr_ratios.append(0) nr_errs.append(0) else: nt = df[(activator, 'NBD', nbd_site, rep_index, 'TIME')].values ny = df[(activator, 'NBD', nbd_site, rep_index, 'VALUE')].values # Fit line to first 10 pts n_lin = scipy.stats.linregress(nt[0:num_pts], ny[0:num_pts]) n_max = np.max(ny) n_int = n_lin[1] n_slope = n_lin[0] n_maxs.append(n_slope) n_slope_err = n_lin[4] n_errs.append(n_slope_err) rn_ratio = r_slope / n_slope rn_err = calc_ratio_sd(r_slope, r_slope_err, n_slope, n_slope_err) rn_ratios.append(rn_ratio) rn_errs.append(rn_err) nr_ratio = n_slope / r_slope nr_err = calc_ratio_sd(n_slope, n_slope_err, r_slope, r_slope_err) nr_ratios.append(nr_ratio) nr_errs.append(nr_err) fit_results.append(FitResult(None, activator, nbd_site, rep_index, 'NBD', 'Initial rate (first %d pts)' % num_pts, n_slope, n_slope_err)) #print "%s, rep %d, Tb slope: %f" % (nbd_site, rep_index, r_slope) #print "%s, rep %d, NBD slope: %f" % (nbd_site, rep_index, n_slope) plt.figure('%s, NBD-%s-Bax initial rates' % (activator, nbd_site), figsize=(12, 5)) plt.subplot(1, 2, 1) plt.plot(rt[0:num_pts], ry[0:num_pts], linestyle='', marker='.', color=rep_colors[rep_index]) plt.plot(rt[0:num_pts], r_int + r_slope * rt[0:num_pts], color=rep_colors[rep_index], label='%s Rep %d' % (activator, rep_index)) plt.title('NBD-%s-Bax, Tb initial rate' % (nbd_site)) plt.legend(loc='lower right') if nbd_site != 'WT': plt.subplot(1, 2, 2) plt.plot(nt[0:num_pts], ny[0:num_pts], linestyle='', marker='.', color=rep_colors[rep_index]) plt.plot(nt[0:num_pts], n_int + n_slope * nt[0:num_pts], color=rep_colors[rep_index], label='%s Rep %d' % (activator, rep_index)) plt.xlabel('Time (sec)') plt.ylabel('$F/F_0$') plt.title('NBD-%s-Bax, NBD initial rate' % (nbd_site)) plt.legend(loc='lower right') # NBD/Tb ratio plt.figure("NBD/Tb initial rate ratio", figsize=(12,6)) plt.title("NBD/Tb initial rate ratio") plt.ylim((-0.08, 0.58)) if activator == 'Bid': plt.bar(range(nbd_index*7, (nbd_index*7) + 3), nr_ratios, width=1, color='r', ecolor='k', yerr=nr_errs) else: plt.bar(range(nbd_index*7+3, (nbd_index*7) + 6), nr_ratios, width=1, color='g', ecolor='k', yerr=nr_errs) # Tb/NBD ratio plt.figure("Tb/NBD initial rate ratio", figsize=(12,6)) plt.title("Tb/NBD initial rate ratio") plt.ylim((-100, 120)) if activator == 'Bid': plt.bar(range(nbd_index*7, (nbd_index*7) + 3), rn_ratios, width=1, color='r', ecolor='k', yerr=rn_errs) else: plt.bar(range(nbd_index*7+3, (nbd_index*7) + 6), rn_ratios, width=1, color='g', ecolor='k', yerr=rn_errs) # Tb initial rate plt.figure("Tb initial rate", figsize=(12, 6)) plt.title('Tb initial rate') if activator == 'Bid': plt.bar(range(nbd_index*7, (nbd_index*7) + 3), r_maxs, width=1, color='r', ecolor='k', yerr=r_errs) else: plt.bar(range(nbd_index*7+3, (nbd_index*7) + 6), r_maxs, width=1, color='g', ecolor='k', yerr=r_errs) # NBD initial rate plt.figure("NBD initial rate", figsize=(12, 6)) plt.title('NBD initial rate') if activator == 'Bid': plt.bar(range(nbd_index*7, (nbd_index*7) + 3), n_maxs, width=1, color='r', ecolor='k', yerr=n_errs) else: plt.bar(range(nbd_index*7+3, (nbd_index*7) + 6), n_maxs, width=1, color='g', ecolor='k', yerr=n_errs) num_sites = len(nbd_sites) fig_names = ["NBD/Tb initial rate ratio", "Tb/NBD initial rate ratio", "Tb initial rate", "NBD initial rate"] for fig_name in fig_names: plt.figure(fig_name) ax = plt.gca() ax.set_xticks(np.arange(3, 3 + num_sites * 7, 7)) ax.set_xticklabels(nbd_sites) return fit_results