Skip to content

Commit 72f67b0

Browse files
committed
Update plots.
1 parent b30c33d commit 72f67b0

File tree

1 file changed

+116
-9
lines changed

1 file changed

+116
-9
lines changed

Reporting/Report/Report.qmd

Lines changed: 116 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ result <- purrr::map(csv_files, \(x){
3131
omopgenerics::bind() |>
3232
omopgenerics::newSummarisedResult()
3333
34+
result$additional_level <- gsub("&&&\\s+&&&", "&&& NULL &&&", result$additional_level)
35+
3436
resultList <- resultList |>
3537
purrr::map(\(x) {
3638
omopgenerics::settings(result) |>
@@ -115,9 +117,10 @@ outcome_counts <- data[["incidence"]] |>
115117
estimate_value = as.numeric(estimate_value)
116118
)
117119
118-
ggplot2::ggplot(outcome_counts, ggplot2::aes(x = outcome_cohort_name, y = estimate_value, fill = outcome_cohort_name)) +
120+
ggplot2::ggplot(outcome_counts, ggplot2::aes(x = cdm_name, y = estimate_value, fill = cdm_name)) +
119121
ggplot2::geom_bar(stat = "identity", colour = "black") +
120-
ggplot2::facet_wrap(~ cdm_name, scales = "free") +
122+
paletteer::scale_fill_paletteer_d("vapoRwave::vapoRwave") +
123+
ggplot2::facet_wrap(~ outcome_cohort_name, scales = "free") +
121124
ggplot2::theme(axis.text.x = ggplot2::element_blank())
122125
```
123126

@@ -139,23 +142,90 @@ char_3 <- data[["summarise_characteristics"]] |>
139142
estimate_value = as.numeric(estimate_value)
140143
) |>
141144
dplyr::filter(estimate_name == "percentage",
142-
estimate_value >= 10)
145+
estimate_value >= 5)
143146
144147
ggplot2::ggplot(char_3, ggplot2::aes(x = variable_level, y = estimate_value, fill = variable_level)) +
145148
ggplot2::geom_bar(stat = "identity", colour = "black") +
149+
paletteer::scale_fill_paletteer_d("vapoRwave::vapoRwave") +
146150
ggplot2::facet_wrap(~ cdm_name + group_level, scales = "free") +
147151
ggplot2::theme(axis.text.x = ggplot2::element_blank())
148152
```
149153

154+
155+
```{r prior use 2, echo=FALSE, message = FALSE, warning = FALSE}
156+
char_3 <- data[["summarise_characteristics"]] |>
157+
dplyr::filter(variable_name == "Antibiotics (-14 to -1)",
158+
strata_level == "overall") |>
159+
dplyr::mutate(cdm_name = dplyr::case_when(
160+
cdm_name == "IDRIL_1" ~ "Lancs",
161+
cdm_name == "LTHT" ~ "Leeds",
162+
cdm_name == "Barts Health" ~ "Barts",
163+
.default = cdm_name
164+
),
165+
group_level = stringr::str_replace(group_level, "^\\d+_", ""),
166+
group_level = stringr::str_to_sentence(group_level), # capitalize first letter
167+
variable_level = stringr::str_replace(variable_level, "^\\d+ ", ""), # remove leading digits and underscore
168+
variable_level = stringr::str_to_sentence(variable_level), # capitalize first letter
169+
estimate_value = as.numeric(estimate_value)
170+
) |>
171+
dplyr::filter(estimate_name == "percentage",
172+
!is.na(estimate_value),
173+
estimate_value >= 5)
174+
175+
ggplot2::ggplot(char_3, ggplot2::aes(x = cdm_name, y = estimate_value, fill = variable_level)) +
176+
ggplot2::geom_bar(stat = "identity", colour = "black") +
177+
ggplot2::facet_wrap(~ group_level, scales = "free") +
178+
ggplot2::theme(
179+
axis.text.x = ggplot2::element_text(angle = 90, vjust = 0.5, hjust = 1)
180+
) +
181+
ggplot2::ggtitle("Prior use of access antibiotics (-14 to -1)") +
182+
ggplot2::xlab("Database") +
183+
ggplot2::ylab("Percentage of Records") +
184+
ggplot2::labs(fill = "Access antibiotics") +
185+
paletteer::scale_fill_paletteer_d("vapoRwave::vapoRwave")
186+
```
187+
```{r prior use 3, echo=FALSE, message = FALSE, warning = FALSE}
188+
char_3 <- data[["summarise_characteristics"]] |>
189+
dplyr::filter(variable_name == "Antibiotics (-14 to -1)",
190+
strata_level == "overall") |>
191+
dplyr::mutate(cdm_name = dplyr::case_when(
192+
cdm_name == "IDRIL_1" ~ "Lancs",
193+
cdm_name == "LTHT" ~ "Leeds",
194+
cdm_name == "Barts Health" ~ "Barts",
195+
.default = cdm_name
196+
),
197+
group_level = stringr::str_replace(group_level, "^\\d+_", ""),
198+
group_level = stringr::str_to_sentence(group_level), # capitalize first letter
199+
variable_level = stringr::str_replace(variable_level, "^\\d+ ", ""), # remove leading digits and underscore
200+
variable_level = stringr::str_to_sentence(variable_level), # capitalize first letter
201+
estimate_value = as.numeric(estimate_value)
202+
) |>
203+
dplyr::filter(estimate_name == "percentage",
204+
!is.na(estimate_value),
205+
estimate_value >= 5)
206+
207+
ggplot2::ggplot(char_3, ggplot2::aes(x = cdm_name, y = estimate_value, fill = variable_level)) +
208+
ggplot2::geom_bar(stat = "identity", colour = "black", position = "dodge") +
209+
ggplot2::facet_wrap(~ group_level, scales = "free") +
210+
ggplot2::theme(
211+
axis.text.x = ggplot2::element_text(angle = 90, vjust = 0.5, hjust = 1)
212+
) +
213+
ggplot2::ggtitle("Prior use of access antibiotics (-14 to -1)") +
214+
ggplot2::xlab("Database") +
215+
ggplot2::ylab("Percentage of Records") +
216+
ggplot2::labs(fill = "Access antibiotics") +
217+
paletteer::scale_fill_paletteer_d("vapoRwave::vapoRwave")
218+
```
150219
## Figure 3 - Indications
151220

152221
```{r indications, echo=FALSE, message = FALSE, warning = FALSE}
153222
char_4 <- data[["summarise_characteristics"]] |>
154223
dplyr::filter(variable_name == "Indication flag",
155224
strata_level == "overall") |>
156225
dplyr::mutate(cdm_name = dplyr::case_when(
157-
cdm_name == "IDRIL_1" ~ "Lancashire",
226+
cdm_name == "IDRIL_1" ~ "Lancs",
158227
cdm_name == "LTHT" ~ "Leeds",
228+
cdm_name == "Barts Health" ~ "Barts",
159229
.default = cdm_name
160230
),
161231
group_level = stringr::str_replace(group_level, "^\\d+_", ""), # remove leading digits and underscore
@@ -165,14 +235,51 @@ char_4 <- data[["summarise_characteristics"]] |>
165235
estimate_value = as.numeric(estimate_value)
166236
) |>
167237
dplyr::filter(estimate_name == "percentage",
168-
estimate_value >= 10)
238+
estimate_value >= 5)
239+
240+
ggplot2::ggplot(char_4, ggplot2::aes(x = cdm_name, y = estimate_value, fill = variable_level)) +
241+
ggplot2::geom_bar(stat = "identity", colour = "black", position = "dodge") +
242+
ggplot2::facet_wrap(~ group_level, scales = "free") +
243+
ggplot2::theme(
244+
axis.text.x = ggplot2::element_text(angle = 90, vjust = 0.5, hjust = 1)
245+
) +
246+
ggplot2::ggtitle("Indications of Use") +
247+
ggplot2::xlab("Database") +
248+
ggplot2::ylab("Percentage of Records") +
249+
ggplot2::labs(fill = "Indications") +
250+
paletteer::scale_fill_paletteer_d("MetBrewer::Signac")
251+
```
252+
```{r indications 2, echo=FALSE, message = FALSE, warning = FALSE}
253+
char_4 <- data[["summarise_characteristics"]] |>
254+
dplyr::filter(variable_name == "Indication flag",
255+
strata_level == "overall") |>
256+
dplyr::mutate(cdm_name = dplyr::case_when(
257+
cdm_name == "IDRIL_1" ~ "Lancs",
258+
cdm_name == "LTHT" ~ "Leeds",
259+
cdm_name == "Barts Health" ~ "Barts",
260+
.default = cdm_name
261+
),
262+
group_level = stringr::str_replace(group_level, "^\\d+_", ""), # remove leading digits and underscore
263+
group_level = stringr::str_to_sentence(group_level), # capitalize first letter
264+
variable_level = stringr::str_replace(variable_level, "^\\d+ ", ""), # remove leading digits and underscore
265+
variable_level = stringr::str_to_sentence(variable_level), # capitalize first letter
266+
estimate_value = as.numeric(estimate_value)
267+
) |>
268+
dplyr::filter(estimate_name == "percentage",
269+
estimate_value >= 5)
169270
170-
ggplot2::ggplot(char_4, ggplot2::aes(x = group_level, y = estimate_value, fill = group_level)) +
271+
ggplot2::ggplot(char_4, ggplot2::aes(x = cdm_name, y = estimate_value, fill = variable_level)) +
171272
ggplot2::geom_bar(stat = "identity", colour = "black") +
172-
ggplot2::facet_wrap(~ cdm_name + variable_level, scales = "free") +
173-
ggplot2::theme(axis.text.x = ggplot2::element_blank())
273+
ggplot2::facet_wrap(~ group_level, scales = "free") +
274+
ggplot2::theme(
275+
axis.text.x = ggplot2::element_text(angle = 90, vjust = 0.5, hjust = 1)
276+
) +
277+
ggplot2::ggtitle("Indications of Use") +
278+
ggplot2::xlab("Database") +
279+
ggplot2::ylab("Percentage of Records") +
280+
ggplot2::labs(fill = "Indications") +
281+
paletteer::scale_fill_paletteer_d("MetBrewer::Signac")
174282
```
175-
176283
## Figure 4 - Incidence of Ciprofloxacin Use
177284

178285
```{r incidence, echo=FALSE, message = FALSE, warning = FALSE}

0 commit comments

Comments
 (0)