drb25df.loc['Beta'].iloc[:, i] = drb25df.loc['Beta'].iloc[:, i].apply(scale_data) # Make the DR curves into IfnData objects, for easy plotting dra25 = IfnData('custom', df=dra25df, conditions={'Alpha': {'Ib': 0}}) drb25 = IfnData('custom', df=drb25df, conditions={'Beta': {'Ia': 0}}) # Generate figure by adding simulations, then data results_plot = DoseresponsePlot((1, 2)) for idx, t in enumerate(['5', '10', '20', '60']): results_plot.add_trajectory(dra25, t, 'plot', alpha_palette[idx], (0, 0), 'Alpha') results_plot.add_trajectory(drb25, t, 'plot', beta_palette[idx], (0,1), 'Beta') for idx, t in enumerate([5, 10, 20, 60]): results_plot.add_trajectory(newdata, t, 'scatter', alpha_palette[idx], (0, 0), 'Alpha', dn=1) results_plot.add_trajectory(newdata, t, 'scatter', beta_palette[idx], (0, 1), 'Beta', dn=1) results_plot.save_figure() # Now try to fit the 60 minute data starting from the 2.5 minute results # ---------------------------------------------------------------------- stepfit60 = StepwiseFit(stepfit25.model, smooth60IfnData, {'kSOCSon': (1E-8, 1E-7), 'kd4': (0.03, 0.1), 'k_d4': (0.03, 0.1), 'krec_a2': (0.0005, 0.05), 'krec_b2': (0.01, 0.0001), 'krec_a1': (0.00003, 0.003), 'krec_b1': (0.001, 0.00001)}, n=2) best_parameters, best_scale_factor60 = stepfit60.fit() scale_data = lambda q: (best_scale_factor60*q[0], best_scale_factor60*q[1]) with open('stepwisefitmodel.p','wb') as f: pickle.dump(stepfit60.model.__dict__,f,2) with open('stepwisefitobject.p','wb') as f: pickle.dump(stepfit60.__dict__,f,2) print(stepfit60.model.parameters)
scale_factor=scale_factor) dra60 = IfnData('custom', df=dradf, conditions={'Alpha': {'Ib': 0}}) drb60 = IfnData('custom', df=drbdf, conditions={'Beta': {'Ia': 0}}) dra60_int = IfnData('custom', df=dradf_int, conditions={'Alpha': {'Ib': 0}}) drb60_int = IfnData('custom', df=drbdf_int, conditions={'Beta': {'Ia': 0}}) dra60_rec = IfnData('custom', df=dradf_rec, conditions={'Alpha': {'Ib': 0}}) drb60_rec = IfnData('custom', df=drbdf_rec, conditions={'Beta': {'Ia': 0}}) dr_plot = DoseresponsePlot((1, 1)) alpha_mask = [] beta_mask = [] # Add fits for idx, t in enumerate([el for el in times]): if t not in alpha_mask: dr_plot.add_trajectory(dra60, t, 'plot', alpha_palette[5], (0, 0), 'Alpha', label='Alpha - No Feedback', linewidth=2.0) dr_plot.add_trajectory(dra60_int, t, 'plot', '--', (0, 0), 'Alpha', color=alpha_palette[3], label='Internalization only', linewidth=2.0, ) dr_plot.add_trajectory(dra60_rec, t, 'plot', ':', (0, 0), 'Alpha', color=alpha_palette[1], label='SOCS only', linewidth=2.0) if t not in beta_mask: dr_plot.add_trajectory(drb60, t, 'plot', beta_palette[5], (0, 0), 'Beta', label='Beta - No Feedback', linewidth=2.0) dr_plot.add_trajectory(drb60_int, t, 'plot', '--', (0, 0), 'Beta', color=beta_palette[3], label='Internalization only', linewidth=2.0) dr_plot.add_trajectory(drb60_rec, t, 'plot', ':', (0, 0), 'Beta', color=beta_palette[1], label='SOCS only', linewidth=2.0) dr_plot.fig.suptitle('Internalization vs SOCS') dir = os.path.join(os.getcwd(), 'results', 'Figures', 'Figure_5') if not os.path.exists(dir): os.makedirs(dir) dr_plot.save_figure(save_dir=os.path.join(dir, 'Figure_5.pdf'))
figure=dr_plot.fig) plt.scatter([], [], color=beta_palette[5], label=r'IFN$\beta$', figure=dr_plot.fig) plt.plot([], [], c='grey', label='No Feedback', linewidth=2.0, figure=dr_plot.fig) plt.plot([], [], '--', c='grey', label='+ Internalization', linewidth=2.0, figure=dr_plot.fig) plt.plot([], [], ':', c='grey', label='+ SOCS', linewidth=2.0, figure=dr_plot.fig) # Plot formatting dr_plot.fig.set_size_inches((5, 4)) dr_plot.axes.set_title('Effects of Negative Feedback') dr_plot.axes.set_ylabel('pSTAT') dr_plot.axes.spines['top'].set_visible(False) dr_plot.axes.spines['right'].set_visible(False) dr_plot.save_figure(save_dir=fname, tight=True)