Пример #1
0
def tidy_sort(df):
    df = compute_cell_states(df)
    df_tidy = df.melt(id_vars=["time", "Infection"], var_name="celltype")

    cells = filter_cells(df_tidy, ["Th1_eff", "Tfh_all", "Tr1_all", "nonTfh",
                                   "Total_CD4"])
    return df_tidy, cells
Пример #2
0
def transform(sim, data, timepoints=[9, 30, 60]):
    """
    objective function computes difference between data and simulation
    Parameters
    ----------
    sim : TYPE
        DESCRIPTION.
    data : TYPE
        DESCRIPTION.
    timepoints : TYPE, optional
        DESCRIPTION. The default is [9, 30, 60].

    Returns
    -------
    resid : arr
        array of data-simulation differences (residuals)

    """
    sim = pd.DataFrame(sim, columns=sim.colnames)
    # get simulation data at these time points
    sim = sim[sim.time.isin(timepoints)]
    sim = compute_cell_states(sim)
    # only focus on Tfh and non Tfh
    sim = sim[["Tfh_all", "nonTfh"]]
    # convert to same format as data
    sim = sim.melt()
    resid = (data.value.values - sim.value.values) / data.eps.values
    return resid
Пример #3
0
def tidy(sim, name):
    """
    convert simulation output to long format for plotting
    """
    sim = pd.DataFrame(sim, columns=sim.colnames)
    # get simulation data at these time points
    sim = compute_cell_states(sim)
    # only focus on Tfh and non Tfh
    sim = sim[["time", "Tfh_all", "nonTfh"]]
    sim = sim.melt(id_vars=["time"])
    sim["Infection"] = name
    return sim