# rr['Vm2'] = rr['Vm2']*v # # rr['Vm4'] = rr['Vm4']*v # # rr['Vm5'] = rr['Vm5']*v ## # rr['Vm6'] = rr['Vm6']*v rr['Vm7'] = rr['Vm7'] * v # rr['Vm8'] = rr['Vm8']*v mut_data = rr.simulate(0, sim_time, 5000) rows, cols = get_dims(len(model_nums)) #plt.subplot(rows, cols, i + 1) for col in sim_data.colnames[1:]: if i == 0: plt.plot(mut_data['time'], mut_data[col], color='C' + col[-1], label=str(num), linewidth=1) else: plt.plot(mut_data['time'], mut_data[col], color='C' + col[-1], label=str(num), linewidth=1, linestyle='--')
mRNA_result = mRNA_result.sort_values('chisqr') time = mRNA_data['time'] t = get_sim_time() tp = get_num_points() plt.figure() print('top regs for ' + mRNA_name + ':') for i in range(top_plots): reg = mRNA_result.iloc[i][1] chisqr = mRNA_result.iloc[i][2] params = ast.literal_eval(mRNA_result.iloc[i][3]) sub_model = generate_sub_model(mRNA_num, reg) rr = te.loada(sub_model) for p in params: rr[p] = params[p] sim_data = rr.simulate(0, t, tp) rows, cols = get_dims(top_plots) plt.subplot(rows, cols, i + 1) plt.plot(time, mRNA_data[mRNA_name], color='C' + str(mRNA_num), label='exp') plt.plot(time, sim_data['[mRNA]'], color='black', label='sim') plt.title('reg: ' + reg + ', chisqr: ' + str(round(chisqr, 2))) plt.legend() print(reg + ', chisqr: ' + str(chisqr)) plt.suptitle('mRNA' + str(mRNA_num)) plt.show() def p(df): print(df[['mRNA_num', 'regulators', 'chisqr']])
# {'species': 'P8', 'params':{'Vm4': 2}, 'ylim': (0, 6)} # ] results = results.sort_values('chisqr') #plt.figure() for idx, model_num in enumerate([0, 1, 2, 3]): sim_time = 1200 regs = ast.literal_eval(results.iloc[model_num][0]) params = ast.literal_eval(results.iloc[model_num][2]) model = make_model(regs) rr = te.loada(model) for p in params: rr[p] = params[p] sim_data_wild = rr.simulate(0, sim_time, 5000) plt.figure('model ' + str(model_num), figsize=(10, 5), dpi=100) rows, cols = get_dims(len(stress_tests)) # row = 1 # cols = 3 #rows, cols = get_dims(4) #plt.subplot(rows, cols, idx + 1) for i, test in enumerate(stress_tests): rr.resetToOrigin() for p in params: rr[p] = params[p] species = '[' + test['species'] + ']' title = species + ', ' for p in test['params']: rr[p] = rr[p] * test['params'][p] title = title + p + '=' + str(test['params'][p]) + 'x, ' sim_data_mut = rr.simulate(0, sim_time, 5000) plt.subplot(rows, cols, i + 1)