From f5c369a84aa4e6861fadc72c9fa2707ae9bd3c7a Mon Sep 17 00:00:00 2001 From: jeffeaton Date: Thu, 2 Jan 2025 21:06:35 +0000 Subject: [PATCH 1/6] add national aggregate to PEPFAR Datapack CSV --- DESCRIPTION | 2 +- NEWS.md | 6 ++++++ R/pepfar-datapack.R | 21 ++++++++++++++++----- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 27626c74..92dd162c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: naomi Title: Naomi Model for Subnational HIV Estimates -Version: 2.10.2 +Version: 2.10.3 Authors@R: person(given = "Jeff", family = "Eaton", diff --git a/NEWS.md b/NEWS.md index 393c2bfa..aa4fa919 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# naomi 2.10.3 + +* Add national level aggregate to PEPFAR Target Setting Tool CSV. + - This also adds a new column `country_or_psnu` that codes values `"Country"` or `"PSNU"` + accordingly. If the PSNU level is national, the value `"Country"` will be coded. + # naomi 2.10.2 * Add ANC testing outputs to T4 projection period for including in PEPFAR datapack output. diff --git a/R/pepfar-datapack.R b/R/pepfar-datapack.R index d808b69a..5159d69d 100644 --- a/R/pepfar-datapack.R +++ b/R/pepfar-datapack.R @@ -67,6 +67,10 @@ write_datapack_csv <- function(naomi_output, warning("PSNU level ", psnu_level, " not included in model outputs.") } + ## PEPFAR Target Setting Tool 2025: select both PSNU level and national aggregates + ## Assume that national aggregate is level 0 + datapack_output_levels <- c(0L, psnu_level) + datapack_indicator_map$calendar_quarter <- naomi_output$meta_period$calendar_quarter[datapack_indicator_map$time] datapack_indicator_map <- datapack_indicator_map %>% @@ -113,9 +117,10 @@ write_datapack_csv <- function(naomi_output, dat <- indicators %>% dplyr::rename(sex_naomi = sex) %>% - dplyr::semi_join( + dplyr::inner_join( naomi_output$meta_area %>% - dplyr::filter(area_level == psnu_level), + dplyr::filter(area_level %in% datapack_output_levels) %>% + dplyr::select(area_id, area_level), by = "area_id" ) %>% dplyr::left_join( @@ -135,6 +140,7 @@ write_datapack_csv <- function(naomi_output, ) %>% dplyr::transmute( area_id, + area_level, indicator, indicator_sort_order, sex_naomi, @@ -149,7 +155,7 @@ write_datapack_csv <- function(naomi_output, dplyr::rename(age_sex_rse = rse) %>% dplyr::left_join( dplyr::filter(dat, age_group %in% c("Y000_999", "Y015_049")) %>% - dplyr::select(-indicator_sort_order, -age_group, -sex_naomi, -value) %>% + dplyr::select(-area_level, -indicator_sort_order, -age_group, -sex_naomi, -value) %>% dplyr::rename(district_rse = rse), by = c("area_id", "indicator", "calendar_quarter") ) %>% @@ -158,7 +164,7 @@ write_datapack_csv <- function(naomi_output, dplyr::select(area_name, area_id), by = "area_id" ) %>% - dplyr::arrange(calendar_quarter, indicator_sort_order, area_id, sex_naomi, age_group) + dplyr::arrange(calendar_quarter, indicator_sort_order, area_level, area_id, sex_naomi, age_group) dat$district_rse[is.na(dat$district_rse) & dat$indicator %in% c("circ_new", "circ_ever")] <- 0.0 @@ -176,6 +182,9 @@ write_datapack_csv <- function(naomi_output, dat <- dplyr::left_join(dat, psnu_map, by = "area_id") dat$psnu <- ifelse(is.na(dat$map_name), dat$area_name, dat$map_name) + ## Recode area_level as "Country" or "PSNU" + dat$country_or_psnu <- ifelse(dat$area_level == 0, "Country", "PSNU") + datapack <- dat %>% dplyr::select( psnu, @@ -190,7 +199,9 @@ write_datapack_csv <- function(naomi_output, calendar_quarter, value, age_sex_rse, - district_rse + district_rse, + country_or_psnu + ) naomi_write_csv(datapack, path) From e3302b1bf75a84b3961a496099c9206e6fad0b50 Mon Sep 17 00:00:00 2001 From: jeffeaton Date: Thu, 2 Jan 2025 21:27:30 +0000 Subject: [PATCH 2/6] remove .T2 indicators from PEPFAR datapack output --- NEWS.md | 1 + inst/datapack/datapack_indicator_mapping.csv | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index aa4fa919..32148c21 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,7 @@ * Add national level aggregate to PEPFAR Target Setting Tool CSV. - This also adds a new column `country_or_psnu` that codes values `"Country"` or `"PSNU"` accordingly. If the PSNU level is national, the value `"Country"` will be coded. +* Remove two-year ahead projection (`*.T2`) indicators from PEPFAR Target Setting Tool output. # naomi 2.10.2 diff --git a/inst/datapack/datapack_indicator_mapping.csv b/inst/datapack/datapack_indicator_mapping.csv index cc7b083d..3665542c 100644 --- a/inst/datapack/datapack_indicator_mapping.csv +++ b/inst/datapack/datapack_indicator_mapping.csv @@ -29,8 +29,5 @@ incidence,Incidence_SUBNAT.Rt.T,Incidence_SUBNAT.Rt.T,,FALSE,4 infections,NEW_INFECTIONS_SUBNAT.T,NEW_INFECTIONS_SUBNAT.T,,TRUE,4 plhiv,PLHIV_Residents.T,PLHIV_Residents.T,,TRUE,4 plhiv_attend,PLHIV_Attend.T,PLHIV_Attend.T,,TRUE,4 -infections,NEW_INFECTIONS_SUBNAT.T2,NEW_INFECTIONS_SUBNAT.T2,,TRUE,5 -plhiv,PLHIV_Residents.T2,PLHIV_Residents.T2,,TRUE,5 -plhiv_attend,PLHIV_Attend.T2,PLHIV_Attend.T2,,TRUE,5 circ_ever,ZayJeEa6pCa,VMMC_TOTALCIRC_SUBNAT.T_1,,TRUE,3 circ_new,SSun4i7nHlV,VMMC_CIRC_SUBNAT.T_1,,TRUE,3 \ No newline at end of file From 8371cde516e2728d46a16e297cb2d460956918a9 Mon Sep 17 00:00:00 2001 From: jeffeaton Date: Wed, 25 Sep 2024 16:03:03 -0400 Subject: [PATCH 3/6] add missing "aware_plhiv_attend" output to Datapack 1-9 output --- R/pepfar-datapack.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/pepfar-datapack.R b/R/pepfar-datapack.R index 5159d69d..679ed1d0 100644 --- a/R/pepfar-datapack.R +++ b/R/pepfar-datapack.R @@ -220,7 +220,7 @@ datapack_aggregate_1to9 <- function(indicators) { indicators_keep <- c("plhiv", "plhiv_attend", "untreated_plhiv_attend", "infections", - "population", "art_current", "art_current_residents", "aware_plhiv_num") + "population", "art_current", "art_current_residents", "aware_plhiv_num", "aware_plhiv_attend") indicators1to9 <- indicators %>% dplyr::filter( From b0e357f43be9c554325f1a75a5acf7071356324b Mon Sep 17 00:00:00 2001 From: jeffeaton Date: Thu, 2 Jan 2025 21:45:04 +0000 Subject: [PATCH 4/6] fix cruff --- DESCRIPTION | 1 - R/pepfar-datapack.R | 1 - 2 files changed, 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 63d55279..cb04f802 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,6 @@ Package: naomi Title: Naomi Model for Subnational HIV Estimates Version: 2.10.7 ->>>>>>> origin/master Authors@R: person(given = "Jeff", family = "Eaton", diff --git a/R/pepfar-datapack.R b/R/pepfar-datapack.R index 86e2255f..1aca73b5 100644 --- a/R/pepfar-datapack.R +++ b/R/pepfar-datapack.R @@ -208,7 +208,6 @@ build_datapack_output <- function(naomi_output, psnu_level, dmppt2_output) { age_sex_rse, district_rse, country_or_psnu - ) } From ceac44074b96f8eca2c25590ee1467ba029f8dd7 Mon Sep 17 00:00:00 2001 From: jeffeaton Date: Fri, 3 Jan 2025 12:47:52 +0000 Subject: [PATCH 5/6] bump version to 2.10.8 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index cb04f802..95ff1985 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: naomi Title: Naomi Model for Subnational HIV Estimates -Version: 2.10.7 +Version: 2.10.8 Authors@R: person(given = "Jeff", family = "Eaton", From 18c420926b3bd75a1bfed9a99c256bee376611f1 Mon Sep 17 00:00:00 2001 From: jeffeaton Date: Fri, 3 Jan 2025 20:47:16 +0100 Subject: [PATCH 6/6] remove new country_or_psnu column in PEPFAR datapack --- NEWS.md | 2 -- R/pepfar-datapack.R | 6 +----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/NEWS.md b/NEWS.md index 27031515..d72ab81c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,6 @@ # naomi 2.10.8 * Add national level aggregate to PEPFAR Target Setting Tool CSV. - - This also adds a new column `country_or_psnu` that codes values `"Country"` or `"PSNU"` - accordingly. If the PSNU level is national, the value `"Country"` will be coded. * Remove two-year ahead projection (`*.T2`) indicators from PEPFAR Target Setting Tool output. # naomi 2.10.7 diff --git a/R/pepfar-datapack.R b/R/pepfar-datapack.R index 1aca73b5..55531073 100644 --- a/R/pepfar-datapack.R +++ b/R/pepfar-datapack.R @@ -189,9 +189,6 @@ build_datapack_output <- function(naomi_output, psnu_level, dmppt2_output) { dat <- dplyr::left_join(dat, psnu_map, by = "area_id") dat$psnu <- ifelse(is.na(dat$map_name), dat$area_name, dat$map_name) - ## Recode area_level as "Country" or "PSNU" - dat$country_or_psnu <- ifelse(dat$area_level == 0, "Country", "PSNU") - dat %>% dplyr::select( psnu, @@ -206,8 +203,7 @@ build_datapack_output <- function(naomi_output, psnu_level, dmppt2_output) { calendar_quarter, value, age_sex_rse, - district_rse, - country_or_psnu + district_rse ) }