Esempio n. 1
0
def plot_effect_of_pore_reverse_rate():
    ci = color_iter()

    pore_reverse_rates = [1e-2, 1e-4, 1e-6]
    t = np.linspace(0, 5000, 500)
    plt.figure()

    for pore_reverse_rate in pore_reverse_rates:
        params_dict = {'Bax_0': 50., 'Vesicles_0': 50.,
                        'pore_reverse_rate_k': pore_reverse_rate}
        b = one_cpt.Builder(params_dict=params_dict)
        b.build_model_bax_schwarz_reversible()
        x = odesolve(b.model, t)
        avg_pores = x['pores']/b.model.parameters['Vesicles_0'].value
        col = ci.next()
        plt.plot(t, avg_pores, color=col, linestyle='-',
                 label="Pores, reverse rate %g" % pore_reverse_rate)
        plt.plot(t, 1 - np.exp(-avg_pores), color=col, linestyle='--',
                 label="Dye release, reverse rate %g" % pore_reverse_rate)

    plt.legend(loc='upper left')
    plt.xlabel('Time (sec)')
    plt.ylabel('Dye release/Avg. pores')
    plt.title('Dye release/pore formation with varying reverse rates')
    plt.show()
Esempio n. 2
0
def run_model_ode(tmax=12000):
    from pysb.integrate import odesolve
    t = np.linspace(0, tmax, 1000)
    x = odesolve(model, t)

    ci = color_iter()
    plt.figure(1)
    # Translocation
    plt.plot(t, (x['ctBid'])/tBid_0.value, label='ctBid', color=ci.next())
    plt.plot(t, (x['mtBid'])/tBid_0.value, label='mtBid', color=ci.next())
    plt.plot(t, (x['cBax'])/Bax_0.value, label='cBax', color=ci.next())
    plt.plot(t, (x['mBax'])/Bax_0.value, label='mBax', color=ci.next())
    plt.legend()
Esempio n. 3
0
    def run_model(self, tmax=12000, num_sims=1, use_kappa=True,
                  figure_ids=[0, 1]):
        xrecs = []   # The array to store the simulation data
        dr_all = []  # TODO: Delete this

        # Run multiple simulations and collect data
        for i in range(0, num_sims):
            # Run simulation using Kappa:
            if use_kappa:
                ssa_result = kappa.run_simulation(self.model, time=tmax,
                                                  points=100,
                                                  output_dir='simdata')
                xrecs.append(ssa_result)
            # Run simulation using BNG SSA implementation:
            else:
                ssa_result = bng.run_ssa(self.model, t_end=tmax, n_steps=100,
                                         cleanup=True)
                xrecs.append(ssa_result)
                #dr_all.append(get_dye_release(model, 'pores', ssa_result))

        # Convert the multiple simulations in an array...
        xall = array([x.tolist() for x in xrecs])

        # ...and calculate the Mean and SD across the simulations
        x_std = recarray(xrecs[0].shape, dtype=xrecs[0].dtype, buf=std(xall, 0))
        x_avg = recarray(xrecs[0].shape, dtype=xrecs[0].dtype,
                         buf=mean(xall, 0))

        # Plotting parameters, aliases
        ci = color_iter()
        marker = 'x'
        linestyle = '-'
        tBid_0 = self['tBid_0']
        Bax_0 = self['Bax_0']

        # Translocation: plot cyto/mito tBid, and cyto/mito Bax
        plt.ion()
        plt.figure(figure_ids[0])
        plt.errorbar(x_avg['time'], x_avg['ctBid']/tBid_0.value,
                 yerr=x_std['ctBid']/tBid_0.value,
                 color=ci.next(), marker=marker, linestyle=linestyle)
        plt.errorbar(x_avg['time'], x_avg['mtBid']/tBid_0.value,
                 yerr=x_std['mtBid']/tBid_0.value,
                 color=ci.next(), marker=marker, linestyle=linestyle)
        plt.errorbar(x_avg['time'], x_avg['cBax']/Bax_0.value,
                 yerr=x_std['cBax']/Bax_0.value,
                 color=ci.next(), marker=marker, linestyle=linestyle)
        plt.errorbar(x_avg['time'], x_avg['mBax']/Bax_0.value,
                 yerr=x_std['mBax']/Bax_0.value,
                 color=ci.next(), marker=marker, linestyle=linestyle)

        # Activation: plot iBax and tBidBax
        plt.errorbar(x_avg['time'], x_avg['iBax']/Bax_0.value,
                 yerr=x_std['iBax']/Bax_0.value, label='iBax',
                 color=ci.next(), marker=marker, linestyle=linestyle)
        plt.errorbar(x_avg['time'], x_avg['tBidBax']/tBid_0.value,
                 yerr=x_std['tBidBax']/tBid_0.value,
                 color=ci.next(), marker=marker, linestyle=linestyle)

        # Dye release calculated exactly ----------
        #dr_avg = mean(dr_all, 0)
        #dr_std = std(dr_all, 0)
        #errorbar(x_avg['time'], dr_avg,
        #         yerr=dr_std, label='dye_release',
        #         color=ci.next(), marker=marker, linestyle=linestyle)


        # Pore Formation
        #plot(x['time'], x['pBax']/Bax_0.value, label='pBax')
        #leg = legend()
        #ltext = leg.get_texts()
        #setp(ltext, fontsize='small')

        #xlabel("Time (seconds)")
        #ylabel("Normalized Concentration")

        #ci = color_iter()
        # Plot pores/vesicle in a new figure ------
        #figure(2)
        #errorbar(x_avg['time'], x_avg['pores'] / float(NUM_COMPARTMENTS),
        #         yerr=x_std['pores']/float(NUM_COMPARTMENTS), label='pores',
        #         color=ci.next(), marker=marker, linestyle=linestyle)

        #F_t = 1 - dr_avg
        #pores_poisson = -log(F_t)
        #plot(x_avg['time'], pores_poisson, color=ci.next(), label='-ln F(t),
        #     stoch',
        #        marker=marker, linestyle=linestyle)
        #xlabel("Time (seconds)")
        #ylabel("Pores/vesicle")
        #title("Pores/vesicle")
        #legend()

        #xlabel("Time (seconds)")
        #ylabel("Dye Release")
        #title("Dye release calculated via compartmental model")

        return xrecs[0]
Esempio n. 4
0
def plot_simulation(x_avg, x_std, dr_all, model, num_sims, figure_ids=[0, 1]):
    ci = color_iter()
    marker = ','
    linestyle = ''

    tBid_0 = model.parameters['tBid_0'].value
    Bax_0 = model.parameters['Bax_0'].value
    Vesicles_0 = model.parameters['Vesicles_0'].value

    # Translocation
    plt.figure(figure_ids[0])
    plt.errorbar(x_avg['time'], x_avg['ctBid']/tBid_0,
             yerr=(x_std['ctBid']/tBid_0)/np.sqrt(num_sims),
             label='ctBid',
             color=ci.next(), marker=marker, linestyle=linestyle)
    plt.errorbar(x_avg['time'], x_avg['mtBid']/tBid_0,
             yerr=(x_std['mtBid']/tBid_0)/np.sqrt(num_sims),
             label='mtBid',
             color=ci.next(), marker=marker, linestyle=linestyle)
    plt.errorbar(x_avg['time'], x_avg['cBax']/Bax_0,
             yerr=(x_std['cBax']/Bax_0)/np.sqrt(num_sims),
             label='cBax',
             color=ci.next(), marker=marker, linestyle=linestyle)
    plt.errorbar(x_avg['time'], x_avg['mBax']/Bax_0,
             yerr=(x_std['mBax']/Bax_0)/np.sqrt(num_sims),
             label='mBax',
             color=ci.next(), marker=marker, linestyle=linestyle)

    # Activation
    plt.errorbar(x_avg['time'], x_avg['iBax']/Bax_0,
                 yerr=(x_std['iBax']/Bax_0)/np.sqrt(num_sims),
                 label='iBax', color=ci.next(), marker=marker,
                 linestyle=linestyle)
    plt.errorbar(x_avg['time'], x_avg['tBidBax']/tBid_0,
                 yerr=(x_std['tBidBax']/tBid_0)/np.sqrt(num_sims),
                 label='tBidBax', color=ci.next(), marker=marker,
                 linestyle=linestyle)

    # Pore Formation
    plt.errorbar(x_avg['time'], x_avg['pBax']/Bax_0,
                 yerr=(x_std['pBax']/Bax_0)/np.sqrt(num_sims),
                 color=ci.next(),
                 label='pBax', marker=marker, linestyle=linestyle)

    ci = color_iter()

    # Dye release calculated exactly ----------
    dr_avg = np.mean(dr_all, 0)
    dr_std = np.std(dr_all, 0)
    plt.errorbar(x_avg['time'], dr_avg,
                yerr=dr_std/np.sqrt(num_sims), label='dye_release',
                color=ci.next(), marker=marker, linestyle=linestyle)

    fontP = FontProperties()
    fontP.set_size = ('small')
    plt.legend(loc='upper center', prop=fontP, ncol=5,
               bbox_to_anchor=(0.5, 1.1), fancybox=True, shadow=True)
    plt.xlabel("Time (seconds)")
    plt.ylabel("Normalized Concentration")
    plt.show()

    # Plot pores/vesicle in a new figure ------
    ci = color_iter()
    plt.figure(figure_ids[1])
    plt.errorbar(x_avg['time'], x_avg['pores']/Vesicles_0,
                 yerr=(x_std['pores']/Vesicles_0)/np.sqrt(num_sims),
                 label='pores/ves', color=ci.next(), marker=marker,
                 linestyle=linestyle)
    plt.legend(loc='upper center', prop=fontP, ncol=1,
               bbox_to_anchor=(0.5, 1.1), fancybox=True, shadow=True)
    plt.show()
    #F_t = 1 - dr_avg
    #pores_poisson = -log(F_t)
    #plot(x_avg['time'], pores_poisson, color=ci.next(), label='-ln F(t),
    #     stoch', marker=marker, linestyle=linestyle)
    #xlabel("Time (seconds)")
    #ylabel("Pores/vesicle")
    #title("Pores/vesicle")
    #legend()

    #xlabel("Time (seconds)")
    #ylabel("Dye Release")
    #title("Dye release calculated via compartmental model")

    return