Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change set_rtss_epi to set_pev_epi #16

Closed
wants to merge 4 commits into from
Closed

Conversation

lmhaile
Copy link
Collaborator

@lmhaile lmhaile commented Jul 4, 2023

Quick change per the new malariasimulation version!

@pwinskill
Copy link
Member

pwinskill commented Jul 14, 2023

@lmhaile - we need the checks below to be passing before these changes can be brought in.
You can run devtools::test() and devtools::check() locally to see what errors and warnings are produced.

Given that we have made modifications to the vaccine implementation, it is likely that the associated test will also have to be corrected, that is in this file: https://github.com/mrc-ide/site/blob/main/tests/testthat/test-rtss.R. You can read here (https://r-pkgs.org/testing-basics.html) for more info on unit tests in packages if it is new to you.

parameters = p,
profile = rtss_profile,
timesteps = timesteps,
coverages = interventions$rtss_cov,
age = round(6 * month),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some pieces missing here, if we look at https://mrc-ide.github.io/malariasimulation/articles/Vaccines.html#simulation-2 then we need to:

  • additionally specify the booster_profile
  • rename the boosters argument to booster_timestep
  • seasonal_boosters is by default set to FALSE so we can remove that

@pwinskill
Copy link
Member

In addition, it might be nice to add a plot to this PR showing the two site files runs - one with vaccination and one without. That way we can be more cofident that the vaccine implementation if feeding through to the model as expected

@lmhaile
Copy link
Collaborator Author

lmhaile commented Jul 17, 2023

In addition, it might be nice to add a plot to this PR showing the two site files runs - one with vaccination and one without. That way we can be more cofident that the vaccine implementation if feeding through to the model as expected

Diagnostic of clinical incidence over time (intervention= 100% vaccine coverage for time period, baseline= 0% coverage):
image

Source code:

install.packages('Q:/site_0.2.2.tar.gz')

# model and plotting functions
run_model <- function(site) {
  
  # pull parameters for this site
  params <- site::site_parameters(
    interventions = site$interventions,
    demography = site$demography,
    vectors = site$vectors,
    seasonality = site$seasonality,
    eir = site$eir$eir[1],
    overrides = list(human_population = 1000),
    burnin = 5 * 365
  )
  
  model <-  malariasimulation::run_simulation(timesteps = 20 * 365,
                                              parameters = params)
  return(model)
}

format_for_plots <- function (baseline, int) {
  baseline <- get_rates(
    baseline,
    time_divisor = 365,
    baseline_t = 0,
    age_divisor = 1,
    scaler = 0.215,
    treatment_scaler = 0.5,
    baseline_treatment = 0
  )
  
  baseline <- baseline |>
    mutate(identifier = 'baseline')
  
  int <- get_rates(
    int,
    time_divisor = 365,
    baseline_t = 0,
    age_divisor = 1,
    scaler = 0.215,
    treatment_scaler = 0.5,
    baseline_treatment = 0
  )
  
  int <- int |>
    mutate(identifier = 'intervention')
  
  
  dt <- rbind(baseline, int, fill = T)
  dt <- dt |>
    rename(year = t) |>
    mutate(age = as.numeric(age_lower)) |>
    mutate(age = round(age / 365)) |>
    mutate(year = year + 1999) |>
    select(identifier, year, age, clinical)
  
  
  dt <- data.table(dt)
  
  dt <- dt[identifier != TRUE]
  return(dt)
}


# run one model with vaccine coverage of 100% and another with 0% coverage
# example site
site_data <- foresite::MWI
site <- site::single_site(site_data, 5)

# run with vaccine coverage
rtss <- copy(site)
rtss$interventions$rtss_cov <- 1

# run without
no_rtss <- copy(site)
no_rtss$interventions$rtss_cov <- 0


intvn <- run_model(rtss)
bl <- run_model(no_rtss)

dt <- format_for_plots(baseline = bl, int = intvn)

# plot
p <-
  ggplot(
    data = dt,
    mapping = aes(
      x = year,
      y = clinical,
      color = identifier,
      fill = identifier
    )
  ) +
  geom_point(alpha = 0.5)  +
  facet_wrap_paginate( ~ round(age), scales = 'free') +
  labs(
    x = 'Time (in years)',
    y = 'Clinical incidence rate',
    title = paste0('Clinical incidence rate over time'),
    color = 'Model Run',
    fill = 'Model Run'
  ) +
  theme_light(base_family = 'Arial') +
  scale_color_manual(values = wes_palette('Royal2', n = 2)) +
  scale_x_continuous(guide = guide_axis(n.dodge = 2)) +
  scale_fill_manual(values = wes_palette('Royal2', n = 2))


print(p)

@lmhaile lmhaile requested a review from pwinskill July 24, 2023 09:24
@codecov
Copy link

codecov bot commented Jul 24, 2023

Codecov Report

Patch coverage: 83.33% and project coverage change: +0.01 🎉

Comparison is base (a031200) 96.55% compared to head (f465303) 96.56%.

❗ Current head f465303 differs from pull request most recent head a399a18. Consider uploading reports for the commit a399a18 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #16      +/-   ##
==========================================
+ Coverage   96.55%   96.56%   +0.01%     
==========================================
  Files           9        9              
  Lines         232      233       +1     
==========================================
+ Hits          224      225       +1     
  Misses          8        8              
Impacted Files Coverage Δ
R/interventions.R 95.39% <83.33%> (+0.03%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@pwinskill pwinskill closed this Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants