<jupyter_start><jupyter_text>WORK IN PROGRESS  DynamicsWe assume t-cell dynamics as below as from [Almocera et al](https://www.biorxiv.org/content/biorxiv/early/2017/08/11/174961.full.pdf), but with lysis (from NK cells) and delayed replication start as a separate state    dI/dt = p V (1 - V/Kv) - I/t    dV/dt =  I/t - (cE + l)V        dE/dt = (E0 - E)δe + G(V)E        p = Ro * (1 - (c E + l) + l m)              G(I) = rV/(V + Ke)         R0 = pδe/(cv Ne)     TODO: Model the regulation of NK cells (for lysis / apoptosis), instead of assuming they kill only through lysis a fixed rate The slow virus takes sixty times as long to start producing copies<jupyter_code>r_slow = 1e-2
r_fast = r_slow
carrying_v = 6e5
carrying_e = 3e3
delta_e = 3e-2
e_0 = 1e6
r0_fast = .5
t_fast = 1
c_v = 1e-6
t_slow = t_fast * 10
lysis_multiplier = 2
lysis_rate = 1e-2
r0_slow = r0_fast
def compute(I, V, E, r, carrying_v, carrying_e, delta_e, e_0, c_v, r0, t, initial, lysis_multiplier, lysis_rate):
    for period in range(len(V) - 1):
        I_old = I[period]
        V_old = V[period]
        E_old = E[period]
        p = r0 * (max(0, (1  - c_v * E_old - lysis_rate)) + lysis_rate * lysis_multiplier)
        flux_I_infection =  max(0, p * V_old * (1 - (V_old + I_old)/carrying_v))
        flux_I_lysis = lysis_rate * I_old
        flux_V_ready = I_old/t 
        flux_V_lysis = lysis_rate * V_old
        flux_V_cleanup = c_v * V_old
        flux_E = (e_0 - E_old) * delta_e + r * V_old / (V_old + carrying_e) * E_old
        I.loc[period + 1] = int(max(0, I_old + flux_I_infection - flux_V_ready - flux_I_lysis))
        V.loc[period + 1] = int(max(0, V_old - flux_V_cleanup + flux_V_ready - flux_V_lysis))
        E.loc[period + 1] = int(max(0, E_old + flux_E))
initial_infections = [1e2] #np.linspace(1e1, 1e3, 5)
# initial = 1e6
allele_multipliers = np.arange(.2, 2, .2)
results_I = []
results_V = []
results_E = []
results_fast_I = []
results_fast_V = []
results_fast_E = []
for initial in initial_infections:
    for a in allele_multipliers:
        slow = pd.DataFrame(np.zeros((1000, 3)), index=range(1000), columns=['I', 'V', 'E'])
        fast = pd.DataFrame(np.zeros((1000, 3)), index=range(1000), columns=['I', 'V', 'E'])
        slow.loc[0, :] = (initial, 0, e_0)
        fast.loc[0, :] = (initial, 0, e_0)
        compute(slow['I'], slow['V'], slow['E'], r_slow, carrying_v, carrying_e, delta_e, e_0, c_v * a, r0_slow, t_slow, initial, lysis_multiplier, lysis_rate)
        compute(fast['I'], fast['V'], fast['E'], r_fast, carrying_v, carrying_e, delta_e, e_0, c_v * a, r0_fast, t_fast, initial, lysis_multiplier, lysis_rate)
        results_I.append(slow['I'])
        results_V.append(slow['V'])
        results_E.append(slow['E'])
        results_fast_I.append(fast['I'])
        results_fast_V.append(fast['V'])
        results_fast_E.append(fast['E'])
trajectories = pd.concat(results_V, axis=1)
trajectories_fast = pd.concat(results_fast_V, axis=1)
trajectories.T.reset_index(drop=True).T.plot(figsize=(30, 30))
trajectories_fast.T.reset_index(drop=True).T.plot(figsize=(30, 30))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14770906760653638, 'fraction_numerical': 0.033963473245754564, 'mean_word_length': 3.318118948824343, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '147301', 'license': 'MIT', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1256, 'n_words': 289, 'path': 'modeling/within-host/within_host_dynamics.ipynb', 'repo_name': 'understand-covid/proposal', 'size': '3121'}