From f868af9d5239c393fa8114e2d9bb03ef9c2c2133 Mon Sep 17 00:00:00 2001 From: James Hay <9113187+jameshay218@users.noreply.github.com> Date: Fri, 17 May 2024 12:15:52 +0100 Subject: [PATCH] Updated documentation --- NAMESPACE | 2 + man/calculate_infection_history_statistics.Rd | 1 + man/create_posterior_func.Rd | 3 +- man/inf_hist_prop_prior_v2_and_v4.Rd | 3 + man/inf_hist_swap.Rd | 7 +-- man/inf_hist_swap_phi.Rd | 4 -- man/plot_antibody_data.Rd | 1 + man/plot_antibody_predictions.Rd | 1 + man/plot_cumulative_infection_histories.Rd | 1 + man/plot_estimated_antibody_model.Rd | 62 +++++++++++++++++++ man/plot_individual_number_infections.Rd | 1 + man/plot_infection_history_chains_indiv.Rd | 1 + man/plot_infection_history_chains_time.Rd | 1 + man/plot_model_fits.Rd | 1 + man/plot_posteriors_infhist.Rd | 1 + man/plot_total_number_infections.Rd | 1 + man/serosolver.Rd | 1 + man/simulate_data.Rd | 6 +- 18 files changed, 85 insertions(+), 13 deletions(-) create mode 100644 man/plot_estimated_antibody_model.Rd diff --git a/NAMESPACE b/NAMESPACE index e5320e4..a3c488d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,7 @@ export(add_measurement_shifts) export(add_noise) +export(add_scale_pars) export(antibody_model) export(calc_phi_probs) export(calc_phi_probs_indiv) @@ -73,6 +74,7 @@ export(plot_antibody_predictions) export(plot_attack_rates) export(plot_attack_rates_pointrange) export(plot_cumulative_infection_histories) +export(plot_estimated_antibody_model) export(plot_individual_number_infections) export(plot_infection_history_chains_indiv) export(plot_infection_history_chains_time) diff --git a/man/calculate_infection_history_statistics.Rd b/man/calculate_infection_history_statistics.Rd index e1afcb3..cc5a91e 100644 --- a/man/calculate_infection_history_statistics.Rd +++ b/man/calculate_infection_history_statistics.Rd @@ -63,6 +63,7 @@ Other infection_history_plots: \code{\link{plot_antibody_data}()}, \code{\link{plot_antibody_predictions}()}, \code{\link{plot_cumulative_infection_histories}()}, +\code{\link{plot_estimated_antibody_model}()}, \code{\link{plot_individual_number_infections}()}, \code{\link{plot_infection_history_chains_indiv}()}, \code{\link{plot_infection_history_chains_time}()}, diff --git a/man/create_posterior_func.Rd b/man/create_posterior_func.Rd index cc309da..cfd7f17 100644 --- a/man/create_posterior_func.Rd +++ b/man/create_posterior_func.Rd @@ -9,7 +9,7 @@ create_posterior_func( antibody_data, antigenic_map = NULL, possible_exposure_times = NULL, - prior_version = 1, + prior_version = 2, solve_likelihood = TRUE, age_mask = NULL, measurement_bias = NULL, @@ -22,6 +22,7 @@ create_posterior_func( start_level_randomize = FALSE, demographics = NULL, demographic_groups = NULL, + fixed_inf_hists = NULL, verbose = FALSE, ... ) diff --git a/man/inf_hist_prop_prior_v2_and_v4.Rd b/man/inf_hist_prop_prior_v2_and_v4.Rd index e65ac1c..ecd5524 100644 --- a/man/inf_hist_prop_prior_v2_and_v4.Rd +++ b/man/inf_hist_prop_prior_v2_and_v4.Rd @@ -59,6 +59,9 @@ inf_hist_prop_prior_v2_and_v4( total_alive, data_types, obs_weights, + indiv_possible_exposure_times_indices, + indiv_poss_exp_times_start, + indiv_poss_exp_times_end, timevarying_groups = FALSE, temp = 1, solve_likelihood = TRUE diff --git a/man/inf_hist_swap.Rd b/man/inf_hist_swap.Rd index 725a8d8..e27a122 100644 --- a/man/inf_hist_swap.Rd +++ b/man/inf_hist_swap.Rd @@ -6,8 +6,7 @@ \usage{ inf_hist_swap( infection_history, - age_mask, - sample_mask, + inf_hist_masks, proposal_inf_hist_indiv_swap_ratio, proposal_inf_hist_distance, proposal_ratios = NULL @@ -16,9 +15,7 @@ inf_hist_swap( \arguments{ \item{infection_history}{matrix of 1s and 0s to swap around representing the infection history} -\item{age_mask}{the first index in infection_history that each individual (row) could be infected in} - -\item{sample_mask}{the last index in infection_history that each individual (row) could be infected in ie. the time of the latest blood sample} +\item{inf_hist_masks}{matrix of 1s and 0s corresponding to infection_history, with a 1 where the infection state is eligible to be updated and a 0 otherwise} \item{proposal_inf_hist_indiv_swap_ratio}{what proportion of infections should be swapped?} diff --git a/man/inf_hist_swap_phi.Rd b/man/inf_hist_swap_phi.Rd index a2e8385..9b34ea9 100644 --- a/man/inf_hist_swap_phi.Rd +++ b/man/inf_hist_swap_phi.Rd @@ -19,10 +19,6 @@ inf_hist_swap_phi( \item{phis}{vector of force of infection parameters for each column} -\item{age_mask}{the first index in infection_history that each individual (row) could be infected in} - -\item{sample_mask}{the last index in infection_history that each individual (row) could be infected in ie. the time of the latest blood sample} - \item{proposal_inf_hist_indiv_swap_ratio}{what proportion of infections should be swapped?} \item{proposal_inf_hist_distance}{How many time points away should be chosen as candidate swaps?} diff --git a/man/plot_antibody_data.Rd b/man/plot_antibody_data.Rd index d2873ed..53285e8 100644 --- a/man/plot_antibody_data.Rd +++ b/man/plot_antibody_data.Rd @@ -46,6 +46,7 @@ Other infection_history_plots: \code{\link{calculate_infection_history_statistics}()}, \code{\link{plot_antibody_predictions}()}, \code{\link{plot_cumulative_infection_histories}()}, +\code{\link{plot_estimated_antibody_model}()}, \code{\link{plot_individual_number_infections}()}, \code{\link{plot_infection_history_chains_indiv}()}, \code{\link{plot_infection_history_chains_time}()}, diff --git a/man/plot_antibody_predictions.Rd b/man/plot_antibody_predictions.Rd index 8d0fce2..e91eddf 100644 --- a/man/plot_antibody_predictions.Rd +++ b/man/plot_antibody_predictions.Rd @@ -58,6 +58,7 @@ Other infection_history_plots: \code{\link{calculate_infection_history_statistics}()}, \code{\link{plot_antibody_data}()}, \code{\link{plot_cumulative_infection_histories}()}, +\code{\link{plot_estimated_antibody_model}()}, \code{\link{plot_individual_number_infections}()}, \code{\link{plot_infection_history_chains_indiv}()}, \code{\link{plot_infection_history_chains_time}()}, diff --git a/man/plot_cumulative_infection_histories.Rd b/man/plot_cumulative_infection_histories.Rd index fb1e29d..682cb8d 100644 --- a/man/plot_cumulative_infection_histories.Rd +++ b/man/plot_cumulative_infection_histories.Rd @@ -69,6 +69,7 @@ Other infection_history_plots: \code{\link{calculate_infection_history_statistics}()}, \code{\link{plot_antibody_data}()}, \code{\link{plot_antibody_predictions}()}, +\code{\link{plot_estimated_antibody_model}()}, \code{\link{plot_individual_number_infections}()}, \code{\link{plot_infection_history_chains_indiv}()}, \code{\link{plot_infection_history_chains_time}()}, diff --git a/man/plot_estimated_antibody_model.Rd b/man/plot_estimated_antibody_model.Rd new file mode 100644 index 0000000..2d01b8e --- /dev/null +++ b/man/plot_estimated_antibody_model.Rd @@ -0,0 +1,62 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot_antibody_model.R +\name{plot_estimated_antibody_model} +\alias{plot_estimated_antibody_model} +\title{Plots estimated antibody kinetics model} +\usage{ +plot_estimated_antibody_model( + chain, + antibody_data = NULL, + demographics = NULL, + antigenic_map = NULL, + possible_exposure_times = NULL, + par_tab = NULL, + nsamp = 1000, + measurement_bias = NULL, + solve_times = seq(1, 30, by = 1), + data_type = 1, + settings = NULL, + by_group = TRUE +) +} +\arguments{ +\item{chain}{the full MCMC chain to generate antibody level trajectories from} + +\item{antibody_data}{the data frame of antibody level data} + +\item{antigenic_map}{(optional) a data frame of antigenic x and y coordinates. Must have column names: x_coord; y_coord; inf_times. See \code{\link{example_antigenic_map}}} + +\item{possible_exposure_times}{(optional) if no antigenic map is specified, this argument gives the vector of times at which individuals can be infected} + +\item{par_tab}{the table controlling the parameters in the MCMC chain} + +\item{nsamp}{number of samples to take from posterior} + +\item{measurement_bias}{default NULL, optional data frame giving the index of `rho` that each biomarker_id and biomarker_group which uses the measurement shift from from. eg. if there's 6 circulation years and 3 strain clusters} + +\item{solve_times}{vector of times to solve model over} + +\item{data_type}{integer, currently accepting 1 or 2. Set to 1 for discretized, bounded data, or 2 for continuous, bounded data.} + +\item{settings}{if not NULL, list of serosolver settings as returned from the main serosolver function} +} +\value{ +a ggplot2 object giving model-predicted antibody level and predicted observations over time since infection +} +\description{ +Plots estimated antibody kinetics model +} +\seealso{ +Other infection_history_plots: +\code{\link{calculate_infection_history_statistics}()}, +\code{\link{plot_antibody_data}()}, +\code{\link{plot_antibody_predictions}()}, +\code{\link{plot_cumulative_infection_histories}()}, +\code{\link{plot_individual_number_infections}()}, +\code{\link{plot_infection_history_chains_indiv}()}, +\code{\link{plot_infection_history_chains_time}()}, +\code{\link{plot_model_fits}()}, +\code{\link{plot_posteriors_infhist}()}, +\code{\link{plot_total_number_infections}()} +} +\concept{infection_history_plots} diff --git a/man/plot_individual_number_infections.Rd b/man/plot_individual_number_infections.Rd index 387c6ec..a791a14 100644 --- a/man/plot_individual_number_infections.Rd +++ b/man/plot_individual_number_infections.Rd @@ -29,6 +29,7 @@ Other infection_history_plots: \code{\link{plot_antibody_data}()}, \code{\link{plot_antibody_predictions}()}, \code{\link{plot_cumulative_infection_histories}()}, +\code{\link{plot_estimated_antibody_model}()}, \code{\link{plot_infection_history_chains_indiv}()}, \code{\link{plot_infection_history_chains_time}()}, \code{\link{plot_model_fits}()}, diff --git a/man/plot_infection_history_chains_indiv.Rd b/man/plot_infection_history_chains_indiv.Rd index 43c9dcf..ce4c0c7 100644 --- a/man/plot_infection_history_chains_indiv.Rd +++ b/man/plot_infection_history_chains_indiv.Rd @@ -40,6 +40,7 @@ Other infection_history_plots: \code{\link{plot_antibody_data}()}, \code{\link{plot_antibody_predictions}()}, \code{\link{plot_cumulative_infection_histories}()}, +\code{\link{plot_estimated_antibody_model}()}, \code{\link{plot_individual_number_infections}()}, \code{\link{plot_infection_history_chains_time}()}, \code{\link{plot_model_fits}()}, diff --git a/man/plot_infection_history_chains_time.Rd b/man/plot_infection_history_chains_time.Rd index a77826b..69c7168 100644 --- a/man/plot_infection_history_chains_time.Rd +++ b/man/plot_infection_history_chains_time.Rd @@ -48,6 +48,7 @@ Other infection_history_plots: \code{\link{plot_antibody_data}()}, \code{\link{plot_antibody_predictions}()}, \code{\link{plot_cumulative_infection_histories}()}, +\code{\link{plot_estimated_antibody_model}()}, \code{\link{plot_individual_number_infections}()}, \code{\link{plot_infection_history_chains_indiv}()}, \code{\link{plot_model_fits}()}, diff --git a/man/plot_model_fits.Rd b/man/plot_model_fits.Rd index eaad03e..ea181fc 100644 --- a/man/plot_model_fits.Rd +++ b/man/plot_model_fits.Rd @@ -83,6 +83,7 @@ Other infection_history_plots: \code{\link{plot_antibody_data}()}, \code{\link{plot_antibody_predictions}()}, \code{\link{plot_cumulative_infection_histories}()}, +\code{\link{plot_estimated_antibody_model}()}, \code{\link{plot_individual_number_infections}()}, \code{\link{plot_infection_history_chains_indiv}()}, \code{\link{plot_infection_history_chains_time}()}, diff --git a/man/plot_posteriors_infhist.Rd b/man/plot_posteriors_infhist.Rd index 034235f..cd541be 100644 --- a/man/plot_posteriors_infhist.Rd +++ b/man/plot_posteriors_infhist.Rd @@ -69,6 +69,7 @@ Other infection_history_plots: \code{\link{plot_antibody_data}()}, \code{\link{plot_antibody_predictions}()}, \code{\link{plot_cumulative_infection_histories}()}, +\code{\link{plot_estimated_antibody_model}()}, \code{\link{plot_individual_number_infections}()}, \code{\link{plot_infection_history_chains_indiv}()}, \code{\link{plot_infection_history_chains_time}()}, diff --git a/man/plot_total_number_infections.Rd b/man/plot_total_number_infections.Rd index 1533e54..f9b69be 100644 --- a/man/plot_total_number_infections.Rd +++ b/man/plot_total_number_infections.Rd @@ -29,6 +29,7 @@ Other infection_history_plots: \code{\link{plot_antibody_data}()}, \code{\link{plot_antibody_predictions}()}, \code{\link{plot_cumulative_infection_histories}()}, +\code{\link{plot_estimated_antibody_model}()}, \code{\link{plot_individual_number_infections}()}, \code{\link{plot_infection_history_chains_indiv}()}, \code{\link{plot_infection_history_chains_time}()}, diff --git a/man/serosolver.Rd b/man/serosolver.Rd index ec34e39..2cc51a6 100644 --- a/man/serosolver.Rd +++ b/man/serosolver.Rd @@ -15,6 +15,7 @@ serosolver( n_chains = 1, parallel = FALSE, start_inf_hist = NULL, + fixed_inf_hists = NULL, filename = "test", posterior_func = create_posterior_func, prior_func = NULL, diff --git a/man/simulate_data.Rd b/man/simulate_data.Rd index 1214af2..9d1680d 100644 --- a/man/simulate_data.Rd +++ b/man/simulate_data.Rd @@ -19,7 +19,7 @@ simulate_data( age_group_bounds = NULL, attack_rates, repeats = 1, - measurement_indices = NULL, + measurement_bias = NULL, data_type = NULL, demographics = NULL, verbose = FALSE @@ -52,13 +52,13 @@ simulate_data( \item{repeats}{number of repeat observations for each year} -\item{measurement_indices}{default NULL, optional vector giving the index of `measurement_bias` that each antigen/biomarker ID uses the measurement shift from from. eg. if there's 6 circulation years and 3 strain clusters, then this might be c(1,1,2,2,3,3)} - \item{data_type}{if not NULL, then a vector of data types to use for each biomarker_group} \item{demographics}{if not NULL, then a tibble for each individual (1:n_indiv) giving demographic variable entries. Most importantly must include "birth" as the birth time. This is used if, for example, you have a stratification grouping in `par_tab`} \item{verbose}{if TRUE, prints additional messages} + +\item{measurement_indices}{default NULL, optional vector giving the index of `measurement_bias` that each antigen/biomarker ID uses the measurement shift from from. eg. if there's 6 circulation years and 3 strain clusters, then this might be c(1,1,2,2,3,3)} } \value{ a list with: 1) the data frame of antibody data as returned by \code{\link{simulate_group}}; 2) a matrix of infection histories as returned by \code{\link{simulate_infection_histories}}; 3) a vector of ages