From 20a281f36e82485c460fc1fcc3414ac80bd04582 Mon Sep 17 00:00:00 2001 From: James Hay <9113187+jameshay218@users.noreply.github.com> Date: Mon, 8 Jul 2024 16:41:14 +0100 Subject: [PATCH] Fixed some minor bugs in start_levels for plotting --- R/helpers.R | 3 ++- R/plot_antibody_model.R | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/helpers.R b/R/helpers.R index a130a47..2411cb0 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -541,7 +541,8 @@ align_antibody_demographic_dat <- function(antibody_data, demographics){ } add_stratifying_variables <- function(antibody_data, timevarying_demographics=NULL, par_tab, use_demographic_groups=NULL){ - # Any stratification of population attack rates? +#browser() + # Any stratification of population attack rates? ## Pull out any parameters related to attack rates population_group_strats <- par_tab %>% filter(names %like% "infection_model_prior" | names == "phi") %>% pull(stratification) %>% unique() diff --git a/R/plot_antibody_model.R b/R/plot_antibody_model.R index 1571f05..b517be7 100644 --- a/R/plot_antibody_model.R +++ b/R/plot_antibody_model.R @@ -155,7 +155,7 @@ plot_model_fits <- function(chain, infection_histories, if(is.null(antibody_data)) antibody_data <- settings$antibody_data if(is.null(demographics)) demographics <- settings$demographics if(is.null(par_tab)) par_tab <- settings$par_tab - if(is.null(start_level) | start_level == "none") start_level <- settings$start_level + if(is.null(start_level) | start_level == "none") start_level <- settings$start_levels if(missing(data_type)) data_type <- settings$data_type } individuals <- individuals[order(individuals)] @@ -173,7 +173,7 @@ plot_model_fits <- function(chain, infection_histories, dplyr::filter(individual %in% individuals),start_level,FALSE) %>% dplyr::arrange(individual, biomarker_group, sample_time, biomarker_id, repeat_number) } else if(class(start_level) %in% c("tibble","data.frame")){ - start_levels <- start_levels + start_levels <- start_level } else { start_levels <- NULL } @@ -198,7 +198,6 @@ plot_model_fits <- function(chain, infection_histories, inf_hist_densities <- antibody_preds$histories inf_hist_densities$xmin <- inf_hist_densities$variable-0.5 inf_hist_densities$xmax <- inf_hist_densities$variable+0.5 - browser() ## Subset infection history densities to not plot infections before sample time inf_hist_densities <- inf_hist_densities %>% left_join(model_preds[model_preds$individual %in% individuals,c("individual","sample_time")] %>% dplyr::distinct(),by="individual",relationship="many-to-many") %>% @@ -410,7 +409,7 @@ plot_antibody_predictions <- function(chain, infection_histories, if(is.null(antibody_data)) antibody_data <- settings$antibody_data if(is.null(demographics)) demographics <- settings$demographics if(is.null(par_tab)) par_tab <- settings$par_tab - if(is.null(start_level) | start_level == "none") start_level <- settings$start_level + if(is.null(start_level) | start_level == "none") start_level <- settings$start_levels if(missing(data_type)) data_type <- settings$data_type } @@ -426,7 +425,7 @@ plot_antibody_predictions <- function(chain, infection_histories, start_levels <- create_start_level_data(antibody_data,start_level,FALSE) %>% dplyr::arrange(individual, biomarker_group, sample_time, biomarker_id, repeat_number) } else if(class(start_level) %in% c("tibble","data.frame")){ - start_levels <- start_levels + start_levels <- start_level } else { start_levels <- NULL }