Skip to contents

Plots example trajectories of the provided antibody kinetics model

Usage

plot_antibody_model(
  antibody_model,
  N = 100,
  times = seq(1, 50, by = 1),
  model_pars,
  biomarker_map,
  demography = NULL,
  draw_parameters_fn = draw_parameters_fixed_fx,
  ...
)

Arguments

antibody_model

A function determining the latent biomarker kinetics as a function of exposure history and within-host kinetics parameters (model_pars)

N

Number of trajectories to simulate

times

Vector of times to solve model over

model_pars

A tibble of parameters needed for the antibody kinetics model, immunity model, observation model and the draw_parameters function

biomarker_map

A tibble specifying the relationship between exposure IDs and biomarker IDs with two variables: 1) exposure_id: the numeric exposure ID; 2) biomarker_id: the numeric biomarker ID

demography

A tibble of demographic information for each individual in the simulation. At a minimum this tibble requires 1 column (i) where all individuals in the simulation are listed by row. This is used to calculate the sample population size. Additional variables can be added by the user, e.g., birth and removal times, see generate_pop_demography If not specified, the model will assume that birth time is the initial time point and removal time is the final time point across all individuals

draw_parameters_fn

Pointer to function used for drawing random kinetics parameters, see draw_parameters_fixed_fx

...

Any additional arguments needed

Value

A ggplot2 object

Examples

library(dplyr)
model_pars <- reformat_biomarker_map(example_model_pars_biphasic)%>% tidyr::drop_na()
draw_parameters_random_fx(1,1,1,1,NULL,NULL,model_pars)
#> # A tibble: 4 × 7
#>       i     t     x     b name         value realized_value
#>   <dbl> <dbl> <dbl> <dbl> <chr>        <dbl>          <dbl>
#> 1     1     1     1     1 boost_long  0.535          0.535 
#> 2     1     1     1     1 boost_short 0.196          0.196 
#> 3     1     1     1     1 wane_long   0.0133         0.0133
#> 4     1     1     1     1 wane_short  0.0489         0.0489
biomarker_map <- dplyr::tibble(exposure_id=c(1,1,2),biomarker_id=c(1,2,1))
plot_antibody_model(antibody_model_biphasic, 50, model_pars=model_pars,
draw_parameters_fn = draw_parameters_random_fx, biomarker_map=biomarker_map)

plot_antibody_model(antibody_model_biphasic, 50, model_pars=model_pars,
draw_parameters_fn = draw_parameters_fixed_fx, biomarker_map=biomarker_map)