Title: | Mind the Gap |
---|---|
Description: | Package to tidy UNAIDS estimates (from the EDMS database) as well as plot trends in UNAIDS 95 goals and ART coverage gap by country. |
Authors: | Aaron Chafetz [aut], Karishma Srikanth [aut, cre], Lemlem Baraki [aut], Tim Essam [aut] |
Maintainer: | Karishma Srikanth <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.0.0 |
Built: | 2025-02-13 06:16:27 UTC |
Source: | https://github.com/USAID-OHA-SI/mindthegap |
This internal function adds a custom text annotation to a ggplot object, positioning it at a specified proportion of the plot's x and y axis ranges. The default annotation is used to indicate epidemic control.
adorn_annotation( p, annotation_label = "<-- Epidemic control", annotation_proportion = 0.9 )
adorn_annotation( p, annotation_label = "<-- Epidemic control", annotation_proportion = 0.9 )
p |
A ggplot2 plot object to which the annotation will be added. |
annotation_label |
A character string specifying the text to annotate the plot with. The default value is "<– Epidemic control". |
annotation_proportion |
A numeric value between 0 and 1 indicating the position of the annotation relative to the axis ranges. Default is 0.9, placing the annotation close to the top-right of the plot. |
This function calculates the annotation position based on the specified proportion of the plot's axis limits. The annotation is angled at 45 degrees to provide visual emphasis, typically used to indicate a threshold or a notable point in the data.
The original ggplot2 plot object with the annotation added.
This function creates a summary table showing OU progress toward the 95-95-95's (Deprecated)
base_plot( df, cntry, denom = c("PLHIV", "Relative"), grp = c("All", "Female 15+", "Male 15+", "Peds <15"), yr = NULL )
base_plot( df, cntry, denom = c("PLHIV", "Relative"), grp = c("All", "Female 15+", "Male 15+", "Peds <15"), yr = NULL )
df |
dataframe from |
cntry |
PEPFAR country to visualize (list OU name) |
denom |
which denominator/base to use, "PLHIV" (default) or "Relative" |
grp |
age/sex group, c("All", "Female 15+", "Male 15+", "Peds <15") |
yr |
year in question, defaults to max year |
Use tab_95s_progress
instead.
gt table
## Not run: df_unaids <- load_unaids() base_plot(df_unaids, "Kenya", denom = "PLHIV") base_plot(df_unaids, "Kenya", denom = "Relative") ## End(Not run)
## Not run: df_unaids <- load_unaids() base_plot(df_unaids, "Kenya", denom = "PLHIV") base_plot(df_unaids, "Kenya", denom = "Relative") ## End(Not run)
This function creates epidemic control curves for "ALL PEPFAR" or selected OU's
epi_plot(df, sel_cntry = c("All PEPFAR"))
epi_plot(df, sel_cntry = c("All PEPFAR"))
df |
UNAIDS data frame loaded from |
sel_cntry |
PEPFAR country to visualize ("ALL PEPFAR" as default or list OU names) |
Use plot_epi_trends()
instead.
Epidemic control plot showing trends in new infections and total deaths to HIV population
## Not run: df_unaids <- load_unaids(pepfar_only = FALSE) epi_plot(df_unaids) epi_plot(df_unaids, sel_cntry = "Lesotho") epi_plot(df_unaids, sel_cntry = c("South Africa", "Zambia", "Kenya", "Malawi")) ## End(Not run)
## Not run: df_unaids <- load_unaids(pepfar_only = FALSE) epi_plot(df_unaids) epi_plot(df_unaids, sel_cntry = "Lesotho") epi_plot(df_unaids, sel_cntry = c("South Africa", "Zambia", "Kenya", "Malawi")) ## End(Not run)
A dataframe containing the different indicators and their disaggregate components to ensure all data expected for are being exported from EDMS.
expected_ind
expected_ind
A data frame with 62 rows and 5 columns:
Parsed EDMS indicator name
EDMS indicator disaggregates
Source folder on EDMS
Expected as part of EDMS Epi + 95s pull (TRUE)
A mapping of the EDMS acronym
to common names used by OHA analysts.
indicator_map
indicator_map
A data frame with 21 rows and 3 columns:
EDMS Acronym
Parsed EDMS indicator name
Common indicator name
This function is used to load the latest UNAIDS data. These data were queried
and exported from UNAIDS EMDS database, cleaned
using munge_edms
and finally loaded up on GitHub as a release. This
function downloads the data and loads it into your working session.
load_unaids(pepfar_only = TRUE)
load_unaids(pepfar_only = TRUE)
pepfar_only |
filters dataset to only PEPFAR countries if TRUE (default = TRUE) |
df
## Not run: df_unaids <- load_unaids(pepfar_only = TRUE) ## End(Not run)
## Not run: df_unaids <- load_unaids(pepfar_only = TRUE) ## End(Not run)
Clean UNAIDS Data from EDMS
munge_edms(path, epi_95s_flag = TRUE)
munge_edms(path, epi_95s_flag = TRUE)
path |
filepath to the EDMS export (csv) |
epi_95s_flag |
add variables to dataframe for UNAIDS 95s achievement and epidemic control status, default = TRUE |
df
## Not run: filepath <- "../DataList_10_1_2030-12_00_00-AM.csv" df <- munge_edms(filepath) ## End(Not run)
## Not run: filepath <- "../DataList_10_1_2030-12_00_00-AM.csv" df <- munge_edms(filepath) ## End(Not run)
Deprecated. This function fetches and cleans UNAIDS Estimates/Test and Treat Data
munge_unaids(return_type, indicator_type)
munge_unaids(return_type, indicator_type)
return_type |
Returns either 'HIV Estimates' or 'HIV Test & Treat' Data |
indicator_type |
Returns either 'Integer' or 'Percent' indicator values |
df
## Not run: munge_unaids(return_type = "HIV Test & Treat", indicator_type = "Percent") ## End(Not run)
## Not run: munge_unaids(return_type = "HIV Test & Treat", indicator_type = "Percent") ## End(Not run)
This is a dataframe of countries that receive PEPFAR funding. This df comes
from glamr::pepfar_country_list
and is originally derived from the
PEPFAR Financial Structured Dataset (FSD).
pepfar
pepfar
A data frame with 55 rows and 2 columns:
Country name
Country ISO3 code
Generates a connected scatterplot of trajectories for deaths and new infections for specified countries.
plot_connected_scatter(.data, sel_cntry, year_range = 2010:2023)
plot_connected_scatter(.data, sel_cntry, year_range = 2010:2023)
.data |
A data frame containing epidemiological data. It should include columns such as |
sel_cntry |
A character vector of countries to include in the plot. |
year_range |
A numeric vector specifying the range of years to include in the analysis. Default is |
This function serves as a wrapper, orchestrating the preparation, calculation, and visualization of the data. It processes the input data, calculates appropriate axis limits, constructs the epidemic control plot, and finally adds an annotation for epidemic control.
A ggplot2 plot object showing the epidemic control trajectories with deaths on the x-axis and new infections on the y-axis.
## Not run: df_unaids <- load_unaids(pepfar_only = FALSE) plot_connected_scatter(df_unaids) plot_connected_scatter(df_unaids, sel_cntry = "Lesotho") plot_connected_scatter(df_unaids, sel_cntry = c("South Africa", "Zambia", "Kenya", "Malawi")) ## End(Not run)
## Not run: df_unaids <- load_unaids(pepfar_only = FALSE) plot_connected_scatter(df_unaids) plot_connected_scatter(df_unaids, sel_cntry = "Lesotho") plot_connected_scatter(df_unaids, sel_cntry = c("South Africa", "Zambia", "Kenya", "Malawi")) ## End(Not run)
This function creates epidemic control curves for "ALL PEPFAR" or selected OU's
plot_epi_trends(df, sel_cntry = c("All PEPFAR"))
plot_epi_trends(df, sel_cntry = c("All PEPFAR"))
df |
UNAIDS data frame loaded from |
sel_cntry |
PEPFAR country to visualize ("ALL PEPFAR" as default or list OU names) |
Epidemic control plot showing trends in new infections and total deaths to HIV population
## Not run: df_unaids <- load_unaids(pepfar_only = FALSE) plot_epi_trends(df_unaids) plot_epi_trends(df_unaids, sel_cntry = "Lesotho") plot_epi_trends(df_unaids, sel_cntry = c("South Africa", "Zambia", "Kenya", "Malawi")) ## End(Not run)
## Not run: df_unaids <- load_unaids(pepfar_only = FALSE) plot_epi_trends(df_unaids) plot_epi_trends(df_unaids, sel_cntry = "Lesotho") plot_epi_trends(df_unaids, sel_cntry = c("South Africa", "Zambia", "Kenya", "Malawi")) ## End(Not run)
This function filters and processes UNAIDS epidemiological data by selecting relevant indicators ("Number Total Deaths to HIV Population" and "Number New HIV Infections"), reshaping the data into a wide format, and renaming the resulting columns for readability. It is intended to prepare the dataset for a race to the bottom visualization.
prep_epi_data(df, sel_cntry, year_range)
prep_epi_data(df, sel_cntry, year_range)
df |
A data frame containing the pre-processed UNAIDS EDMS data. |
sel_cntry |
A character vector of country names for which data should be filtered. The function will filter the dataset to include only these countries. |
year_range |
A numeric vector specifying the range of years to filter the dataset by. Only data within this range will be retained. |
The function first filters the data to include only the selected countries (sel_cntry
),
specified year range (year_range
), and the indicators "Number Total Deaths to HIV Population"
and "Number New HIV Infections". It selects columns relevant for further analysis, reshapes the
data into a wide format, and renames the indicator columns to
deaths
and infections
for better readability. If no data matches the provided filters,
an error is thrown to inform the user.
A filtered and reshaped data frame containing the selected countries, indicators, and
years. The resulting data frame includes columns for region
, country
, year
, iso
, pepfar
,
and estimates of deaths
and infections
.
This function assumes that the dataset includes all age and sex categories set to "All". Make sure to provide a correctly formatted dataset and verify country names to avoid errors.
## Not run: # Load a sample UNAIDS dataset df_unaids <- load_unaids() # Assume this function loads your dataset # Prepare data for Lesotho for the years 2010-2023 df_prepared <- prep_epi_data(df_unaids, sel_cntry = "Lesotho", year_range = 2010:2023) ## End(Not run)
## Not run: # Load a sample UNAIDS dataset df_unaids <- load_unaids() # Assume this function loads your dataset # Prepare data for Lesotho for the years 2010-2023 df_prepared <- prep_epi_data(df_unaids, sel_cntry = "Lesotho", year_range = 2010:2023) ## End(Not run)
This is a developer's tool to take the output from EDMS that has been
tidied via munge_edms
and push it to GitHub as a
Release. This is
performed once annually when the data are updated and then users will
access via load_unaids
. This function posts versions for all countries
as well as PEPFAR only countries in csv and rds formats.
publish_release(df)
publish_release(df)
df |
dataframe created by |
munge_edms()
and load_unaids()
## Not run: filepath <- "../DataList_10_1_2030-12_00_00-AM.csv" df <- munge_edms(filepath) publish_release(df) ## End(Not run)
## Not run: filepath <- "../DataList_10_1_2030-12_00_00-AM.csv" df <- munge_edms(filepath) publish_release(df) ## End(Not run)
Deprecated.
Pull clean UNAIDS estimates data. Wrapper around
pull_unaids
.
pull_estimates(pepfar_only = TRUE)
pull_estimates(pepfar_only = TRUE)
pepfar_only |
filters dataset to only PEPFAR countries if TRUE (default = TRUE) |
df
## Not run: pull_estimates() ## End(Not run)
## Not run: pull_estimates() ## End(Not run)
Deprecated.
Pull clean UNAIDS 2022 (1990-2022) HIV Test & Treat data. Wrapper around
pull_unaids
.
pull_testtreat(pepfar_only = TRUE)
pull_testtreat(pepfar_only = TRUE)
pepfar_only |
filters dataset to only PEPFAR countries if TRUE (default = TRUE) |
df
## Not run: pull_testtreat() ## End(Not run)
## Not run: pull_testtreat() ## End(Not run)
Deprecated. Pull clean UNAIDS estimates
pull_unaids(data_type, pepfar_only = TRUE)
pull_unaids(data_type, pepfar_only = TRUE)
data_type |
returns one of 2 available data set types eg "HIV Estimates", "HIV Test & Treat" (or both if missing) |
pepfar_only |
filters dataset to only PEPFAR countries if TRUE (default = TRUE) |
df
## Not run: pull_unaids(data_type = "HIV Estimates", pepfar_only = TRUE) ## End(Not run)
## Not run: pull_unaids(data_type = "HIV Estimates", pepfar_only = TRUE) ## End(Not run)
This is a list of the key columns that are needed through the munging process for the clean export. The dataset originates from the UNAIDS EDMS Database.
req_cols
req_cols
Character vectors. A vector of length 11
Returns UNAIDS Source info for consistent sourcing notes
source_note
source_note
An object of class character
of length 1.
This function creates a summary table showing OU progress toward the 95-95-95's
tab_95s( df, cntry, denom = c("PLHIV", "Relative"), grp = c("All", "Female 15+", "Male 15+", "Peds <15"), yr = NULL )
tab_95s( df, cntry, denom = c("PLHIV", "Relative"), grp = c("All", "Female 15+", "Male 15+", "Peds <15"), yr = NULL )
df |
dataframe from |
cntry |
PEPFAR country to visualize (list OU name) |
denom |
which denominator/base to use, "PLHIV" (default) or "Relative" |
grp |
age/sex group, c("All", "Female 15+", "Male 15+", "Peds <15") |
yr |
year in question, defaults to max year |
gt table
## Not run: tab_95s(load_unaids(), "Kenya", denom = "PLHIV") tab_95s(load_unaids(), "Kenya", denom = "Relative") ## End(Not run)
## Not run: tab_95s(load_unaids(), "Kenya", denom = "PLHIV") tab_95s(load_unaids(), "Kenya", denom = "Relative") ## End(Not run)