y_label = None
x_label = None
y_label1 = 'Seed population size'
x_label1 = 'Number of Generations / Growth time (in units of td)'

for i0 in range(X0):
    par1 = par_set
    for temp in range(len(par1_vals[i0])):
        par1[par1_vals[i0][temp][0]] = par1_vals[i0][temp][1]
    temp = list([])
    temp.append(
        g.slope_vbvd_m(par1, par1['g1_thresh_std'],
                       par1['g2_std'] * par1['td']))
    temp.append(
        g.slope_vbvd_func(par1, par1['g1_thresh_std'],
                          par1['g2_std'] * par1['td']))
    for i1 in range(X4):
        fig = plt.figure(figsize=[20, 6])
        ind = 1
        for i2 in range(2):
            ax = plt.subplot(1, 4, ind)
            title_str = simtype[i2] + ' mean slope diff'
            temp1 = val[0][i0, :, :, i1, i2]
            ax = g.heat_map(temp1 - temp[i1],
                            num_s1,
                            num_gen1,
                            ax,
                            xlabel=x_label,
                            ylabel=y_label,
                            title=title_str)
            # ax = g.heat_map(temp1, num_s1, num_gen1, ax, xlabel=x_label, ylabel=y_label, title=title_str)
Пример #2
0
celltype = ['m', 'd', 'p']
fullcelltype = [' mothers', ' daughters', ' population']

# g1_vol_obs = []
# for i in range(3):
#     g1_vol_obs.append(np.empty([X0, X1, len(celltype)]))
for i0 in range(X0):
    par1[vals[0]] = pars[0][i0]
    for i1 in range(X1):
        par1[vals[1]] = pars[1][i1]
        for i2 in range(X2):
            par1[vals[2]] = pars[2][i2]
            slopes[i0, i1, i2, 0] = g.slope_vbvd_m(par1, 0.0,
                                                   par1['td'] * g2_std[i1])
            slopes[i0, i1, i2, 1] = g.slope_vbvd_func(par1, 0.0,
                                                      par1['td'] * g2_std[i1])

temp = 1
for i0 in range(len(models)):
    for temp in range(len(celltype) - 1):
        a = np.zeros((X0, X1))
        # print data[:, :, i0, :, 1, temp].shape
        a[:, :] = np.mean(data[:, :, i0, :, 1, temp], 2) - slopes[:, :, i0,
                                                                  temp]
        fig = heat_map(a,
                       g2_std,
                       cd,
                       lab,
                       fullcelltype[temp],
                       vmax=1.0,
                       model_name=str(models[i0]))
    u += -1

it = [cd, g1_std, g2_std, l_std, k_std]
list_it = ['CD', 'g1_thresh_std', 'g2_std', 'l_std', 'k_std']
w_ind = 5
w_frac_m = np.linspace(w_frac[w_ind], w_frac[-1], 40)
ind = [[5, 0, 3, 0, 0], [5, 1, 3, 0, 0], [5, 0, 3, 1, 0],
       [5, 0, 3, 0, 1]]  # stores the indices for the data to be plotted.
theory_slopes = np.empty([len(ind), len(w_frac_m)])

for i0 in range(len(ind)):
    for i1 in range(len(list_it)):
        par1[list_it[i1]] = it[i1][ind[i0][i1]]
    for i1 in range(len(w_frac_m)):
        par1['w_frac'] = w_frac_m[i1]
        theory_slopes[i0, i1] = g.slope_vbvd_func(par1, par1['g1_thresh_std'],
                                                  par1['g2_std'])
values = range(len(it) + 1)  # 2x since 2 models being compared
cmap = plt.get_cmap('gnuplot2')
cnorm = colors.Normalize(vmin=0, vmax=values[-1])
scalarmap = cmx.ScalarMappable(norm=cnorm, cmap=cmap)

fig = plt.figure(figsize=[8, 8])
for i0 in range(len(ind)):
    colorval = scalarmap.to_rgba(values[i0])
    plt.scatter(w_frac[w_ind:],
                obs[ind[i0][0], ind[i0][1], ind[i0][2], ind[i0][3], ind[i0][4],
                    w_ind:, 0, 1],
                label='sims' + ' $t_b$= ' + str(it[0][ind[i0][0]]) +
                ', $\sigma_i=$ ' + str(it[1][ind[i0][1]]) +
                ', $\sigma_{G2}/t_d=$ ' + str(it[2][ind[i0][2]]) +
                ', $\sigma_k/k=$ ' + str(it[3][ind[i0][3]]) +
                                 del c, c1, obs1, temp
                                 if par1['modeltype'] in [21, 22]:
                                     a[i0, i1, i2, i3, i4, i5, i6, i7, 0, 2] = 0.0
                                     # theory mothers
                                     a[i0, i1, i2, i3, i4, i5, i6, i7, 1, 2] = 0.0
                                 else:
                                     a[i0, i1, i2, i3, i4, i5, i6, i7, 0, 2] = g.slope_vbvd_m(par1,
                                                                                              par1['g1_thresh_std'] *
                                                                                              par1['K'] * par1['CD'],
                                                                                              par1['g2_std'] * par1[
                                                                                                  'td'])
                                     # theory mothers
                                     a[i0, i1, i2, i3, i4, i5, i6, i7, 1, 2] = g.slope_vbvd_func(par1,
                                                                                                 par1[
                                                                                                     'g1_thresh_std'] *
                                                                                                 par1['K'] * par1[
                                                                                                     'CD'],
                                                                                                 par1['g2_std'] *
                                                                                                 par1[
                                                                                                     'td'])
                                 # theory daughters
                                 # print rank, "time taken", time.clock()-tic
                                 # print a[i0, i1, i2, i3, i4, i5, i6, i7, 1, :]
                                 # exit()
         print 'I am {0} and I have done one range'.format(rank)
     del cd, g2_std, l_std, f  # delete the new variables
 # Now everyone has made part of the matrix. Send to one processor. Many ways to do this. Broadcast, sendrecv etc
 if rank != 0:
     comm.send(a, dest=0)
 if rank == 0:
     new_grid = np.zeros(np.shape(a))
     new_grid += a
# GENERATING MODEL PREDICTIONS
n = 1
g1_std_m = np.linspace(0.0, 0.25, 1 + n * (len(g1_std) - 1))
g2_std_m = np.linspace(0.0, 0.25, 1 + n * (len(g2_std) - 1))
cd_m = np.linspace(0.5, 1.0, 1 + n * (len(cd) - 1))
l_std_m = np.linspace(0.0, 0.2, 1 + n * (len(l_std) - 1))
k_std_m = np.linspace(0.0, 0.2, 1 + n * (len(k_std) - 1))

slopes = np.zeros(
    [len(g1_std_m),
     len(g2_std_m),
     len(cd_m),
     len(l_std_m),
     len(k_std_m), 2])
for h in range(len(g1_std_m)):
    par1['g1_thresh_std'] = g1_std_m[h]
    for i in range(len(cd_m)):
        par1['cd_m'] = cd_m[i]
        for j in range(len(l_std_m)):
            par1['l_std'] = l_std_m[j]
            for k in range(len(k_std_m)):
                par1['k_std'] = k_std_m[k]
                slopes[h, :, i, j, k,
                       0] = g.slope_vbvd_m(par1, par1['g1_thresh_std'],
                                           g2_std_m)
                slopes[h, :, i, j, k,
                       1] = g.slope_vbvd_func(par1, par1['g1_thresh_std'],
                                              g2_std_m)
np.save('model' + str(par1['modeltype']) + '_theory_gen_numsamp' + str(n),
        slopes)
Пример #6
0
            colorval = scalarmap.to_rgba(values[index])
            plt.plot(f,
                     obs[pars[0], pars[1], pars[2], pars[3], :, j, 0, k],
                     label=modeltype[j] + ' $\sigma_i$=' +
                     str(np.round(par1['g1_thresh_std'], 2)) +
                     ' $\sigma_{G2}$=' + str(np.round(par1['g2_std'], 2)) +
                     ' $\sigma_{\lambda}$=' + str(np.round(par1['l_std'], 2)),
                     color=colorval)
            # plt.plot(frac, slopes[i][j][0][k], color=colorval, marker="o")
            par1[
                'modeltype'] = 4  # print the model's predicted slope for each different condition
        print '$\sigma_i$=' + str(np.round(
            par1['g1_thresh_std'], 2)) + ' $\sigma_{G2}$=' + str(
                np.round(par1['g2_std'], 2)) + ' $\sigma_{\lambda}$=' + str(
                    np.round(par1['l_std'], 2))
        if k == 0:
            print celltype[k], g.slope_vbvd_func(par1, g1_std[pars[1]],
                                                 g2_std[pars[2]])
        if k == 1:
            print celltype[k], g.slope_vbvd_m(par1, g1_std[pars[1]],
                                              g2_std[pars[2]])
    plt.legend(loc=3)
    plt.title(fullcelltype[k] + ' Constant adder model CD=' +
              str(np.round(par1['CD'], 2)))
    plt.xlabel('Daughter volume fraction')
    plt.xlim(xmin=f[0] - 0.02, xmax=f[-1] + 0.02)
    plt.ylabel('$V_d$ vs. $V_b$ regression slope')
    fig.savefig('./modelfigs/model11_12_' + str(celltype[k]) + '2.eps',
                bbox_inches='tight',
                dpi=fig.dpi)
Пример #7
0
par1 = dict([('g1_std', 0.0), ('g2_std', 0.1), ('g1_thresh_std', 0.0),
             ('dt', 0.01), ('CD', cd), ('num_gen', 9), ('K', 10.0 / cd),
             ('td', 1.0), ('modeltype', 20), ('g1_delay', x), ('l_std', 0.2),
             ('d_std', 0.2), ('delta', 10.0)])

print par1

obs = g.single_par_meas2(par1)
i0 = 1
s_i = par1['g1_thresh_std']
s_cd = par1['g2_std'] * par1['td']
label = [
    'Slope', '<Vb>', '<VbVb>', '<Vd>', '<VdVb>', '<Wb>', '<WbWb>',
    'Fraction low conc'
]
obs1 = [g.slope_vbvd_func(par1, s_i, s_cd), g.vb_func(par1, s_i, s_cd), g.vbvb_func(par1, s_i, s_cd), \
        g.vd_func(par1, s_i, s_cd), g.vdvb_func(par1, s_i, s_cd), g.wb(par1, cell_no=i0), g.wbwb(par1, cell_no=i0)]
print "Daughters"
for j in range(obs.shape[0] - 1):
    print label[j], np.round(obs[j, i0], 3), np.round(obs1[j], 3)
print label[7], np.round(obs[7, i0], 3)
i0 = 0
print "Mothers"
sel = [1, 5, 6]
obs2 = [
    g.vb_m(par1, s_i, s_cd),
    g.wb(par1, cell_no=i0),
    g.wbwb(par1, cell_no=i0)
]
for j in range(len(sel)):
    print label[sel[j]], np.round(obs[sel[j], i0], 3), np.round(obs2[j], 3)
Пример #8
0
    par1['CD'] = cd[k]
    obs1, obs2, tg1, tg2 = g.single_par_meas5(par1)  # Obs1 are leaf cells, obs2 are entire tree cells
    slopes[0, :, k] = obs1[0, :]
    slopes[1, :, k] = obs2[0, :]
    obs3, tg3 = g.single_par_meas4(par1)
    tg[0][0].append(tg1[0])  # mothers data
    tg[0][1].append(tg2[0])
    tg[0][2].append(tg3[0])

    tg[1][0].append(tg1[1])  # daughters data
    tg[1][1].append(tg2[1])
    tg[1][2].append(tg3[1])

    slopes[2, :, k] = obs3[0, :]
    slopes[3, 0, k] = g.slope_vbvd_m(par1, par1['g1_thresh_std'], par1['g2_std'])
    slopes[3, 1, k] = g.slope_vbvd_func(par1, par1['g1_thresh_std'], par1['g2_std'])
    del tg1, tg2, tg3, obs1, obs2, obs3
#
np.save('symm_asymm_comp4', slopes)
np.save('symm_asymm_tgrow_data', tg)
labels = ['Discretized time leaf cells', 'Discretized time tree cells', 'Discrete generations', 'Theory']
celltype = ['Mothers', 'Daughters']


fig = plt.figure(figsize=[16, 7])
for i in range(2):
    plt.subplot(1, 2, i+1)
    for j in range(slopes.shape[0]):
        plt.plot(cd, slopes[j, i, :], label=labels[j])
    plt.xlabel('Budded period $CD/t_d$')
    plt.ylabel('$V_d$ vs $V_b$ slope')
Пример #9
0
# a = np.zeros((X, Y, Z, 6, 2, W))

labels = ['Discr time leaf', 'Discr time tree', 'Discr genr', 'Theory']
fullcelltype = ['Mothers', 'Daughters']
celltype = ['m', 'd']

slopes = np.zeros([len(cd_m), len(g1_std), len(g2_std_m), len(l_std), 2])
for k in range(len(cd_m)):
    par1['CD'] = cd_m[k]
    for i in range(len(g1_std_m)):
        par1['g1_thresh_std'] = g1_std_m[i]
        for j in range(len(l_std)):
            par1['l_std'] = l_std[j]
            slopes[k, i, :, j, 0] = g.slope_vbvd_m(par1, par1['g1_thresh_std'], g2_std_m)
            slopes[k, i, :, j, 1] = g.slope_vbvd_func(par1, par1['g1_thresh_std'], g2_std_m)

obs = np.load('discr_time_tester1_model'+str(par1['modeltype'])+'_K_1.npy')
for k in range(2):
    fig = plt.figure(figsize=[20, 20])
    for i in range(len(g1_std)):
        for j in range(len(g2_std)):
            ax = fig.add_subplot(len(g1_std), len(g2_std), j+1+i*len(g2_std))
            ax.set_title('$\sigma_{i}/\Delta=$' + str(np.round(g1_std[i], 2)) + ' $\sigma_{G2}=$' +
                         str(np.round(g2_std[j], 2)))
            for h in range(len(l_std[::2])):
                ax.plot(cd, obs[:, i, j, 0, k, 2*h], linewidth=4.0, label=' Simulation '+'$\sigma_{\lambda}=$' +
                                                                          str(np.round(l_std[2*h], 2)))
                ax.plot(cd_m, slopes[:, i, j, 2*h, k], label=labels[3]+'$\sigma_{\lambda}=$' +
                        str(np.round(l_std[2*h], 2)))
            if i == len(g1_std)-1: