Quickly and easily import analysis ready TB burden data, from the World Health Organisation (WHO), into R. The aim of the package is to speed up access to high quality TB burden data, using a simple R interface. Generic plotting functions are provided to allow for rapid graphical exploration of the WHO TB data. A shiny dashboard is built in to showcase package functionality. An automated report allows country level TB burden to be summarised. See here for the WHO data permissions. For help getting started see the Getting Started vignette and for a case study using the package see the Exploring Global Trends in Tuberculosis Incidence Rates vignette.
Lets get started quickly by mapping and then plotting TB incidence rates in the United Kingdom. First map the most recently available global TB incidence rates (this will also download and save both the TB burden data and its data dictionary, if they are not found locally, to R’s temporary directory),
getTBinR::map_tb_burden(metric = "e_inc_100k")
#> Downloading data from: https://extranet.who.int/tme/generateCSV.asp?ds=estimates
#> Saving data to: /tmp/RtmptQI6ty/TB_burden.rds
#> Downloading data from: https://extranet.who.int/tme/generateCSV.asp?ds=mdr_rr_estimates
#> Saving data to: /tmp/RtmptQI6ty/MDR_TB.rds
#> Joining TB burden data and MDR TB data.
#> Downloading data from: https://extranet.who.int/tme/generateCSV.asp?ds=dictionary
#> Saving data to: /tmp/RtmptQI6ty/TB_data_dict.rds
#> 1 results found for your variable search for e_inc_100k
Then compare TB incidence rates in the UK to TB incidence rates in other countries in the region,
getTBinR::plot_tb_burden_overview(metric = "e_inc_100k",
countries = "United Kingdom",
compare_to_region = TRUE,
interactive = FALSE)
#> Loading data from: /tmp/RtmptQI6ty/TB_burden.rds
#> Loading data from: /tmp/RtmptQI6ty/MDR_TB.rds
#> Joining TB burden data and MDR TB data.
#> Loading data from: /tmp/RtmptQI6ty/TB_data_dict.rds
#> 1 results found for your variable search for e_inc_100k
In order to compare the changes in incidence rates over time, in the region, plot the annual percentage change,
getTBinR::plot_tb_burden_overview(metric = "e_inc_100k",
countries = "United Kingdom",
compare_to_region = TRUE,
annual_change = TRUE,
interactive = FALSE)
#> Loading data from: /tmp/RtmptQI6ty/TB_burden.rds
#> Loading data from: /tmp/RtmptQI6ty/MDR_TB.rds
#> Joining TB burden data and MDR TB data.
#> Loading data from: /tmp/RtmptQI6ty/TB_data_dict.rds
#> 1 results found for your variable search for e_inc_100k
Now plot TB incidence rates over time in the United Kingdom, compared to TB incidence rates in Europe and globally.
getTBinR::plot_tb_burden_summary(metric = "e_inc_num",
metric_label = "e_inc_100k",
countries = "United Kingdom",
legend = "top",
compare_all_regions = FALSE,
compare_to_region = TRUE,
compare_to_world = TRUE,
interactive = FALSE)
#> Loading data from: /tmp/RtmptQI6ty/TB_data_dict.rds
#> 1 results found for your variable search for e_inc_100k
#> Extracting data for specified countries
#> Loading data from: /tmp/RtmptQI6ty/TB_burden.rds
#> Loading data from: /tmp/RtmptQI6ty/MDR_TB.rds
#> Joining TB burden data and MDR TB data.
#> Loading data from: /tmp/RtmptQI6ty/TB_data_dict.rds
#> 1 results found for your variable search for e_inc_num
#> Loading data from: /tmp/RtmptQI6ty/TB_burden.rds
#> Loading data from: /tmp/RtmptQI6ty/MDR_TB.rds
#> Joining TB burden data and MDR TB data.
#> Loading data from: /tmp/RtmptQI6ty/TB_data_dict.rds
#> 1 results found for your variable search for e_inc_num
#> Loading data from: /tmp/RtmptQI6ty/TB_burden.rds
#> Loading data from: /tmp/RtmptQI6ty/MDR_TB.rds
#> Joining TB burden data and MDR TB data.
#> Loading data from: /tmp/RtmptQI6ty/TB_data_dict.rds
#> 1 results found for your variable search for e_inc_num
Finally we repeat the above plot but this time only for the UK - this allows us to get a clear picture of trends in TB incidence rates in the UK.
getTBinR::plot_tb_burden(metric = "e_inc_100k",
countries = "United Kingdom",
interactive = FALSE)
#> Loading data from: /tmp/RtmptQI6ty/TB_burden.rds
#> Loading data from: /tmp/RtmptQI6ty/MDR_TB.rds
#> Joining TB burden data and MDR TB data.
#> Loading data from: /tmp/RtmptQI6ty/TB_data_dict.rds
#> 1 results found for your variable search for e_inc_100k
See Functions for more details of the functions used (note the fuzzy country matching, map_tb_burden
, plot_tb_burden_overview
, plot_tb_burden_summary
and plot_tb_burden
will try to exactly match your country request and if that fails will search for partial matches) and for more package functionality. We could make these plots interactive by specifying interactive = TRUE
To explore the package functionality in an interactive session, or to investigate TB without having to code extensively in R, a shiny dashboard has been built into the package. This can either be used locally using,
Or accessed online. Any metric in the WHO data can be explored, with country selection using the built in map, and animation possible by year.
Snapshot of the integrated dashboard.
To get a detailed overview of TB in a country of your choice run the following, alternatively available from the built in dashboard above.
## Code saves report into your current working directory
render_country_report(country = "United Kingdom", save_dir = ".")
Example report for the United Kingdom.
File an issue here if there is a feature, or a dataset, that you think is missing from the package, or better yet submit a pull request!
Please note that the getTBinR
project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
This package has been developed in docker based on the rocker/tidyverse
image, to access the development environment enter the following at the command line (with an active docker daemon running),
docker pull seabbs/gettbinr
docker run -d -p 8787:8787 -e USER=getTBinR -e PASSWORD=getTBinR --name getTBinR seabbs/gettbinr
The rstudio client can be accessed on port 8787
at localhost
(or your machines ip). The default username is getTBinR and the default password is getTBinR. Alternatively, access the development environment via binder.