Skip to content

Commit

Permalink
Merge pull request #84 from opensafely/notebook-report
Browse files Browse the repository at this point in the history
Notebook report
  • Loading branch information
andrewscolm authored Feb 28, 2024
2 parents ee82a8a + 480a71e commit 7117274
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 12 additions & 8 deletions notebooks_r/report.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ library("ggsci")
library("glue")
library("ggalluvial")
library("ggrepel")
library("lubridate")
library("scales")
label_number_n <- label_number(1, 1, big.mark = ",")
Expand Down Expand Up @@ -268,12 +269,12 @@ new_ctv3_prop_table <- read_csv(here::here("output", "report_tables", "report_pa
### combine tables
combined_prop_table <- new_sus_prop_table %>%
left_join(ctv3_sus_prop_table, by = c("group", "subgroup", "population")) %>%
left_join(new_ctv3_prop_table, by = c("group", "subgroup", "population")) %>%
left_join(new_ctv3_prop_table, by = c("group", "subgroup", "population")) %>%
relocate(population, .after = last_col())
table_cols <- setNames(c("group", "", "SNOMED 2022", "SNOMED 2022 with SUS data", "SNOMED 2022 Percentage point increase\n with SUS data", "CTV3 2020", "CTV3 2020 with SUS data", "CTV3 2020 Percentage point increase\n with SUS data", "In both SNOMED and CTV3","Population"), names(combined_prop_table))
table_cols <- setNames(c("group", "", "SNOMED 2022", "SNOMED 2022 with SUS data", "SNOMED 2022 Percentage point increase\n with SUS data", "CTV3 2020", "CTV3 2020 with SUS data", "CTV3 2020 Percentage point increase\n with SUS data", "In both SNOMED and CTV3", "Population"), names(combined_prop_table))
SUS_gt <- combined_prop_table %>%
Expand Down Expand Up @@ -302,7 +303,7 @@ SUS_gt <- combined_prop_table %>%
) %>%
tab_header(
title = md("Table 1: Count of patients with a recorded ethnicity in OpenSAFELY-TPP (proportion of registered TPP population) by clinical and demographic subgroups. All counts are rounded to the nearest 5."),
)
)
SUS_gt
```
Expand Down Expand Up @@ -504,10 +505,10 @@ combined_prop_5_table <- ctv3_SUS5 %>%
left_join(new_SUS5, by = c("group", "subgroup")) %>%
rename_with(~ gsub(" 5", "", .)) %>% # remove extra 5
rename_with(~ gsub("CTV3 ", "CTV3:2020 ", .)) %>% # remove extra 5
select("group", "subgroup", sort(names(.))) %>%
select("group", "subgroup", sort(names(.))) %>%
relocate(contains("Other"), .after = last_col())
my_cols <- setNames(c("group", "", rep(c("CTV3 2020", "CTV3 2020 with SUS", "SNOMED 2022", "SNOMED 2022 with SUS"), 5)), names(combined_prop_5_table))
SUS5 <- combined_prop_5_table %>%
Expand Down Expand Up @@ -1204,7 +1205,7 @@ df_sus_new_cross_table_ctv3
<br>

```{r, fig.width=20, fig.height=15}
# alluvial_new
alluvial_new
```

<br>
Expand All @@ -1215,7 +1216,7 @@ df_sus_new_cross_table_new
<br>

```{r, fig.width=20, fig.height=15}
# alluvial_new
alluvial_new
```

<br>
Expand Down Expand Up @@ -1676,7 +1677,10 @@ This report describes existing methods to derive primary care ethnicity in OpenS

# Technical details

This notebook was run on `r Sys.Date()`. The information is based on data extracted from the OpenSAFELY-TPP database on `r date(file.info(here::here("output","extract_5","input_5.feather"))$ctime)`.
```{r}
extract_date <- file.info(here::here("output", "extract_5", "input_5.feather"))$ctime
```
This notebook was run on `r Sys.Date()`. The information is based on data extracted from the OpenSAFELY-TPP database on `r date(extract_date)`.

If a clinical code appears in the primary care record on multiple dates, the latest date is used.

Expand Down
2 changes: 1 addition & 1 deletion project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ actions:
##### draft report
generate_draft_report_rmd:
run: r:latest -e 'rmarkdown::render("notebooks_r/report.Rmd", knit_root_dir = "/workspace", output_dir="/workspace/output/report")'
needs: [generate_ons_comparisons,report_tables, execute_simple_validation_analyses,execute_simple_validation_analyses_16,execute_simple_validation_analyses_sus,execute_simple_validation_analyses_16_sus]
needs: [generate_ons_comparisons,report_tables, execute_simple_validation_analyses,execute_simple_validation_analyses_16,execute_simple_validation_analyses_sus,execute_simple_validation_analyses_16_sus,generate_study_population_5]
outputs:
moderately_sensitive:
html: output/report/report.html
Expand Down

0 comments on commit 7117274

Please sign in to comment.