Skip to content

Commit

Permalink
Merge pull request #139 from mrc-ide/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
giovannic authored Aug 26, 2021
2 parents cf3e479 + 0b36cc6 commit 0a4061c
Show file tree
Hide file tree
Showing 52 changed files with 1,671 additions and 677 deletions.
33 changes: 19 additions & 14 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
on:
pull_request:
branches:
- dev
- dev
- master

name: R-CMD-check
Expand All @@ -21,19 +21,21 @@ jobs:
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", http-user-agent: "R/4.1.0 (ubuntu-20.04) R (4.1.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@master
- uses: r-lib/actions/setup-r@v1
with:
r-version: ${{ matrix.config.r }}

- uses: r-lib/actions/setup-pandoc@master
- uses: r-lib/actions/setup-pandoc@v1

- name: Query dependencies
run: |
Expand All @@ -42,35 +44,38 @@ jobs:
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v1
- name: Restore R package cache
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install system dependencies
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
- name: Install dependencies
run: |
install.packages(c("remotes"))
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual"), error_on = "warning", check_dir = "check")
shell: Rscript {0}

- name: Upload code coverage
if: runner.os == 'Linux'
run: covr::codecov()
run: |
options(crayon.enabled = TRUE)
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
path: check
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: malariasimulation
Title: An individual based model for malaria
Version: 1.0.2
Version: 1.1.0
Authors@R: c(
person(
given = "Giovanni",
Expand All @@ -19,7 +19,6 @@ License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Remotes:
mrc-ide/individual,
mrc-ide/malariaEquilibrium
Imports:
individual,
Expand All @@ -29,7 +28,8 @@ Imports:
MASS,
dqrng,
sitmo,
BH
BH,
R6
Suggests:
testthat,
mockery,
Expand Down
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ export(set_bednets)
export(set_clinical_treatment)
export(set_drugs)
export(set_equilibrium)
export(set_mass_rtss)
export(set_mda)
export(set_rtss)
export(set_rtss_epi)
export(set_smc)
export(set_species)
export(set_spraying)
Expand Down
32 changes: 16 additions & 16 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

create_adult_mosquito_model <- function(growth_model, mu, tau, susceptible) {
.Call(`_malariasimulation_create_adult_mosquito_model`, growth_model, mu, tau, susceptible)
create_adult_mosquito_model <- function(growth_model, mu, tau, susceptible, foim) {
.Call(`_malariasimulation_create_adult_mosquito_model`, growth_model, mu, tau, susceptible, foim)
}

adult_mosquito_model_update <- function(model, mu, foim, susceptible, f) {
invisible(.Call(`_malariasimulation_adult_mosquito_model_update`, model, mu, foim, susceptible, f))
}

create_adult_solver <- function(model, init, r_tol, a_tol) {
.Call(`_malariasimulation_create_adult_solver`, model, init, r_tol, a_tol)
create_adult_solver <- function(model, init, r_tol, a_tol, max_steps) {
.Call(`_malariasimulation_create_adult_solver`, model, init, r_tol, a_tol, max_steps)
}

create_aquatic_mosquito_model <- function(beta, de, mue, K0, gamma, dl, mul, dp, mup, total_M, model_seasonality, g0, g, h, R_bar, mum, f) {
.Call(`_malariasimulation_create_aquatic_mosquito_model`, beta, de, mue, K0, gamma, dl, mul, dp, mup, total_M, model_seasonality, g0, g, h, R_bar, mum, f)
}

aquatic_mosquito_model_update <- function(model, total_M, f, mum) {
invisible(.Call(`_malariasimulation_aquatic_mosquito_model_update`, model, total_M, f, mum))
}

create_aquatic_solver <- function(model, init, r_tol, a_tol, max_steps) {
.Call(`_malariasimulation_create_aquatic_solver`, model, init, r_tol, a_tol, max_steps)
}

create_history <- function(size, default_value) {
Expand All @@ -37,18 +49,6 @@ rainfall <- function(t, g0, g, h) {
.Call(`_malariasimulation_rainfall`, t, g0, g, h)
}

create_mosquito_model <- function(beta, de, mue, K0, gamma, dl, mul, dp, mup, total_M, model_seasonality, g0, g, h, R_bar) {
.Call(`_malariasimulation_create_mosquito_model`, beta, de, mue, K0, gamma, dl, mul, dp, mup, total_M, model_seasonality, g0, g, h, R_bar)
}

mosquito_model_update <- function(model, total_M, f, mum) {
invisible(.Call(`_malariasimulation_mosquito_model_update`, model, total_M, f, mum))
}

create_solver <- function(model, init, r_tol, a_tol) {
.Call(`_malariasimulation_create_solver`, model, init, r_tol, a_tol)
}

solver_get_states <- function(solver) {
.Call(`_malariasimulation_solver_get_states`, solver)
}
Expand Down
7 changes: 6 additions & 1 deletion R/biting_process.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,12 @@ simulate_bites <- function(

if (parameters$individual_mosquitoes) {
# update the ODE with stats for ovoposition calculations
mosquito_model_update(models[[s_i]], species_index$size(), f, mu)
aquatic_mosquito_model_update(
models[[s_i]],
species_index$size(),
f,
mu
)

# update the individual mosquitoes
susceptible_species_index <- susceptible_index$copy()$and(species_index)
Expand Down
17 changes: 11 additions & 6 deletions R/ode.R → R/compartmental.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ parameterise_mosquito_models <- function(parameters) {
function(i) {
p <- parameters$species_proportions[[i]]
m <- p * parameters$total_M
growth_model <- create_mosquito_model(
growth_model <- create_aquatic_mosquito_model(
parameters$beta,
parameters$del,
parameters$me,
Expand All @@ -22,7 +22,9 @@ parameterise_mosquito_models <- function(parameters) {
parameters$g0,
parameters$g,
parameters$h,
calculate_R_bar(parameters)
calculate_R_bar(parameters),
parameters$mum[[i]],
parameters$blood_meal_rates[[i]]
)

if (!parameters$individual_mosquitoes) {
Expand All @@ -37,7 +39,8 @@ parameterise_mosquito_models <- function(parameters) {
growth_model,
parameters$mum[[i]],
parameters$dem,
susceptible * parameters$init_foim
susceptible * parameters$init_foim,
parameters$init_foim
)
)
}
Expand All @@ -58,15 +61,17 @@ parameterise_solvers <- function(models, parameters) {
models[[i]],
init,
parameters$r_tol,
parameters$a_tol
parameters$a_tol,
parameters$ode_max_steps
)
)
}
create_solver(
create_aquatic_solver(
models[[i]],
init[ODE_INDICES],
parameters$r_tol,
parameters$a_tol
parameters$a_tol,
parameters$ode_max_steps
)
}
)
Expand Down
7 changes: 4 additions & 3 deletions R/correlation.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,15 @@ CorrelationParameters <- R6::R6Class(
#' parameters <- get_parameters()
#'
#' # Set some rtss strategy
#' parameters <- set_rtss(
#' parameters <- set_mass_rtss(
#' parameters,
#' timesteps = 100,
#' coverages = .9,
#' min_wait = 0,
#' min_ages = 100,
#' max_ages = 1000,
#' boosters = NULL,
#' booster_coverage = NULL
#' boosters = numeric(0),
#' booster_coverage = numeric(0)
#' )
#'
#' # Set some smc strategy
Expand Down
83 changes: 64 additions & 19 deletions R/events.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,46 @@ create_events <- function(parameters) {
# whether the infection is detected
detection = individual::TargetedEvent$new(parameters$human_population),

# Vaccination events
rtss_vaccination = individual::Event$new(),
rtss_booster = individual::TargetedEvent$new(parameters$human_population),
tbv_vaccination = individual::Event$new(),

# MDA events
mda_administer = individual::Event$new(),
smc_administer = individual::Event$new(),

# TBV event
tbv_vaccination = individual::Event$new(),

# Bednet events
throw_away_net = individual::TargetedEvent$new(parameters$human_population)
)

# Mass vaccination events
if (!is.null(parameters$rtss_mass_timesteps)) {
rtss_mass_doses <- lapply(
seq_along(parameters$rtss_doses),
function(.) individual::TargetedEvent$new(parameters$human_population)
)
rtss_mass_boosters <- lapply(
seq_along(parameters$rtss_mass_boosters),
function(.) individual::TargetedEvent$new(parameters$human_population)
)
events$rtss_mass_vaccination = individual::Event$new()
events$rtss_mass_doses <- rtss_mass_doses
events$rtss_mass_boosters <- rtss_mass_boosters
}

# EPI vaccination events
if (!is.null(parameters$rtss_epi_start)) {
rtss_epi_doses <- lapply(
seq_along(parameters$rtss_doses),
function(.) individual::TargetedEvent$new(parameters$human_population)
)
rtss_epi_boosters <- lapply(
seq_along(parameters$rtss_epi_boosters),
function(.) individual::TargetedEvent$new(parameters$human_population)
)
events$rtss_epi_doses <- rtss_epi_doses
events$rtss_epi_boosters <- rtss_epi_boosters
}

if (parameters$individual_mosquitoes) {
events <- c(
events,
Expand All @@ -45,9 +73,9 @@ initialise_events <- function(events, variables, parameters) {
)
}

# Initialise interventions
if (parameters$rtss) {
events$rtss_vaccination$schedule(parameters$rtss_timesteps[[1]] - 1)
# Initialise scheduled interventions
if (!is.null(parameters$rtss_mass_timesteps)) {
events$rtss_mass_vaccination$schedule(parameters$rtss_mass_timesteps[[1]] - 1)
}
if (parameters$mda) {
events$mda_administer$schedule(parameters$mda_timesteps[[1]] - 1)
Expand Down Expand Up @@ -175,22 +203,39 @@ attach_event_listeners <- function(
)
}

if (parameters$rtss == 1) {
events$rtss_vaccination$add_listener(
create_rtss_vaccination_listener(
# RTS,S listeners
if (!is.null(events$rtss_mass_doses)) {
# set up distribution
events$rtss_mass_vaccination$add_listener(
create_rtss_mass_listener(
variables,
events,
parameters,
correlations,
renderer
correlations
)
)
events$rtss_booster$add_listener(
create_rtss_booster_listener(
variables,
events,
parameters
)
attach_rtss_dose_listeners(
variables,
parameters,
events$rtss_mass_doses,
events$rtss_mass_boosters,
parameters$rtss_mass_boosters,
parameters$rtss_mass_booster_coverage,
'mass',
renderer
)
}

if (!is.null(events$rtss_epi_doses)) {
attach_rtss_dose_listeners(
variables,
parameters,
events$rtss_epi_doses,
events$rtss_epi_boosters,
parameters$rtss_epi_boosters,
parameters$rtss_epi_booster_coverage,
'epi',
renderer
)
}

Expand Down
Loading

0 comments on commit 0a4061c

Please sign in to comment.