cell_list = [] molecules_list = [] id = "SD(virus)" for sim, beta, alpha in zip(sim_list, betas, alphas): cells, molecules = sim.run_sim() SD = round(alpha / (beta**2), 2) cells[id] = str(SD) molecules[id] = str(SD) cell_list.append(cells) molecules_list.append(molecules) cells = pd.concat(cell_list) molecules = pd.concat(molecules_list) g = pl.plot_timecourse(cells, hue=id, col="cell") g.set_titles("{col_name}") plt.show() molecules = molecules.loc[molecules["cell"] == "Virus"] g = sns.relplot(data=molecules, x="time", y="value", hue=id, facet_kws={"sharey": False}, kind="line", legend=False, aspect=1.1) g.set_titles("{col_name}") g.set(ylabel="virus density")
# create simulation list sim_list = [ Sim(name=name, params=dic, time=time, virus_model=vir_model) for dic in d_list ] sim_list2 = [ Sim(name=name, params=dic, time=time, virus_model=vir_model) for dic in d_list2 ] # run model id = "ag conc." exp1 = Simlist(sim_list, names, idtype=id) cells, molecules = exp1.run_sim() cells["r_chronic"] = "0" exp2 = Simlist(sim_list2, names, idtype=id) cells2, molecules2 = exp2.run_sim() cells2["r_chronic"] = "10" cells = pd.concat([cells, cells2]) pl.plot_timecourse(cells, cells=["teff", "tchronic"], style="r_chronic", palette=["grey", "grey"], col="ag conc.", row="cell", hue="r_chronic") plt.show()
name="il2+time+ag", prolif_type="timer", myc_type="il2_ag", params=d4, virus_model=vir_model_SIR2) simlist = [sim1, sim2, sim3, sim4] simres = [sim.run_sim() for sim in simlist] cells = [res[0] for res in simres] molecules = [res[1] for res in simres] cells = pd.concat(cells) molecules = pd.concat(molecules) g = pl.plot_timecourse(cells, cells=["Effector"], hue="name") plt.show() g = pl.plot_timecourse(molecules, cells=["IL2", "Myc", "Virus"], hue="name", col="cell") plt.show() # effect of division time on model for sim in simlist: arr = np.linspace(3.5, 6, 30) pname = "prolif_th1" df1, df2 = proc.run_timecourses(sim, arr, pname) # add division time based on prolif rate
mysim3 = exp.Sim(name="timer", 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()
highlight_cells = [] highlight_mols = [] # set up arrays pname = "beta_p" arr_timecourse = np.geomspace(10,100, res_timecourse) arr_pscan = np.geomspace(1,1e3, res_pscan) for name, mymol, K_eff, param_name in zip(names, mymols, K_vals, param_names): # make simulation object sim = Sim(name=name, params=d, time=time, virus_model=vir_model, prolif_type=name) # plot timecourse before normalization cells, molecules = sim.run_sim() pl.plot_timecourse(df = cells, cells= ["tnaive", "teff", "tchronic", "all_cells"], hue = "cell", ylim = (1,1e6)) # plot timecourse with normalized cells cells2 = cells.loc[cells["cell"] == "all_cells", :] mynorm = np.log2(cells2["value"]) #print(rr.get_peaktime(cells2["time"], cells2["value"])) #peak = rr.get_peak_height(cells2["time"], cells2["value"]) if name != "Cntrl": mypeak = np.max(mynorm) else: # take the value where time is at peak in other models out = cells2.loc[(cells2["time"] > 2) & (cells2["time"] <= 2.2),:] mypeak = np.log2(out.value.iloc[0]) cells2.loc[:, "value"] = (mynorm / mypeak) highlight_cells.append(cells2)
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()
from src.models.virus_models import vir_model_const import src.modules.pl as pl import matplotlib.pyplot as plt import seaborn as sns import pandas as pd # init model name = "il2" # can be "il2", "timer" "timer_il2" vir_model = vir_model_const time = np.arange(0, 10, 0.01) # plot timecourse sim = Sim(name=name, params=d, time=time, virus_model=vir_model) cells, molecules = sim.run_sim() pl.plot_timecourse(cells, cells=["teff"]) plt.show() # check effect for different const. ag levels # create dicts and set up simulations names = ["none", "lo", "mid", "hi"] vir_loads = [0, 0.01, 0.1, 10] d_list = [dict(d) for i in range(len(vir_loads))] for dic, v in zip(d_list, vir_loads): dic["vir_load"] = v sim_list = [ Sim(name=name, params=dic, time=time, virus_model=vir_model) for dic in d_list ] cell_list = []