Skip to content

Commit

Permalink
Merge pull request #40 from mrc-ide/gh-actions
Browse files Browse the repository at this point in the history
Migrate to github actions, qualify package names
  • Loading branch information
r-ash committed Mar 18, 2024
2 parents a0d28ce + 607d14b commit 36e722d
Show file tree
Hide file tree
Showing 25 changed files with 765 additions and 679 deletions.
8 changes: 7 additions & 1 deletion .Rbuildignore
@@ -1,5 +1,11 @@
^README\.Rmd$
^README\.md$
^\.idea$
^data-raw$
^LICENSE\.md$
^dev$
^.travis.yml$
^.*\.Rproj$
^\.Rproj\.user$
^.github$
^.ProgramDataGuidance\.md$
^.SurveyDataGuidance\.md$
1 change: 1 addition & 0 deletions .github/.gitignore
@@ -0,0 +1 @@
*.html
58 changes: 58 additions & 0 deletions .github/workflows/R-CMD-check.yaml
@@ -0,0 +1,58 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: actions/checkout@master
with:
repository: mrc-ide/shiny90_sample_files
## ${{ github.token }} is scoped to the current repository, so we
## need to provide our own PAT
token: ${{ secrets.SAMPLE_FILES_GH_PAT }}
path: tests/testthat/sample_files

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
error-on: '"error"'
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -7,7 +7,8 @@
.DS_Store
.idea
tests/testthat/sample_files
tests/testthat/Rplots.pdf
*.tar.gz
*.Rcheck

README.html
README.html
8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions DESCRIPTION
@@ -1,5 +1,5 @@
Package: first90
Version: 1.6.9
Version: 1.6.10
Title: The first90 model
Description: Implements the Shiny90 model for estimating progress towards the UNAIDS "first 90" target for HIV awareness of status in sub-Saharan Africa.
Authors@R:
Expand All @@ -25,7 +25,7 @@ Encoding: UTF-8
LazyData: true
ByteCompile: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Depends:
R (>= 2.10)
Imports:
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
@@ -1,6 +1,5 @@
# Generated by roxygen2: do not edit by hand

export()
export(add_ss_indices)
export(artcov15to49)
export(combine_inputs)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
@@ -1,3 +1,7 @@
# first90 1.6.10

* Qualify package names, fix some R CMD warnings and notes

# first90 1.6.9

* Bug fix: account for end-year net migration in the ART population in the first year of ART start (implemented in v1.6.0).
Expand Down
29 changes: 14 additions & 15 deletions R/create_hts_param.R
Expand Up @@ -60,32 +60,32 @@ create_hts_param <- function(theta, fp) {
n_k1 <- length(knots) - 1 # we remove 1995
n_k2 <- n_k1 + length(knots_rr_dxunt)
rate_f <- exp(theta[1:n_k1])
rr_dxunt <- plogis(theta[(n_k1 + 1):n_k2]) * 8 # Range is 0-8
rr_m <- plogis(theta[(n_k2 + 1):(n_k2 + 2)]) * 1.1
rr_test <- 0.95 + plogis(theta[(n_k2 + 3):(n_k2 + 4)]) * 7.05 # Range is 1-8
rr_plhiv <- 0.05 + plogis(theta[n_k2 + 5]) * (1.95 - 0.05)
rr_dxart <- plogis(theta[n_k2 + 6])
rr_25m <- 0.1 + plogis(theta[n_k2 + 7]) * (6 - 0.1)
rr_35m <- 0.1 + plogis(theta[n_k2 + 8]) * (6 - 0.1)
rr_25f <- 0.1 + plogis(theta[n_k2 + 9]) * (6 - 0.1)
rr_35f <- 0.1 + plogis(theta[n_k2 + 10]) * (6 - 0.1)
pr_oidx <- 0.25 + (plogis(theta[n_k2 + 11]) * (1.75 - 0.25))
rr_dxunt <- stats::plogis(theta[(n_k1 + 1):n_k2]) * 8 # Range is 0-8
rr_m <- stats::plogis(theta[(n_k2 + 1):(n_k2 + 2)]) * 1.1
rr_test <- 0.95 + stats::plogis(theta[(n_k2 + 3):(n_k2 + 4)]) * 7.05 # Range is 1-8
rr_plhiv <- 0.05 + stats::plogis(theta[n_k2 + 5]) * (1.95 - 0.05)
rr_dxart <- stats::plogis(theta[n_k2 + 6])
rr_25m <- 0.1 + stats::plogis(theta[n_k2 + 7]) * (6 - 0.1)
rr_35m <- 0.1 + stats::plogis(theta[n_k2 + 8]) * (6 - 0.1)
rr_25f <- 0.1 + stats::plogis(theta[n_k2 + 9]) * (6 - 0.1)
rr_35f <- 0.1 + stats::plogis(theta[n_k2 + 10]) * (6 - 0.1)
pr_oidx <- 0.25 + (stats::plogis(theta[n_k2 + 11]) * (1.75 - 0.25))

# Age function for males and females
agefn_m <- c(rep(1, 3), rep(rr_25m, 2), rep(rr_35m, 3), rr_35m * 0.8112) # last age group is 50+
agefn_f <- c(rep(1, 3), rep(rr_25f, 2), rep(rr_35f, 3), rr_35f * 0.8183) # last age group is 50+

# Time trends in testing rates
fp$t_hts_start <- as.integer(1995 - fp$ss$proj_start + 1L)
base_rate_f <- approx(knots, c(0, rate_f), seq_len(fp$ss$PROJ_YEARS), rule = 2)$y
base_rate_f <- stats::approx(knots, c(0, rate_f), seq_len(fp$ss$PROJ_YEARS), rule = 2)$y

knots_rr_m <- c(2005, 2012) - fp$ss$proj_start + 1L
rr_m <- approx(knots_rr_m, rr_m, seq_len(fp$ss$PROJ_YEARS), rule = 2)$y
rr_m <- stats::approx(knots_rr_m, rr_m, seq_len(fp$ss$PROJ_YEARS), rule = 2)$y
base_rate_m <- base_rate_f * rr_m

# Retest with time
knots_rr_test <- c(2005, 2010, 2015) - fp$ss$proj_start + 1L
rate_rr_test <- exp(approx(knots_rr_test, log(c(1, rr_test)), seq_len(fp$ss$PROJ_YEARS), rule = 2)$y)
rate_rr_test <- exp(stats::approx(knots_rr_test, log(c(1, rr_test)), seq_len(fp$ss$PROJ_YEARS), rule = 2)$y)

## Testing rate for HIV negative population:
## 1: never tested
Expand Down Expand Up @@ -147,7 +147,7 @@ create_hts_param <- function(theta, fp) {

## Relative testing among aware
# Re-testing rate among PLHIV aware (not on ART)
rate_dxunt <- approx(knots_rr_dxunt, rr_dxunt, seq_len(fp$ss$PROJ_YEARS), rule = 2)$y
rate_dxunt <- stats::approx(knots_rr_dxunt, rr_dxunt, seq_len(fp$ss$PROJ_YEARS), rule = 2)$y

diagn_rate_dxunt <- sweep(diagn_rate[,,,3,, drop = FALSE], 5, rate_dxunt, "*")
diagn_rate[,,,3,] <- diagn_rate_dxunt
Expand All @@ -162,4 +162,3 @@ create_hts_param <- function(theta, fp) {

fp
}

10 changes: 5 additions & 5 deletions R/extract-pjnz.R
Expand Up @@ -134,9 +134,9 @@ extract_pjnz <- function(pjnz = NULL, dp_file= NULL, pjn_file = NULL){
v$art15plus_num <- v$art15plus_num * adult_artadj_factor
}

v$art15plus_eligthresh <- setNames(as.numeric(dpsub(dp, "<CD4ThreshHoldAdults MV>", 2, col_idx)), proj_years)
v$art15plus_eligthresh <- stats::setNames(as.numeric(dpsub(dp, "<CD4ThreshHoldAdults MV>", 2, col_idx)), proj_years)

artelig_specpop <- setNames(dpsub(dp, "<PopsEligTreat MV>", 3:9, 2:6),
artelig_specpop <- stats::setNames(dpsub(dp, "<PopsEligTreat MV>", 3:9, 2:6),
c("description", "pop", "elig", "percent", "year"))
artelig_specpop$pop <- c("PW", "TBHIV", "DC", "FSW", "MSM", "IDU", "OTHER")
artelig_specpop$elig <- as.logical(as.integer(artelig_specpop$elig))
Expand All @@ -146,8 +146,8 @@ extract_pjnz <- function(pjnz = NULL, dp_file= NULL, pjn_file = NULL){
rownames(artelig_specpop) <- artelig_specpop$pop
v$artelig_specpop <- artelig_specpop

v$median_cd4init <- setNames(as.numeric(dpsub(dp, "<MedCD4CountInit MV>", 2, col_idx)), proj_years)
v$art_dropout <- setNames(as.numeric(dpsub(dp, "<PercLostFollowup MV>", 2, col_idx)), proj_years)
v$median_cd4init <- stats::setNames(as.numeric(dpsub(dp, "<MedCD4CountInit MV>", 2, col_idx)), proj_years)
v$art_dropout <- stats::setNames(as.numeric(dpsub(dp, "<PercLostFollowup MV>", 2, col_idx)), proj_years)

v$art_alloc_method <- get_dp_art_alloc_method(dp)
v$art_prop_alloc <- get_dp_art_prop_alloc(dp)
Expand Down Expand Up @@ -763,7 +763,7 @@ get_pjn_iso3 <- function(pjn){

#' @export
file_in_zip <- function(zfile, ext){
ff <- grep(ext, unzip(zfile, list = TRUE)$Name, value = TRUE)
ff <- grep(ext, utils::unzip(zfile, list = TRUE)$Name, value = TRUE)
unz(zfile, ff)
}

Expand Down
10 changes: 10 additions & 0 deletions R/first90-package.R
Expand Up @@ -5,3 +5,13 @@ NULL
#' @importFrom Rcpp sourceCpp
## usethis namespace: end
NULL

## Suppress R CMD check NOTEs about "no visible binding for
## global variable". These NOTEs aren't that important as we're using
## but the thousands of lines of NOTE they print does obscure real issues.
utils::globalVariables(c(
"DT", "PROJ_YEARS", "ag.idx", "agegr", "aglast.idx", "country", "f.idx",
"h.ag.span", "h.age15plus.idx", "h.fert.idx", "hAG", "hDS", "hTS",
"hiv_steps_per_year", "hivn.idx", "hivp.idx", "hivstatus", "logit", "m.idx",
"nearPD", "outcome", "p.age15plus.idx", "p.age15to49.idx", "p.fert.idx",
"pAG", "pDS", "quantile", "sex", "tot", "totpos", "year"))

0 comments on commit 36e722d

Please sign in to comment.