Example #1
0
def calc_pore_size_by_slope():
    (fmax_arr, k1_arr, k2_arr, conc_list) = \
           titration_fits.plot_two_exp_fits(bgsub_norm_wells, layout, plot=True)
    titration_fits.plot_fmax_curve(fmax_arr, conc_list)
    titration_fits.plot_k1_curve(k1_arr[:,1:], conc_list[1:])
    titration_fits.plot_k2_curve(k2_arr[:,1:], conc_list[1:])

    conc_lipos = 5.16

    fmax_means = np.mean(fmax_arr, axis=0)
    fmax_stds = np.std(fmax_arr, axis=0)
    ratios = conc_list / conc_lipos

    derivs = np.zeros(len(fmax_means)-1)
    deriv_sds = np.zeros(len(fmax_means)-1)
    for i in np.arange(1, len(fmax_means)):
        if i == 1:
            prev_mean = 0
            prev_sd = 0
        else:
            prev_mean = fmax_means[i-1]
            prev_sd = fmax_stds[i-1]

        fmax_diff = fmax_means[i] - prev_mean
        conc_diff = conc_list[i] - conc_list[i-1]
        derivs[i-1] = fmax_diff / float(conc_diff)
        deriv_sds[i-1] = np.sqrt(fmax_stds[i] ** 2 + prev_sd ** 2)
    plt.figure()
    #plt.errorbar(conc_list[1:], derivs, yerr=deriv_sds, marker='o', )
    plt.errorbar(conc_list[1:], derivs, marker='o', )
    plt.title('d[Fmax]/d[Bax]')

    # Fit with exp dist?
    exp_lambda = fitting.Parameter(1/20.)
    def exp_dist(x):
        return exp_lambda() * np.exp(-exp_lambda() * x)
    (residuals, result) = fitting.fit(exp_dist, [exp_lambda], derivs,
                                      conc_list[1:])
    plt.plot(conc_list[1:], exp_dist(conc_list[1:]), color='g')
    print "exp_lambda: %f" % exp_lambda()

    # Fit with exp decay
    exp_c0 = fitting.Parameter(0.005)
    exp_k = fitting.Parameter(1/50.)
    def exp_decay(x):
        return exp_c0() * np.exp(-exp_k() * x)
    (residuals, result) = fitting.fit(exp_decay, [exp_c0, exp_k],
                                      derivs, conc_list[1:])
    plt.plot(conc_list[1:], exp_decay(conc_list[1:]), color='r')
    print "exp_c0: %f" % exp_c0()
    print "exp_k: %f" % exp_k()
    # We want to estimate Bax per pore, or pores per Bax, if Bax
    # holes didn't exist. Basically we want to know the fraction release
    # we would get if the amount of Bax approached 0. In the case of
    # the exponential decay, this is the value of exp_c0.
    # We convert exp_c0 from % release to number of pores:
    # The derivative dfmax/dBax tells us how much more permeabilization we get
    # per Bax. At low concentrations, we get a certain amount of release
    # per Bax that is relatively unaffected by the Bax hole phenomenon.
    print "exp_c0 * conc_lipos: %f" % (exp_c0() * conc_lipos)
Example #2
0
def plot_normalized_by_fmax():
    (fmax_arr, k1_arr, k2_arr, conc_list) = \
          titration_fits.plot_two_exp_fits(bgsub_norm_wells, layout, plot=False)

    data = bgsub_norm_wells
    k1_arr = np.zeros((3, len(layout.keys())))
    conc_list = np.zeros(len(layout.keys()))

    plt.figure()
    for i, conc_str in enumerate(layout.keys()):
        # The list of wells for this concentration
        wells = layout[conc_str]
        well_conc = float(conc_str.split(' ')[1])
        conc_list[i] = well_conc

        if well_conc == 0.0:
            continue

        for j, well in enumerate(wells):
            well_data = data[well]
            time = np.array(well_data[TIME][:])
            y = np.array(well_data[VALUE][:])
            fmax = fmax_arr[j, i]
            norm_data = y / float(fmax)
            plt.plot(norm_data)
Example #3
0
def calc_pore_size_by_poisson():
    set_fig_params_for_publication()

    (fmax_arr, k1_arr, k2_arr, conc_list) = \
         titration_fits.plot_two_exp_fits(bgsub_norm_wells, layout, plot=False)

    conc_lipos = 2.8

    fmax_means = np.mean(fmax_arr, axis=0)
    fmax_stds = np.std(fmax_arr, axis=0)
    ratios = conc_list / conc_lipos
    isf_pore_sizes = []
    k_max = 20
    for i, ratio in enumerate(ratios):
        if i == 0:
            continue
        # Probability of permeabilization is
        # 1 - poisson.cdf(pore_size, ratio)
        pore_sizes = np.arange(1, k_max)
        probs = [1 - stats.poisson.cdf(pore_size, ratio)
                 for pore_size in pore_sizes]
        isf_pore_size = stats.poisson.isf(fmax_means[i], ratio) + 1
        isf_pore_sizes.append(isf_pore_size)

        #plt.figure()
        #plt.plot(pore_sizes, probs, marker='o')
        #plt.xlabel('Pore size')
        #plt.ylim([-0.05, 1.05])
        #plt.title('Ratio of %f, isf pore size: %f' % (ratio, isf_pore_size))
        #sd_lines = [fmax_means[i] + fmax_stds[i]*num_sds
        #            for num_sds in np.arange(-2, 3)]
        #plt.hlines(sd_lines, 0, k_max, color='r')

    # Plot min pore size vs. Bax, with linear fit
    fig = plt.figure(figsize=(1.5, 1.5), dpi=300)
    ax = fig.gca()
    ax.plot(ratios[1:], isf_pore_sizes, marker='o', markersize=2,
            linestyle='') # Skip the 0 Bax pt
    ax.set_xlabel('[Bax]/[Lipo]')
    ax.set_ylabel('Predicted pore size')
    ax.set_xscale('log')
    ax.set_yscale('log')
    lbound = 0.1
    ubound = 200
    ax.set_xlim(lbound, 1000)
    #ax.set_ylim(1, 200)
    lin_fit = stats.linregress(ratios[1:], isf_pore_sizes)
    slope = lin_fit[0]
    intercept = lin_fit[1]
    ax.plot(ratios[1:], slope*ratios[1:] + intercept, color='r')
    interp_range = np.linspace(lbound, ratios[1])
    ax.plot(interp_range, slope*interp_range + intercept, color='r',
            linestyle='--', dashes=(2, 2))
    ax.plot(interp_range, [slope*ratios[1] + intercept] * len(interp_range),
            color='r', linestyle='--', dashes=(2, 2))
    #ax.set_title('Slope %f, intercept %f' % (slope, intercept),
    #             fontsize=fontsize)
    fig.subplots_adjust(left=0.22, bottom=0.19)
    format_axis(ax)
Example #4
0
    figure()
    plot_all(reset_norm_subset, legend_position=0.7)
    title("Norm., Avg., Reset to t = 0")

    figure()
    plot_all(pores)
    title("Avg. pores per liposome")

if __name__ == '__main__':
    #plot_data()
    plt.ion()
    bax63_layout = extract(bax63_wells, layout)
    (fmax_arr, k1_arr, k2_arr, conc_list) = \
          titration_fits.plot_two_exp_fits(norm_wells, bax63_layout,
                                           num_reps=1, conc_str_index=4,
                                           plot=True)
    plt.figure()
    plt.semilogx(conc_list, fmax_arr[0], marker='o')
    plt.xlabel('[cBid] (nM)')
    plt.ylabel('$F_{max}$')

    plt.figure()
    plt.semilogx(conc_list, k1_arr[0], marker='o')
    plt.xlabel('[cBid] (nM)')
    plt.ylabel('$k_1$')

    plt.figure()
    plt.semilogx(conc_list, k2_arr[0], marker='o')
    plt.xlabel('[cBid] (nM)')
    plt.ylabel('$k_2$')
Example #5
0
def get_twoexp_fmax_arr():
    (fmax_arr, k1_arr, k2_arr, conc_list) = \
         titration_fits.plot_two_exp_fits(bgsub_norm_wells, layout, plot=False)
    return (fmax_arr, conc_list)
Example #6
0
    k_decay_sd = np.sqrt(cov_matrix[1, 1])
    bg_bg_sd = np.sqrt(cov_matrix[2, 2])
    """

def get_twoexp_fmax_arr():
    (fmax_arr, k1_arr, k2_arr, conc_list) = \
         titration_fits.plot_two_exp_fits(bgsub_norm_wells, layout, plot=False)
    return (fmax_arr, conc_list)

if __name__ == '__main__':
    plt.ion()
    plt.close('all')


    (fmax_arr, k1_arr, k2_arr, conc_list) = \
         titration_fits.plot_two_exp_fits(bgsub_norm_wells, layout, plot=False)
    plot_k_curves(fmax_arr, conc_list)

    calc_pore_size_by_poisson()

    sys.exit()

    (k1_arr, k2_arr, tau_arr, conc_list) = plot_pore_fits()
    plot_k_curves(k1_arr, conc_list)
    plot_k_curves(k2_arr, conc_list)
    plot_k_curves(tau_arr, conc_list)


    #plot_normalized_to_ref_curve()
    #plot_normalized_by_fmax()