Created
March 15, 2018 11:37
-
-
Save seabbs/d412d50273a11d6fe652b7c628cea91c to your computer and use it in GitHub Desktop.
rif resistant TB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Get packages | |
if (!require(pacman)) install.packages("pacman"); library(pacman) | |
p_load_gh("seabbs/getTBinR") | |
p_load_gh("thomasp85/patchwork") | |
p_load("tidyverse") | |
p_load("ggridges") | |
p_load("viridis") | |
## Get data | |
tb <- get_tb_burden() | |
dict <- get_data_dict() | |
## Search for resistant variable | |
search_data_dict(def = "resistant") | |
## Get estimated incidence of rif res | |
tb_res <- tb %>% | |
mutate(rr_inc_rate = e_inc_rr_num / e_pop_num * 100000, | |
rr_inc_rate_lo = e_inc_rr_num_lo / e_pop_num * 100000, | |
rr_inc_rate_hi = e_inc_rr_num_lo / e_pop_num * 100000 | |
) | |
## Map of rifampicin resistance in previously treated cases | |
map_rr_inc_rates <- map_tb_burden(tb_res, | |
metric = "rr_inc_rate", | |
metric_label = "Incidence rate (per 100,000 population) of rifampicin resistant TB", | |
year = 2016, viridis_palette = "cividis") + | |
labs(title = "Map of Rifampicin Resistant TB Incidence Rates", | |
subtitle = "In 2016", | |
caption = "") | |
## 10 countries with the highest incidence rates of rif res | |
high_rif_res_countries <- tb_res %>% | |
filter(year == 2016) %>% | |
arrange(desc(rr_inc_rate)) %>% | |
slice(1:20) %>% | |
pull(country) | |
## Get overview for these countries | |
high_rr_countries_plot <- plot_tb_burden_overview(tb_res, | |
metric = "rr_inc_rate", | |
metric_label = "Incidence rate (per 100,000 population) of rifampicin resistant TB", | |
viridis_palette = "cividis", | |
viridis_direction = -1, | |
countries = high_rif_res_countries | |
) + | |
theme(legend.position = "none") + | |
labs(title = "Countries with the Highest Incidence Rate of Rifampicin Resistant TB", | |
subtitle = "Top 20 countries, in 2016", | |
caption = "") | |
## Distribution of new rif res cases by region in 2016 | |
dist_rif_res_new <- tb %>% | |
filter(year == 2016) %>% | |
ggplot(aes(y = g_whoregion, x = e_rr_pct_new, fill = g_whoregion)) + | |
geom_density_ridges() + | |
scale_fill_viridis(discrete = TRUE, option = "cividis", direction = -1, end = 0.9) + | |
theme_minimal() + | |
theme(legend.position = "none") + | |
labs(x = search_data_dict("e_rr_pct_new")$definition, | |
y = "Region", | |
caption = "", | |
title = "Estimated percentage of new TB cases with rifampicin resistant TB", | |
subtitle = "By region, in 2016") | |
## Distribution of previously treated rif res cases by region in 2016 | |
dist_rif_res_prev <- tb %>% | |
filter(year == 2016) %>% | |
ggplot(aes(y = g_whoregion, x = e_rr_pct_ret, fill = g_whoregion)) + | |
geom_density_ridges() + | |
scale_fill_viridis(discrete = TRUE, option = "cividis", direction = -1, end = 0.9) + | |
theme_minimal() + | |
theme(legend.position = "none") + | |
labs(x = search_data_dict("e_rr_pct_ret")$definition, | |
y = "Region", | |
title = "Estimated percentage of previously treated TB cases with rifampicin resistant TB", | |
subtitle = "By region, in 2016", | |
caption = "@seabbs Source: World Health Organisation") | |
storyboard <- (map_rr_inc_rates / high_rr_countries_plot) | (dist_rif_res_new / dist_rif_res_prev ) | |
ggsave("storyboard.png", | |
storyboard, width = 20, height = 15, dpi = 330) | |
storyboard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment