time = np.arange(0, 50, 0.01) # init models name = "il2" d["r_chronic"] = 1 d1 = dict(d) d1["r_chronic"] = 0 sim = Sim(name=name, params=d, time=time, virus_model=vir_model) sim2 = Sim(name=name, params=d1, time=time, virus_model=vir_model) # run parameter scans pname = "SIR_r0" res = 50 down = 1 up = 10 arr = np.linspace(down, up, res) res1 = proc.pscan(sim, arr, pname) res2 = proc.pscan(sim2, arr, pname) res1["chronic"] = "on" res2["chronic"] = "off" res = pd.concat([res1, res2]) # plot parameter scans g = pl.plot_pscan(res, value_col="val_min", cells=["teff"], hue="chronic", palette=["grey", "k"]) plt.show()
sim4.reset() cells, molecules = sim4.run_sim() cells = cells.loc[cells.cell == "Effector"] ax = g.axes.flatten()[0] ax.plot(cells.time, cells.value, color="tab:cyan", lw=6) plt.show() # # also run parameter scan res = proc.pscan(sim4, arr, pname) sim4.reset() # only look at peak for presentation figure res2 = res.loc[res.readout == "Peak"] g = pl.plot_pscan(res2, yscale="log", value_col="value", cells=["Effector"], aspect=1.2, color="grey") ax = g.axes.flatten()[0] ax.xaxis.set_minor_formatter(NullFormatter()) ax.set_ylabel("cell maximum") ax.set_xlabel("antigen dose (a.u.)") plt.title("") plt.show() ########################################################################################################### ########################################################################################################### ########################################################################################################### #effect of r0 on model arr = np.geomspace(1, 10, 30)
cells2 = cells.loc[cells.cell == "Total_CD4"] g = pl.plot_timecourses(cells2, pl_cbar=True, hue_log=True, scale="log", ylabel="n cells", legend=False, ylim=(1e4, 1e7)) plt.show() # also run parameter scan lower = 1 upper = 10 n = 50 arr_pscan = np.geomspace(lower, upper, n) res = proc.pscan(sim, arr_pscan, pname) cells_pscan = ["Total_CD4"] res = res.loc[res.cell.isin(cells_pscan)] res = res.loc[res.readout == "Peak"] ## plot parameter scans g = pl.plot_pscan(res, xscale="log", yscale="log", value_col="value", cells=cells_pscan, col="cell") plt.show()
params=params, time=time, virus_model=mdl.vir_model_gamma) mysim4 = exp.Sim(name="timer", params=params, time=time, virus_model=mdl.vir_model_ode) mysims = [mysim1] for mysim in mysims: # run timecourse cells, molecules = mysim.run_sim() # plot timecourse g = pl.plot_timecourse(cells) plt.show() g = pl.plot_timecourse(molecules) plt.show() # get readouts reads = proc.get_readouts(cells) # run pscan pname = "beta" arr = np.geomspace(0.1, 1, 12) myscan1 = proc.pscan(mysim, arr, pname) # plot pscan g = pl.plot_pscan(myscan1) plt.show()
legend=False) g.set(xlim=xlim) plt.show() #g.savefig("../figures/antigen_effects/timecourse_virus.png") # also run parameter scan lower = 1 upper = 10 n = 10 arr_pscan = np.geomspace(lower, upper, n) res = proc.pscan(sim, arr_pscan, pname) ## plot parameter scans g = pl.plot_pscan(res, xscale="log", yscale="log", value_col="value", cells=["teff"], color="grey") plt.show() # only look at peak for presentation figure res2 = res.loc[res.readout == "Peak"] g = pl.plot_pscan(res2, xscale="log", yscale="log", value_col="value", cells=["teff"], aspect=1.2) ax = g.axes.flatten()[0] for a, c in zip(arr_timecourse, cmap):
# # get readouts for varying beta p # arr = np.geomspace(1,1000, res_pscan) # reads = proc.pscan(sim, arr, pname) # assign nans to null model for beta p > 15 cutoff_null = 30 pscan_prolif.loc[(pscan_prolif["name"] == "Cntrl") & (pscan_prolif["param_value"] > cutoff_null), "value"] = np.nan pscan_prolif.loc[(pscan_prolif["name"] == "Cntrl") & (pscan_prolif["param_value"] > cutoff_null), "val_norm"] = np.nan pscan_prolif.loc[(pscan_prolif["name"] == "Cntrl") & (pscan_prolif["param_value"] > cutoff_null), "val_min"] = np.nan g = pl.plot_pscan(pscan_prolif, cells = ["all_cells"], hue = "readout", col = "name", xscale = "log", kind = "line", legend = False, linewidth = mylinewidth, readouts = myreads, value_col= "val_min", aspect = 1.2, facet_kws = {"despine" : False, "sharey" : False}) axes = g.axes[0] for ax in axes: #ax.axhline(y=0, ls = "--", c = "k", lw = 2) #ax.axhline(y=-10, ls = "--", c = "k", lw = 2) #ax.axhline(y=10, ls = "--", c = "k", lw = 2) ax.set_ylim([-1,25]) ax.set_xlabel(prolif_label) ax.set_ylabel("effect size") ax.set_title("")
n = 100 arr_pscan = np.geomspace(lower, upper, n) #res1 = proc.pscan(sim, arr_pscan, pname) # also run pscan for ag dose pname2 = "vir_load" sim.params["r0"] = 2 res2 = proc.pscan(sim, arr_pscan, pname2) # only looking at antigen dose for now for res in [res2]: cells_pscan = ["Th_eff", "Th_chr", "Total_CD4"] res = res.loc[res.cell.isin(cells_pscan)] res = res.loc[res.readout == "Peak"] ## plot parameter scans g = pl.plot_pscan(res, xscale="log", yscale="log", value_col="value", cells=cells_pscan, hue="cell", legend=False, xlabel="antigen dose", ylabel="response peak", ylim=(1e5, 1e7), aspect=1.2, palette=["grey", "k", "crimson"]) plt.xlabel("antigen dose (a.u.)") plt.title("") plt.show()
from src.modules.pl import plot_timecourse from src.modules.proc import pscan from src.modules.pl import plot_pscan import matplotlib.pyplot as plt # init model name = "il2" vir_model = vir_model_const time = np.arange(0, 200, 0.01) # create simulation sim = Sim(name=name, params=d, time=time, virus_model=vir_model) pname = "vir_load" cells, molecules = sim.run_sim() plot_timecourse(cells, col="cell") plt.show() reads = get_readouts(cells, check_criteria2) res = 30 arr = np.linspace(0, 0.2, res) pscan = pscan(sim, arr, pname) g = plot_pscan(pscan, cells=["teff"], value_col="val_norm", palette=["grey"], hue="cell") plt.show()
# init model name = "il2" vir_model = vir_model_const time = np.arange(0, 50, 0.01) d["r_chronic"] = 10.0 # compare feedback and no fb scenario d1 = dict(d) d2 = dict(d) d2["pos_fb_chr"] = 10.0 # create simulation sim1 = Sim(name = name, params = d1, time = time, virus_model = vir_model) sim2 = Sim(name = name, params = d2, time = time, virus_model = vir_model) res = 100 pname = "vir_load" arr = np.linspace(0,1.0, res) pscan1 = pscan(sim1, arr, pname) pscan2 = pscan(sim2, arr, pname) pscan1["feedback"] = "off" pscan2["feedback"] = "on" pscan = pd.concat([pscan1, pscan2]) pscan = pscan.loc[pscan.cell == "teff"] g = plot_pscan(pscan, row = "feedback", value_col= "val_min", palette= ["grey"]) #g.set(ylim(0,20)) plt.show()
vir_model = vir_model_const time = np.arange(0, 50, 0.01) d1 = dict(d) d1["r_chronic"] = 0 d2 = dict(d) d2["r_chronic"] = 10.0 # create simulation sim1 = Sim(name=name, params=d1, time=time, virus_model=vir_model) sim2 = Sim(name=name, params=d2, time=time, virus_model=vir_model) res = 50 pname = "vir_load" arr = np.linspace(0, 1.0, res) pscan1 = pscan(sim1, arr, pname) pscan2 = pscan(sim2, arr, pname) pscan1["chronic"] = "on" pscan2["chronic"] = "off" pscan = pd.concat([pscan1, pscan2]) pscan = pscan.loc[pscan.cell == "teff"] g = plot_pscan(pscan, row="chronic", value_col="val_min", palette=["grey"], hue="cell") #g.set(ylim(0,20)) plt.show()