mphadsphiri/Quantitative-IGRA
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
# Summary
This project examines quantitative QuantiFERON-TB Gold Plus (QFT-Plus) responses using a Bayesian analysis workflow. The analysis focuses on the two QFT-Plus TB1 and TB2 responses, and their nil-subtracted IFN values. It describes participant characteristics, compares TB1 and TB2 response distributions, evaluates the correlation between the two tubes, and explores how clinical and demographic factors relate to response patterns.
# Data
The source data are stored in `data/data.rds`. The setup script reads this file, standardises the analysis variables.
Key variables used in the analysis include:
- age and age-group summaries
- sex
- HIV status & ART status
- fever history
- cough ≥2 weeks history
- previous TB treatment
- previous household TB contact
- raw and nil-subtracted TB1, TB2, nil, and mitogen values
- final QFT-Plus result (QFT-Plus software printout)
The setup code also derives several analysis variables, including TB1/TB2 tube-specific results, TB2-TB1 differential, a binary outcome for a TB2-TB1 differentoal > 0.6 IU/mL, and recalculated QFT-Plus results under alternative hypothetical thresholds.
# Workflow
The project is organised into four scripts:
1. `scripts/0_setup.R` prepares the environment and cleans the data.
2. `scripts/1_funcs.R` defines helper functions used for model summaries and threshold reclassification.
3. `scripts/2_models.R` fits the Bayesian models.
4. `scripts/3_output.R` creates tables & figures for manuscript
The main modelling components are:
- hurdle lognormal models for TB1 and TB2 responses among QFT-Plus positive participants
- models for the TB2-TB1 continuous difference
- multivariate correlation models for TB1 and TB2 nil-subtracted responses
- logistic models for the binary outcome that TB2-TB1 exceeds 0.6 IU/mL
- exploratory analyses across a range of antigen thresholds from 0.1 to 0.5 IU/mL (higher thresholds can be explored)
Age is modelled flexibly using spline terms for each sex, and several models adjust for HIV status, previous TB treatment, and household TB contact.
# Outputs
The output script is designed to produce the main descriptive and inferential outputs for the project, including:
- a participant characteristics table
- a distribution plot of TB1 and TB2 nil-subtracted values by age and sex
- predicted mean TB1 and TB2 response curves across age by sex
- model-based summaries for the Bayesian analyses
Results are intended for the `output/figures` and `output/tables` directories.
# Reproducibility
The analysis uses the `brms` interface with `cmdstanr` as the backend. The setup script sets key global options, defines iteration and warmup settings, and fixes the seed so model fitting is reproducible.
To reproduce the analysis, run the scripts in order after opening the project in RStudio:
```r
source("scripts/0_setup.R")
source("scripts/1_funcs.R")
source("scripts/2_models.R")
source("scripts/3_output.R")
```
# Session Info
R version 4.3.3 (2024-02-29)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS 26.3
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: Africa/Blantyre
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggbreak_0.1.5 scales_1.4.0 tidybayes_3.0.6 patchwork_1.2.0 brms_2.22.0
[6] Rcpp_1.1.0 cmdstanr_0.7.1 rstan_2.32.6 StanHeaders_2.32.10 posterior_1.6.0
[11] kableExtra_1.4.0 lubridate_1.9.4 stringr_1.5.1 readr_2.1.5 tibble_3.3.0
[16] ggplot2_3.5.2 tidyverse_2.0.0 purrr_1.0.4 forcats_1.0.0 tidyr_1.3.1
[21] dplyr_1.1.4 here_1.0.1
loaded via a namespace (and not attached):
[1] gridExtra_2.3 inline_0.3.19 rlang_1.1.6 magrittr_2.0.3 matrixStats_1.4.1
[6] compiler_4.3.3 mgcv_1.9-1 loo_2.8.0 systemfonts_1.2.3 vctrs_0.6.5
[11] pkgconfig_2.0.3 arrayhelpers_1.1-0 crayon_1.5.3 fastmap_1.2.0 backports_1.5.0
[16] labeling_0.4.3 utf8_1.2.6 rmarkdown_2.29 tzdb_0.5.0 ps_1.8.0
[21] xfun_0.52 aplot_0.2.8 jsonlite_2.0.0 parallel_4.3.3 R6_2.6.1
[26] stringi_1.8.7 RColorBrewer_1.1-3 estimability_1.5.1 knitr_1.50 bayesplot_1.11.1
[31] Matrix_1.6-5 splines_4.3.3 timechange_0.3.0 tidyselect_1.2.1 rstudioapi_0.16.0
[36] dichromat_2.0-0.1 abind_1.4-8 yaml_2.3.10 codetools_0.2-19 curl_6.4.0
[41] processx_3.8.4 pkgbuild_1.4.4 lattice_0.22-5 withr_3.0.2 bridgesampling_1.1-2
[46] coda_0.19-4.1 evaluate_1.0.4 gridGraphics_0.5-1 RcppParallel_5.1.9 ggdist_3.3.2
[51] xml2_1.3.8 pillar_1.11.0 tensorA_0.36.2.1 checkmate_2.3.2 stats4_4.3.3
[56] ggfun_0.1.9 distributional_0.4.0 generics_0.1.4 rprojroot_2.0.4 hms_1.1.3
[61] rstantools_2.4.0 xtable_1.8-4 glue_1.8.0 emmeans_1.10.6 tools_4.3.3
[66] data.table_1.16.4 fs_1.6.6 mvtnorm_1.3-3 grid_4.3.3 QuickJSR_1.3.1
[71] colorspace_2.1-1 nlme_3.1-164 cli_3.6.5 svUnit_1.0.6 viridisLite_0.4.2
[76] svglite_2.1.3 Brobdingnag_1.2-9 V8_6.0.4 gtable_0.3.6 yulab.utils_0.2.0
[81] digest_0.6.37 ggplotify_0.1.2 farver_2.1.2 htmltools_0.5.8.1 lifecycle_1.0.4
# Notes
This is a high-level description of the project structure and analysis.
# Licence
R scripts are licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Project data is licenced under CC BY 4.0 - see the [DATA_LICENSE](DATA_LICENSE) file for details.
Cite as [](https://doi.org/10.5281/zenodo.19390526)