attr_names <- EpiModelWHAMPDX::attr_names
suppressPackageStartupMessages(library(tidyverse))
suppressPackageStartupMessages(library(magrittr))
suppressPackageStartupMessages(library(cowplot))
suppressPackageStartupMessages(library(ggrepel))
library(EpiModelWHAMPDX)
sim_dat <- readRDS("../../EpiModel/AE/sim_epimodel3/sim_at_2033_feb_19.rds")
options(dplyr.summarise.inform = FALSE)
print_many_plots <- function(testing_plots, sim_dat, num_hash = 2){
sml_temp <- paste0(c(rep("#", num_hash), " %s ", "
", "
"), collapse = "")
sub_plot_info <- testing_plots
if (is.null(sub_plot_info$plt_type)) {
plt_type <- "line" }else{
plt_type <- sub_plot_info$plt_type }
meas_data <- make_epi_plot_data(sim_dat, sub_plot_info)
for (ct_idx in seq(attr_names)) {
this_cat <- names(attr_names)[ct_idx]
targs <- EpiModelWHAMPDX::WHAMP.targs %>%
filter(measure == sub_plot_info$name)
if (nrow(targs) == 0) {
targs <- NULL
}else{
sub_trg <- targs %>% filter(cat == this_cat)
if (nrow(sub_trg) == 0) {
catgs <- EpiModelWHAMPDX::attr_names[[this_cat]]
sub_trg <- do.call(rbind, rep(list(targs), length(catgs)))
sub_trg$sub_cat <- catgs
sub_trg$cat <- this_cat
}
targs <- sub_trg
}
if (this_cat == "ovr") {
cat_meas_name <- "overall"
}else if (this_cat == "age.grp") {
cat_meas_name <- "age"
}else{
cat_meas_name <- this_cat
}
cat(sprintf(sml_temp, cat_meas_name))
print(EpiModelWHAMPDX::plot_epi(meas_data, this_cat,
plot_type = plt_type,
targets = targs,
year_range = c(1990, 2030)))
cat("\n\n")
}
}
Open the first code chunk below to see the construction rule
# prop.of.neg.on.prep <- neg.prep.num / (num - i.num)
# (prepStats == 1 & status = 0) / (status == 0) =
prop.prep <- list(name = "prop.prep",
plot_name = "Proportion of HIV- on PrEP",
plt_type = "line",
vars = c("neg.prep.num.", "num.", "i.num."),
sum_fun = function(x, y, z) x / (y - z))
print_many_plots(prop.prep, sim_dat)
Open the first code chunk below to see the construction rule
# prop.of.hiv.supr <- any.prep.ind / (num - i.num) =
# (prepIndic == 1 & status == 0) / (status == 0)
prop.hivn.ind <- list(name = "prop.hivn.ind",
plot_name = "Proportion of HIV- who are PrEP indicated",
plt_type = "line",
vars = c("any.prep.ind.", "num.", "i.num."),
sum_fun = function(x, y, z) x/(y - z))
print_many_plots(prop.hivn.ind, sim_dat)
Open the first code chunk below to see the construction rule
# prop.of.ind.on.prep <- on.prep.and.ind / any.prep.ind =
# (prepIndic == 1 & status == 0 & prepStat == 1) / (prepIndic == 1 & status == 0)
prop.ind.on.prep <- list(name = "prop.ind.on.prep",
plot_name = "Proportion of PrEP indicated on PrEP",
vars = c("on.prep.and.ind.", "any.prep.ind."),
sum_fun = function(x, y) x / y,
plt_type = "line")
print_many_plots(prop.ind.on.prep, sim_dat)