From 51bf1a1a8275dfd5166ca4a0e8cba65e7c7f9d9a Mon Sep 17 00:00:00 2001 From: kristinawlai Date: Fri, 11 Oct 2024 17:59:14 -0700 Subject: [PATCH 1/5] Change axis label to specify log scale --- vignettes/articles/enteric_fever_example.Rmd | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vignettes/articles/enteric_fever_example.Rmd b/vignettes/articles/enteric_fever_example.Rmd index b7934dcb1..a14a8ad37 100644 --- a/vignettes/articles/enteric_fever_example.Rmd +++ b/vignettes/articles/enteric_fever_example.Rmd @@ -151,7 +151,9 @@ xs_data %>% mutate(Country = fct_relevel(Country, "Bangladesh", "Pakistan", "Nepal")) %>% autoplot(strata = "Country", type = "density") + scale_fill_manual(values = country_pal) + - scale_x_log10(labels = scales::label_comma()) + scale_x_log10(labels = scales::label_comma()) + + labs(x = "Log Antibody Response Value") + ``` From db6da497a8edc9a6dae64a8d7bcf64e4cae32b45 Mon Sep 17 00:00:00 2001 From: kristinawlai Date: Fri, 11 Oct 2024 18:11:04 -0700 Subject: [PATCH 2/5] increment version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index cd89fe11b..21eeb85e8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: serocalculator Title: Estimating Infection Rates from Serological Data -Version: 1.2.0.9016 +Version: 1.2.0.9017 Authors@R: c( person("Peter", "Teunis", , "p.teunis@emory.edu", role = c("aut", "cph"), comment = "Author of the method and original code."), From 2f532a7353f8c0d49e59e9ff1d4c9993f290c9b1 Mon Sep 17 00:00:00 2001 From: kristinawlai Date: Fri, 11 Oct 2024 21:13:44 -0700 Subject: [PATCH 3/5] remove extra white space for linting --- vignettes/articles/enteric_fever_example.Rmd | 1 - 1 file changed, 1 deletion(-) diff --git a/vignettes/articles/enteric_fever_example.Rmd b/vignettes/articles/enteric_fever_example.Rmd index a14a8ad37..0dc07e109 100644 --- a/vignettes/articles/enteric_fever_example.Rmd +++ b/vignettes/articles/enteric_fever_example.Rmd @@ -153,7 +153,6 @@ xs_data %>% scale_fill_manual(values = country_pal) + scale_x_log10(labels = scales::label_comma()) + labs(x = "Log Antibody Response Value") - ``` From ea992a9527415a9dcb4ebd278432414e34ca456c Mon Sep 17 00:00:00 2001 From: kristinawlai Date: Wed, 30 Oct 2024 13:32:35 -0700 Subject: [PATCH 4/5] Update log scaling to built in option --- vignettes/articles/enteric_fever_example.Rmd | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vignettes/articles/enteric_fever_example.Rmd b/vignettes/articles/enteric_fever_example.Rmd index 0dc07e109..87fb25520 100644 --- a/vignettes/articles/enteric_fever_example.Rmd +++ b/vignettes/articles/enteric_fever_example.Rmd @@ -149,9 +149,8 @@ We see that across countries, our data is highly skewed with the majority of res xs_data %>% mutate(Country = fct_relevel(Country, "Bangladesh", "Pakistan", "Nepal")) %>% - autoplot(strata = "Country", type = "density") + + autoplot(strata = "Country", type = "density", log = TRUE) + scale_fill_manual(values = country_pal) + - scale_x_log10(labels = scales::label_comma()) + labs(x = "Log Antibody Response Value") ``` From 50e63739dc49885bee09e6ed45d9410cf77f67f9 Mon Sep 17 00:00:00 2001 From: kristinawlai Date: Fri, 20 Dec 2024 10:47:50 -0800 Subject: [PATCH 5/5] draft bar plot --- R/autoplot.summary.seroincidence.by.bar.R | 29 ++++++++++++++++++++ vignettes/articles/enteric_fever_example.Rmd | 11 ++++---- 2 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 R/autoplot.summary.seroincidence.by.bar.R diff --git a/R/autoplot.summary.seroincidence.by.bar.R b/R/autoplot.summary.seroincidence.by.bar.R new file mode 100644 index 000000000..c871abac9 --- /dev/null +++ b/R/autoplot.summary.seroincidence.by.bar.R @@ -0,0 +1,29 @@ +#' Create bar plot for stratified seroincidence results +#' +#' +#' @return a [ggplot2::ggplot()] object + +autoplot.seroincidence.by.bar <- function(est_country_agedf, ageCat, incidence.rate, Country, CI.lwr, CI.upr, country_pal) { + ggplot(est_country_agedf, + aes( + y = fct_rev(ageCat), + x = incidence.rate * 1000, #rescale incidence + fill = Country + )) + + geom_bar(stat = "identity", + position = position_dodge2(reverse = TRUE), + show.legend = TRUE) + + geom_errorbar( + aes(xmin = CI.lwr * 1000, xmax = CI.upr * 1000), #rescale CIs + position = position_dodge2(reverse = TRUE) + ) + + labs(title = "Enteric Fever Seroincidence by Country and Age", + x = "Seroincidence rate per 1000 person-years", + y = "Age Category", + fill = "Country") + + theme_linedraw() + + theme(axis.text.y = element_text(size = 11), + axis.text.x = element_text(size = 11)) + + scale_x_continuous(expand = c(0, 10)) + + scale_fill_manual(values = country_pal) +} diff --git a/vignettes/articles/enteric_fever_example.Rmd b/vignettes/articles/enteric_fever_example.Rmd index 812307d74..4b07244dd 100644 --- a/vignettes/articles/enteric_fever_example.Rmd +++ b/vignettes/articles/enteric_fever_example.Rmd @@ -7,9 +7,11 @@ output: toc: true vignette: > %\VignetteIndexEntry{Enteric Fever Seroincidence Vignette} - %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} + %\VignetteEngine{knitr::rmarkdown} bibliography: ../references.bib +editor_options: + chunk_output_type: console --- ## Introduction @@ -281,15 +283,14 @@ ggplot(est_country_agedf, fill = Country )) + geom_bar(stat = "identity", - position = position_dodge(), + position = position_dodge2(reverse = TRUE), show.legend = TRUE) + geom_errorbar( aes(xmin = CI.lwr * 1000, xmax = CI.upr * 1000), #rescale CIs - position = position_dodge(width = 0.9), - width = .2 + position = position_dodge2(reverse = TRUE) ) + labs(title = "Enteric Fever Seroincidence by Country and Age", - x = "Seroincidence rate per 1000 person-years", + x = "Seroconversion rate per 1000 person-years", y = "Age Category", fill = "Country") + theme_linedraw() +