covidchildtb is a R package which includes code to analyse global
tuberculosis notifications. The analysis has been conducted to support
an academic manuscript which describes the change in global notifications in
childhood tuberculosis through the COVID pandemic.
The code to recreate this analysis has encapsulated within a R package.
You will need to have R installed on your local computer.
# devtools is required to install packages from Github
install.packages("devtools")
devtools::install_github("JayAchar/tb-covid-child-notifications")This will install the package covidchildtb on your computer. Uninstall it by
running the following code:
uninstall.packages("covidchildtb")The render_rmd function access package Rmarkdown templates to recreate
the analyses used for this study.
First create a local directory where files generated by the analysis can be saved and later reviewed.
Then run the code below to create the required data structures for the
analysis. Ensure that you substitute the output_dir argument with your
own directory path:
library(covidchildtb)
# specify your desired output directory
render_rmd(
"generate_prediction_data.Rmd",
output_dir = "~/Documents/covid-notifications"
)
After the data structures have been successfully created, it is possible to replicate the analysis using the code below:
render_rmd(
"generate_manuscript_artefacts.Rmd",
output_dir = "~/Documents/covid-notifications",
save_artefacts = TRUE,
plot_type = "png"
)As dependencies continue to develop, there's a strong chance that
the code in this package will no longer execute with newer packages.
To ensure the package continues to function correctly, a Dockerfiile
has been included in the repository.
To learn about and install Docker, please check their extensive documentation.
The docker image includes the covidchildtb package along with all
time-stamped (2020-06-30) R dependencies. The R-version is 4.0.4.
The image also serves an instance of RStudio which will be accessible through your default web browser when a container is running - see instructions below.
To build the docker image, you will first need to download this repository:
git clone https://github.com/JayAchar/tb-covid-child-notifications.gitNavigate into the newly created directory then build the image with the following commands:
cd tb-covid-child-notifications
docker build -t childtbcovid:latest .The build process requires internet access and will take a few minutes to complete.
After the image has been built, a container needs to be started to access the RStudio instance. Choose a directory on your computer where you would like to save any files that are created by the analysis. Substitue the placeholder in the code below with your chosen directory path.
docker run --name covidtb -d --rm\
-p 127.0.0.1:8787:8787 \
-v REPLACE_WITH_YOUR_DIRECTORY:/home/rstudio \
childtbcovid:latestAuthentication has been disabled for this image, so access to the open port is restricted to the local machine. It's not recommended to keep this container running for long periods since the image has not been optimised for security.
To open RStudio and execute the analysis, open your default web
browser and navigate to http://localhost:8787. You should immediately
be logged into the RStudio instance that's running in the container.
To be able to access any created files, the output_dir must be
set to /home/rstudio as below. Any created files will then be
available in the directory chosen on your local computer.
library(covidchildtb)
output_dir <- "/home/rstudio"
# specify your desired output directory
render_rmd(
"generate_prediction_data.Rmd",
output_dir = output_dir
)
render_rmd(
"generate_manuscript_artefacts.Rmd",
output_dir = output_dir,
save_artefacts = TRUE,
plot_type = "png"
)In your terminal run the following command to stop the container:
docker stop covidtbAny generated files will be available in your chosen directory.
Currently the templates used for model selection and data quality checking
are not functioning in this package format. They can be found at inst/rmd
in this repository if manual execution is required. They will eventually
be refactored to allow easier execution through the package workflow.
Please get in touch with Jay Achar if you have questions about the code contained in this repository. foo