Skip to content

Commit

Permalink
Merge pull request #18 from opensafely/update-report
Browse files Browse the repository at this point in the history
Update report
  • Loading branch information
acagreen17 authored Mar 18, 2022
2 parents ac38439 + fba31e4 commit f878423
Show file tree
Hide file tree
Showing 27 changed files with 6,088 additions and 5,444 deletions.
34 changes: 15 additions & 19 deletions analysis/descriptive/coverage_report_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,7 @@ plot_data_treated_groups <- data_processed_clean %>%
summarise(n = sum(n, na.rm = T)) %>%
group_by(high_risk_cohort, treatment_type) %>%
mutate(count = ifelse(is.na(n), 0, n),
cum_count = cumsum(count),
cum_count_redacted = plyr::round_any(cum_count, 10)) %>%
count_redacted = plyr::round_any(count, 10)) %>%
select(-n) %>%
arrange(high_risk_cohort, treatment_type, week)

Expand All @@ -302,8 +301,7 @@ plot_data_treated_all <- data_processed_clean %>%
group_by(treatment_type, week) %>%
tally() %>%
mutate(count = ifelse(is.na(n), 0, n),
cum_count = cumsum(count),
cum_count_redacted = plyr::round_any(cum_count, 10),
count_redacted = plyr::round_any(count, 10),
high_risk_cohort = "All") %>%
select(-n) %>%
arrange(high_risk_cohort, treatment_type, week) %>%
Expand All @@ -327,8 +325,7 @@ plot_data_groups <- data_processed_clean %>%
summarise(n = sum(n, na.rm = T)) %>%
group_by(high_risk_cohort) %>%
mutate(count = ifelse(is.na(n), 0, n),
cum_count = cumsum(count),
cum_count_redacted = plyr::round_any(cum_count, 10)) %>%
count_redacted = plyr::round_any(count, 10)) %>%
select(-n) %>%
arrange(high_risk_cohort, week)

Expand All @@ -341,8 +338,7 @@ plot_data_all <- data_processed_clean %>%
group_by(week) %>%
tally() %>%
mutate(count = ifelse(is.na(n), 0, n),
cum_count = cumsum(count),
cum_count_redacted = plyr::round_any(cum_count, 10),
count_redacted = plyr::round_any(count, 10),
high_risk_cohort = "All") %>%
select(-n) %>%
arrange(high_risk_cohort, week) %>%
Expand All @@ -353,10 +349,10 @@ print(head(plot_data_all))
plot_data_prop_treated <- left_join(plot_data_treated_all, plot_data_all,
by = c("high_risk_cohort", "week")) %>%
mutate(week = as.Date(week) - 2,
Treated = ifelse(is.na(cum_count_redacted.x), 0, cum_count_redacted.x),
Total = ifelse(is.na(cum_count_redacted.y), 0, cum_count_redacted.y),
Treated = ifelse(is.na(count_redacted.x), 0, count_redacted.x),
Total = ifelse(is.na(count_redacted.y), 0, count_redacted.y),
prop = Treated/Total,
prop_redacted = ifelse((Total < threshold | Treated < threshold), NA, round(prop, digits = 2)))
prop_redacted = ifelse((Total < threshold | Treated < threshold), NA, round(prop, digits = 4)))

write_csv(plot_data_prop_treated %>% select(elig_start = week, prop_redacted, treatment_type, high_risk_cohort),
fs::path(output_dir, "table_prop_treated_redacted.csv"))
Expand Down Expand Up @@ -549,7 +545,7 @@ data_flowchart <- non_elig_treated %>%
values_to="n"
) %>%
mutate(n = ifelse(n < 5 & n > 0, "<5", n),
n = ifelse(n != "<5", plyr::round_any(as.numeric(n), 5), n))
n = ifelse(n != "<5", plyr::round_any(as.numeric(n), 10), n))

all_treated <- data_processed_clean %>%
filter(!is.na(treatment_date),
Expand Down Expand Up @@ -621,7 +617,7 @@ data_flowchart2 <- all_treated %>%
values_to="n"
) %>%
mutate(n = ifelse(n < 5 & n > 0, "<5", n),
n = ifelse(n != "<5", plyr::round_any(as.numeric(n), 5), n))
n = ifelse(n != "<5", plyr::round_any(as.numeric(n), 10), n))

write_csv(rbind(data_flowchart, data_flowchart2), fs::path(output_dir, "table_non_elig_flowchart_redacted.csv"))

Expand All @@ -639,7 +635,7 @@ high_risk_cohort_comparison_redacted <- data_processed_clean %>%
tally() %>%
arrange(desc(n)) %>%
mutate(n = ifelse(n < 5, NA, n),
n = plyr::round_any(as.numeric(n), 5))
n = plyr::round_any(as.numeric(n), 10))

write_csv(high_risk_cohort_comparison_redacted, fs::path(output_dir, "table_non_elig_high_risk_cohort_comparison_redacted.csv"))

Expand All @@ -652,7 +648,7 @@ all <- data_processed_clean %>%
tally() %>%
mutate(high_risk_cohort = "All",
n = ifelse(n < 5, NA, n),
n = plyr::round_any(as.numeric(n), 5)) %>%
n = plyr::round_any(as.numeric(n), 10)) %>%
filter(!is.na(n))

groups <- data_processed_clean %>%
Expand All @@ -672,7 +668,7 @@ groups <- data_processed_clean %>%
values_to = "n"
) %>%
mutate(n = ifelse(n < 5, NA, n),
n = plyr::round_any(as.numeric(n), 5)) %>%
n = plyr::round_any(as.numeric(n), 10)) %>%
filter(!is.na(n))

groups2 <- data_processed_clean %>%
Expand All @@ -692,7 +688,7 @@ groups2 <- data_processed_clean %>%
values_to = "n"
) %>%
mutate(n = ifelse(n < 5, NA, n),
n = plyr::round_any(as.numeric(n), 5),
n = plyr::round_any(as.numeric(n), 10),
variable = group) %>%
filter(!is.na(n))

Expand All @@ -708,7 +704,7 @@ for (i in 1:length(groups_tte)) {
group_by_all() %>%
tally() %>%
mutate(n = ifelse(n < 5, NA, n),
n = plyr::round_any(as.numeric(n), 5),
n = plyr::round_any(as.numeric(n), 10),
group = groups_tte[i]) %>%
filter(!is.na(n))

Expand Down Expand Up @@ -745,7 +741,7 @@ all <- data_processed_clean %>%
values_to = "Count"
) %>%
mutate(Count = ifelse(Count < 5, NA, Count),
Count = plyr::round_any(as.numeric(Count), 5)) %>%
Count = plyr::round_any(as.numeric(Count), 10)) %>%
pivot_wider(names_from = treated_status, values_from = Count) %>%
mutate(treated_tot = data_processed_clean %>% filter(!is.na(treatment_type)) %>% nrow(),
treated_perc = round(treated/treated_tot*100, digits = 0),
Expand Down
1 change: 0 additions & 1 deletion project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ actions:
moderately_sensitive:
html: output/coverage/sa_symptomatic_test.html


# Report ----
report_data:
run: r:latest analysis/descriptive/coverage_report_data.R
Expand Down
246 changes: 246 additions & 0 deletions released_outputs/reports/coverage/sa_symptomatic_test.html

Large diffs are not rendered by default.

Loading

0 comments on commit f878423

Please sign in to comment.