Skip to content

Commit

Permalink
Fixed some minor bugs in start_levels for plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshay218 committed Jul 8, 2024
1 parent 710178c commit 20a281f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
3 changes: 2 additions & 1 deletion R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 4 additions & 5 deletions R/plot_antibody_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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
}
Expand All @@ -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") %>%
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}
Expand Down

0 comments on commit 20a281f

Please sign in to comment.