Skip to content

Commit dd70521

Browse files
Remove provisional fns
1 parent f506502 commit dd70521

3 files changed

Lines changed: 2 additions & 161 deletions

File tree

NAMESPACE

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
export(basic_burden_sanity)
44
export(check_demography_alignment)
55
export(file_dict_colnames)
6-
export(impact_check)
76
export(plot_age_patterns)
87
export(plot_compare_demography)
98
export(plot_coverage_set)
@@ -18,11 +17,9 @@ export(prep_plot_fvp)
1817
export(prep_plot_global_burden)
1918
export(theme_vimc)
2019
export(theme_vimc_noxaxis)
21-
export(transform_coverage_fvps)
2220
export(validate_complete_incoming_files)
2321
export(validate_file_dict_template)
2422
export(validate_template_alignment)
25-
importFrom(dplyr,.data)
2623
importFrom(ggplot2,'%+replace%')
2724
importFrom(ggplot2,aes)
2825
importFrom(ggplot2,facet_grid)

R/burden_diagnositics.R

Lines changed: 1 addition & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ validate_complete_incoming_files <- function(
203203

204204
#' Check incoming burden set against template
205205
#'
206-
#' @description
206+
#' @description Identify extra and missing columns and rows in burden data.
207207
#'
208208
#' @param burden_set A `<data.frame>` of modeller-provided burden-set data.
209209
#'
@@ -389,159 +389,3 @@ basic_burden_sanity <- function(burden) {
389389

390390
mes
391391
}
392-
393-
#' @title
394-
#'
395-
#' @description
396-
#' A short description...
397-
#'
398-
#' @param coverage
399-
#'
400-
#' @param wpp
401-
#'
402-
#' @return
403-
#'
404-
#' @examples
405-
#' # example code
406-
#'
407-
#' @importFrom dplyr .data
408-
#'
409-
#' @keywords diagnostics
410-
#'
411-
#' @export
412-
transform_coverage_fvps <- function(coverage, wpp) {
413-
# TODO: checks on coverage
414-
# TODO: checks on wpp
415-
416-
cols_to_select <- c("age_from", "age_to", "gender")
417-
todo_list <- dplyr::select(
418-
coverage,
419-
{{ cols_to_select }}
420-
)
421-
todo_list <- dplyr::distinct(todo_list)
422-
todo_list <- dplyr::mutate(
423-
todo_list,
424-
job = seq_along(.data$gender)
425-
)
426-
427-
# TODO: THIS NEEDS TO BE CLEANED UP
428-
# TODO: clarify structure of `coverage` and mapping of gender to age
429-
pop_all <- list()
430-
for (i in seq_along(todo_list$age_from)) {
431-
x <- dplyr::filter(
432-
wpp,
433-
dplyr::between(.data$age, todo_list$age_from[i], todo_list$age_to[i]),
434-
.data$gender == todo_list$gender[i]
435-
)
436-
x <- dplyr::summarise(
437-
x,
438-
target_wpp = sum(.data$value),
439-
.by = c("country", "year")
440-
)
441-
x <- dplyr::mutate(
442-
x,
443-
job = todo_list$job[i]
444-
)
445-
446-
pop_all[[i]] <- x
447-
}
448-
pop_all <- dplyr::bind_rows(pop_all)
449-
450-
# TODO: add comments or explain in fn docs
451-
d <- dplyr::left_join(
452-
coverage,
453-
pop_all,
454-
by = c("country", "year")
455-
)
456-
d <- dplyr::mutate(
457-
d,
458-
target = dplyr::coalesce(
459-
.data$target,
460-
.data$target_wpp # replace NAs in target with target_wpp
461-
),
462-
fvps = .data$target * .data$coverage,
463-
fvps_adjusted = pmin(
464-
.data$target_wpp,
465-
.data$fvps
466-
),
467-
target_adjusted = pmin(
468-
.data$target_wpp,
469-
.data$target
470-
),
471-
coverage_adjusted = .data$fvps_adjusted / .data$target_adjusted
472-
)
473-
d[["target_wpp"]] <- NULL
474-
475-
d
476-
}
477-
478-
# TODO: fill out fn docs
479-
#' @title
480-
#'
481-
#' @description
482-
#'
483-
#' @param burden
484-
#'
485-
#' @param scenario_order
486-
#'
487-
#' @return
488-
#'
489-
#' @importFrom dplyr .data
490-
#'
491-
#' @examples
492-
#'
493-
#' @keywords diagnostics
494-
#'
495-
#' @export
496-
impact_check <- function(burden, scenario_order) {
497-
# TODO: input checks
498-
scenario_cols <- c("scenario", "scenario_order")
499-
scenario_order <- dplyr::select(scenario_order, {{ scenario_cols }})
500-
501-
d <- dplyr::summarise(
502-
burden,
503-
millions = sum(.data$value) / 1e6,
504-
.by = c("scenario", "burden_outcome"),
505-
.groups = "drop" # probably unnecessary as grouping is temporary
506-
)
507-
508-
d <- dplyr::left_join(
509-
d,
510-
scenario_order,
511-
by = "scenario"
512-
)
513-
514-
d <- dplyr::mutate(
515-
d,
516-
scenario_order = glue::glue("{.data$scenario_order}:{.data$scenario}")
517-
)
518-
519-
d$scenario <- NULL
520-
521-
d <- tidyr::pivot_wider(
522-
d,
523-
names_from = "scenario_order",
524-
values_from = "million"
525-
)
526-
527-
# TODO: CLEAN THIS UP
528-
for (i in 2:nrow(scenario_order)) {
529-
for (j in 1:(i - 1)) {
530-
if (any(d[i + 1] > d[j + 1])) {
531-
cat(sprintf(
532-
"&nbsp;&nbsp;&nbsp;&nbsp;**Warning**: provided less disease burden in lower coverage scenario (%s) compared to higher coverage scenario (%s).</span>",
533-
names(d)[j + 1],
534-
names(d)[i + 1]
535-
))
536-
cat("<br>")
537-
} else {
538-
cat(sprintf(
539-
"&nbsp;&nbsp;&nbsp;&nbsp;**PASS**: Provided higher disease burden in scenarios with fewer FVPs.</span>"
540-
))
541-
cat("<br>")
542-
}
543-
}
544-
}
545-
546-
d
547-
}

man/validate_template_alignment.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)