Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mrc-ide/first90release
https://github.com/mrc-ide/first90release
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mrc-ide/first90release
- Owner: mrc-ide
- License: other
- Created: 2019-01-24T01:17:53.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-10T11:02:05.000Z (4 months ago)
- Last Synced: 2024-08-10T12:22:25.819Z (4 months ago)
- Language: R
- Size: 2.7 MB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
fig.width = 5,
fig.height = 4)devtools::load_all("R")
library(data.table)
```
# first90![R CMD check](https://github.com/mrc-ide/first90release/actions/workflows/R-CMD-check.yml/badge.svg)
UNAIDS put forward the ambitious 90-90-90 target to end the AIDS epidemic by 2030. This target aims for 90% of people living with HIV (PLHIV) to be aware of their HIV-positive status, 90% of those diagnosed to receive antiretroviral therapy, and 90% of those on treatment to have a suppressed viral load by 2020 (each reaching 95% by 2030). HIV testing remains an important bottleneck in this cascade, however, and obtaining reliable epidemiological data on the proportion of PLHIV aware of their status is difficult. Such information is nevertheless crucial to effectively monitor HIV prevention efforts. Tracking progress towards achievement of this “first 90” target could be improved by combining population-based surveys and programmatic data on the number of HIV tests performed (and yield) in a coherent deterministic/statistical model. This type of integrative systems modelling is especially useful to fully consider HIV incidence, mortality, testing behaviours, as well as to coherently combine different sources of data.
The goal of the first90 package is to provide annual estimates of the proportion of PLHIV that are aware of their status, by combining estimates of PLHIV from EPP/Spectrum, annual programmatic data on the number of HIV tests performed (and yield), and nationally-representative survey of HIV testing behaviors.
## Installation
Install via Github using `devtools`:
``` r
devtools::install_github("mrc-ide/first90release")
```## Example: Malawi
This example demonstrates basic model steps.
```{r example, fig.height = 8, fig.width = 8, warning = FALSE}
# Read PJNZ file(s)
pjnz <- "~/Downloads/Malawi_2018_version_8.PJNZ"
cnt <- first90::read_country(pjnz)fp <- first90::prepare_inputs(pjnz)
# first90::prepare_inputs can also take a list of files, if using regional files
# e.g. fp <- first90::prepare_inputs(list.files("~/Documents/Data/", "CotedIvoire.*PJNZ$", full.names=TRUE, ignore.case=TRUE))
fp$popadjust <- FALSE# We visualize the PJNZ data
first90::plot_pjnz(fp)
```The following functions enable users to produce invidual plots.
```
pjnz_summary <- first90::get_pjnz_summary_data(fp)
first90::plot_pjnz_pop(pjnz_summary)
first90::plot_pjnz_plhiv(pjnz_summary)
first90::plot_pjnz_prv(pjnz_summary)
first90::plot_pjnz_inc(pjnz_summary)
``````{r, fig.height = 8, fig.width = 8, warning = FALSE}
age_group <- c('15-24','25-34','35-49')
# Import and prepare your survey data. See [guidance](SurveyDataGuidance.md)
survey_hts <- data.frame(country="Malawi",
surveyid="Survey1",
year=2000,
agegr="15-99",
sex="both",
outcome="evertest",
hivstatus="positive",
est=0.553,
se=0.0159,
ci_l=2.5652e-12,
ci_u=8958e-12,
counts=16168)dat <- first90::select_hts(survey_hts, cnt, age_group)
# Import and prepare your programmatic data. See [guidance](ProgramDataGuidance.md)
prgm_dat <- data.frame(country = "Malawi",
year = 2010,
sex = 'both',
agegr = "15-99",
tot = 215269,
totpos = 50115,
vct = 107634,
vctpos = 25057,
anc = 107635,
ancpos = 25058)
prg_dat <- first90::select_prgmdata(prgm_dat, cnt, age_group)# We visualize the program data
first90::plot_inputdata(prg_dat, fp)
```The following functions enable users to produce invidual plots.
```
first90::plot_input_tot(prgm_dat, fp)
first90::plot_input_totpos(prgm_dat, fp)
first90::plot_input_anctot(prgm_dat, fp)
first90::plot_input_ancpos(prgm_dat, fp)
```
```{r, fig.height = 10, fig.width = 8.5, warning = FALSE}
# ---- Enter parameters here ----
# We create the likelihood data
likdat <- first90::prepare_hts_likdat(dat, prg_dat, fp)# Starting parameters
data("theta0", package="first90")
first90::ll_hts(theta0, fp, likdat)opt <- optim(theta0, ll_hts, fp = fp, likdat = likdat, method = "BFGS",
control = list(fnscale = -1, trace = 4, REPORT = 1, maxit = 250), hessian = TRUE)simul <- first90::simul.test(opt, fp, sim = 400)
# ---- Plots for FITS ----
fp <- first90::create_hts_param(opt$par, fp)
mod <- first90::simmod(fp)# ---- The Fitted Parameters ----
first90::optimized_par(opt)# ---- Functions for individuals model fits ----
out_evertest <- first90::get_out_evertest(mod, fp)first90::plot_out(mod, fp, likdat, cnt, survey_hts, out_evertest, simul)
```
The model fits by age and sex.
```{r, fig.height = 5, fig.width = 8.5, warning=FALSE}
first90::plot_out_strat(mod, fp, likdat, cnt, survey_hts, out_evertest, simul)
```
The following functions enable users to produce invidual plots.
```
first90::plot_out_nbtest(mod, fp, likdat, cnt, simul)
first90::plot_out_nbpostest(mod, fp, likdat, cnt, simul)
first90::plot_out_evertestneg(mod, fp, likdat, cnt, survey_hts, out_evertest, simul)
first90::plot_out_evertestpos(mod, fp, likdat, cnt, survey_hts, out_evertest, simul)
first90::plot_out_evertest(mod, fp, likdat, cnt, survey_hts, out_evertest, simul)
first90::plot_out_90s(mod, fp, likdat, cnt, out_evertest, survey_hts, simul)
first90::plot_out_evertest_fbyage(mod, fp, likdat, cnt, survey_hts, out_evertest, simul)
first90::plot_out_evertest_mbyage(mod, fp, likdat, cnt, survey_hts, out_evertest, simul)
```
We can compare HIV tests' positivity through time, the estimated *true* yield of new HIV diagnoses, and compare those to population-level HIV prevalence.```{r, fig.height = 5, fig.width = 5, warning = FALSE}
graphics::par(mfrow = c(1,1))
first90::plot_prv_pos_yld(mod, fp, likdat, cnt, yr_pred = 2018)
```We can also examine some ouptuts related to the distribution of HIV tests performed in those susceptibles to HIV and PLHIV by different awareness and treatment status. (First sets of graphs is on the absolute scale, second one on the relative scale.)
```{r, fig.height = 5, fig.width = 8.5, warning = FALSE}
graphics::par(mfrow = c(1,2))
first90::plot_retest_test_neg(mod, fp, likdat, cnt)
first90::plot_retest_test_pos(mod, fp, likdat, cnt)graphics::par(mfrow = c(1,2))
first90::plot_retest_test_neg(mod, fp, likdat, cnt, relative = TRUE)
first90::plot_retest_test_pos(mod, fp, likdat, cnt, relative = TRUE)
```Finally, tabular outputs can be obtained by using the following functions.
```{r, warning = FALSE}
# ---- Tabular outputs ----
first90::tab_out_evertest(mod, fp, simul = simul)
first90::tab_out_aware(mod, fp, simul = simul)
first90::tab_out_nbaware(mod, fp)
first90::tab_out_artcov(mod, fp)
```## Running tests
Some tests require sample files. If you have access, Spectrum files are available on SharePoint [here](https://imperiallondon-my.sharepoint.com/:f:/r/personal/epidem_ic_ac_uk/Documents/UNAIDS%20Ref%20Group%20Shared%20Drive/Ref%20Group%20Meetings/Meetings%202018/first%2090%20workshop%20-%20Wisbech%20August%202018?csf=1&e=MFospr)
To use them, create a directory with `mkdir tests/testhat/sample_files` and copy the Malawi .PJNZ file into it.Or if you access to the private repo, you can clone it:
```
git clone [email protected]:mrc-ide/shiny90_sample_files tests/testthat/sample_files
```Then run
`r
devtools::test()
`