Skip to content

Commit

Permalink
Make adjustments for linting + remove github installation code
Browse files Browse the repository at this point in the history
  • Loading branch information
kristinawlai committed Sep 27, 2024
1 parent d6e94d6 commit 5ccd677
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions vignettes/articles/enteric_fever_example.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,12 @@ knitr::opts_chunk$set(
### Load packages
The first step in conducting this analysis is to load our necessary packages. If you haven't installed already, you will need to do so before loading.

```{r setup, eval=FALSE}
# devtools::install_github("ucd-serg/serocalculator")
```


```{r load_packages}
library(serocalculator)
library(tidyverse)
library(forcats)
```


## Load data

Pathogen-specific sample datasets, noise parameters, and longitudinal antibody dynamics for **serocalculator** are available on the [Serocalculator Data Repository](https://osf.io/ne8pc/) on Open Science Framework (OSF). We will pull this data directly into our R environment.
Expand Down Expand Up @@ -133,9 +127,9 @@ We examine our cross-sectional antibody data by visualizing the distribution of
```{r plots}
#color palette
country.pal <- c('#EA6552', '#8F4B86', '#0099B4FF')
country.pal <- c("#EA6552", "#8F4B86", "#0099B4FF")

Check warning on line 130 in vignettes/articles/enteric_fever_example.Rmd

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=vignettes/articles/enteric_fever_example.Rmd,line=130,col=1,[object_name_linter] Variable and function name style should match snake_case or symbols.
xs_data %>% autoplot(strata = "Country", type = 'density') +
xs_data %>% autoplot(strata = "Country", type = "density") +
scale_fill_manual(values = country.pal)
```
Expand All @@ -147,7 +141,7 @@ 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") +
scale_fill_manual(values = country.pal) +
scale_x_log10(labels = scales::label_comma())
Expand All @@ -161,15 +155,15 @@ Let's also take a look at how antibody responses change by age.
#Plot antibody responses by age
ggplot(data = xs_data %>%
mutate(Country = fct_relevel(
mutate(Country = fct_relevel(
Country, "Bangladesh", "Pakistan", "Nepal"

Check warning on line 159 in vignettes/articles/enteric_fever_example.Rmd

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=vignettes/articles/enteric_fever_example.Rmd,line=159,col=11,[indentation_linter] Indentation should be 4 spaces but is 11 spaces.
)),
aes(x = age, y = value, color = Country)) +
geom_point(size = 0.6, alpha = 0.7) +
geom_smooth(method = "lm", se = FALSE) +
scale_y_log10() +
theme_linedraw() +
labs(title = "Quantitative Antibody Responses by Age", x = "Age", y = "Value") +
labs(title = "Quantitative Antibody Results by Age", x = "Age", y = "Value") +
scale_color_manual(values = country.pal)
```
Expand Down Expand Up @@ -231,7 +225,7 @@ Let's compare estimates across all countries and by age group.
```{r estbycountry}
#Using est.incidence.by (strata)
est_country_age = est.incidence.by(
est_country_age <- est.incidence.by(
strata = c("Country", "ageCat"),
pop_data = xs_data,
curve_params = curves,
Expand All @@ -257,18 +251,18 @@ est_country_agedf <- summary(est_country_age) %>%
ageCat = factor(ageCat)
)
## Create barplot with bars for each age category (rescale incidence rate and CIs)
## Create plot by country and age category
ggplot(est_country_agedf,
aes(
y = fct_rev(ageCat),
x = incidence.rate * 1000,
x = incidence.rate * 1000, #rescale incidence
fill = Country
)) +
geom_bar(stat = "identity",
position = position_dodge(),
show.legend = TRUE) +
geom_errorbar(
aes(xmin = CI.lwr * 1000, xmax = CI.upr * 1000),
aes(xmin = CI.lwr * 1000, xmax = CI.upr * 1000), #rescale CIs
position = position_dodge(width = 0.9),
width = .2
) +
Expand All @@ -292,7 +286,6 @@ rate_bangla <- round(est_country_agedf$incidence.rate[3] * 1000)
rate_nepal <- round(est_country_agedf$incidence.rate[1] * 1000)
rate_ratio_bangla_nepal <- round(rate_bangla / rate_nepal)
```

## Conclusions
Expand Down

0 comments on commit 5ccd677

Please sign in to comment.