Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more fixes to website #303

Merged
merged 10 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: serocalculator
Title: Estimating Infection Rates from Serological Data
Version: 1.2.0.9015
Version: 1.2.0.9016
Authors@R: c(
person("Peter", "Teunis", , "[email protected]", role = c("aut", "cph"),
comment = "Author of the method and original code."),
Expand Down
5 changes: 3 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

* Add `as_noise_params` (#228)

* Updated `simulate_xsectionalData.Rmd()` (linting, removing deprecated functions).
* Updated `simulate_xsectionalData.Rmd` (linting, removing deprecated functions)
(#289)

* Added default value for `antigen_isos` argument in `log_likelihood()` (#286)

* Updated enteric fever example article with upgraded code and visualizations (#290)

* Added `Methodology` vignette (#284, #302)
* Added `Methodology` vignette (#284, #302, #303)

* Added template for reporting Issues
(from `usethis::use_tidy_issue_template()`) (#270)
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@
[![codecov](https://codecov.io/gh/UCD-SERG/serocalculator/graph/badge.svg?token=85CXV6GN2T)](https://codecov.io/gh/UCD-SERG/serocalculator)
<!-- badges: end -->

#> Warning: package 'qrcode' was built under R version 4.4.1
<div id="fig-website-QR">

![QR code for {serocalculator} website](man/figures/qr.svg)
![](man/figures/qr.svg)


Figure 1: QR code for `serocalculator` website

</div>

Antibody levels measured in a cross–sectional population sample can be
translated into an estimate of the frequency with which seroconversions
Expand Down
2 changes: 1 addition & 1 deletion README.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ code <- qr_code("https://ucd-serg.github.io/serocalculator/")
generate_svg(code, filename = "man/figures/qr.svg")
```

![QR code for {serocalculator} website](man/figures/qr.svg)
![QR code for `serocalculator` website](man/figures/qr.svg){#fig-website-QR}

Antibody levels measured in a cross–sectional population sample can be translated into an estimate of the frequency with which seroconversions (infections) occur in the sampled population.
In other words, the presence of many high antibody titers indicates that many individuals likely experienced infection recently and the burden of disease is high in the population,
Expand Down
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ template:
bootstrap: 5
light-switch: true

bibliography: vignettes/references.bib
2 changes: 1 addition & 1 deletion vignettes/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ methodology_files
*_files/
*.pptx
*.docx

/.quarto/
*.rmarkdown
2 changes: 1 addition & 1 deletion vignettes/articles/enteric_fever_example.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ vignette: >
%\VignetteIndexEntry{Enteric Fever Seroincidence Vignette}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
bibliography: ../references.bib
---
## Introduction

Expand Down
59 changes: 32 additions & 27 deletions vignettes/articles/scrubTyphus_example.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ vignette: >
%\VignetteIndexEntry{Scrub Typhus Seroincidence Vignette}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}

bibliography: ../references.bib

---
## Introduction
Expand Down Expand Up @@ -42,17 +42,23 @@ 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, message=FALSE}
# devtools::install_github("ucd-serg/serocalculator", eval=FALSE)
```
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.
We will also need to have the `tidyverse` and `mixtools` packages installed
for data manipulation and graphics operations we will perform in this vignette.
Please see the websites for
[`serocalculator`](https://ucd-serg.github.io/serocalculator/#installing-the-serocalculator-package),
[`tidyverse`](https://tidyverse.tidyverse.org/#installation),
and [`mixtools`](https://github.com/dsy109/mixtools?tab=readme-ov-file#installation)
for guidance on installing these packages into your R package library.

Once all three of those packages are installed, we can load them into
our active R session environment:

```{r load_packages}
library(serocalculator)
# install.packages("tidyverse")
library(tidyverse)
# install.packages("mixtools")
library(mixtools)
```

Expand Down Expand Up @@ -147,29 +153,31 @@ Column Name | Description

```{r message=FALSE, warning=FALSE}
# biologic noise
b.noise <- xs_data %>%
b_noise <- xs_data %>%
group_by(antigen_iso) %>%
filter(!is.na(value)) %>%
filter(age < 40) %>% # restrict to young ages to capture recent exposures
do({
set.seed(54321)
# Fit the mixture model
mixmod <- normalmixEM(.$value, k = 2, maxit = 1000) # k is the number of components, adjust as necessary
# Assuming the first component is the lower distribution
mixmod <- normalmixEM(.$value, k = 2, maxit = 1000)
# k is the number of components, adjust as necessary
# Assuming the first component is the lower distribution:
lower_mu <- mixmod$mu[1]
lower_sigma <- sqrt(mixmod$sigma[1])
# Calculate the 90th percentile of the lower distribution
percentile75 <- qnorm(0.75, lower_mu, lower_sigma)
# Return the results
data.frame(antigen_iso = .$antigen_iso[1], percentile75 = percentile75)
data.frame(antigen_iso = .$antigen_iso[1],
percentile75 = percentile75)
})



# define conditional parameters
noise <- data.frame(
antigen_iso = c("OT56kda_IgG", "OT56kda_IgM"),
nu = as.numeric(c(b.noise[2, 2], b.noise[1, 2])), # Biologic noise (nu)
nu = as.numeric(c(b_noise[2, 2], b_noise[1, 2])), # Biologic noise (nu)
eps = c(0.2, 0.2), # M noise (eps)
y.low = c(0.2, 0.2), # low cutoff (llod)
y.high = c(200, 200)
Expand Down Expand Up @@ -236,25 +244,22 @@ estdf <- summary(est) %>%
est2df <- summary(est2)


est.comb <- rbind(estdf, est2df)
est_comb <- rbind(estdf, est2df)

# Create barplot (rescale incidence rate and CIs)
ggplot(est.comb, aes(y = ageQ, x = incidence.rate * 1000, fill = country)) +
geom_bar(stat = "identity", position = position_dodge2(width = 0.8, preserve = "single")) +
ggplot(est_comb) +
aes(y = ageQ, x = incidence.rate * 1000, fill = country) +
geom_bar(stat = "identity",
position = position_dodge2(width = 0.8, preserve = "single")) +
geom_linerange(aes(xmin = CI.lwr * 1000, xmax = CI.upr * 1000),
position = position_dodge2(width = 0.8, preserve = "single")
) +
labs(
title = "Enteric Fever Seroincidence by Catchment Area",
x = "Seroincience rate per 1000 person-years",
y = "Catchment"
) +
position = position_dodge2(width = 0.8, preserve = "single")) +
labs(title = "Enteric Fever Seroincidence by Catchment Area",
x = "Seroincience rate per 1000 person-years",
y = "Catchment") +
theme_bw() +
facet_wrap(~country) +
theme(
axis.text.y = element_text(size = 11),
axis.text.x = element_text(size = 11)
) +
facet_wrap(~ country) +
theme(axis.text.y = element_text(size = 11),
axis.text.x = element_text(size = 11)) +
scale_fill_manual(values = c("orange2", "#39558CFF", "red"))
```

Expand Down
5 changes: 3 additions & 2 deletions vignettes/articles/serocalculator.Rmd
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
title: "Overview"
title: "Introduction to serocalculator"
description: >
A summary of the methods behind serocalculator.
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Overview}
%\VignetteIndexEntry{Introduction to serocalculator}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
bibliography: ../references.bib
---

## Overview
Expand Down
3 changes: 2 additions & 1 deletion vignettes/articles/simulate_xsectionalData.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
%\VignetteIndexEntry{simulate_xsectionalData}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
bibliography: ../references.bib
---


This vignette shows how to simulate a cross-sectional sample of
Expand Down Expand Up @@ -219,7 +220,7 @@
We can also graph the log-likelihoods, even without finding the MLEs, using `graph_loglik()`:

```{r}
lik_HlyE_IgA <-

Check warning on line 223 in vignettes/articles/simulate_xsectionalData.Rmd

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=vignettes/articles/simulate_xsectionalData.Rmd,line=223,col=1,[object_name_linter] Variable and function name style should match snake_case or symbols.
graph_loglik(
pop_data = csdata,
curve_params = dmcmc,
Expand All @@ -228,7 +229,7 @@
log_x = TRUE
)

lik_HlyE_IgG <- graph_loglik(

Check warning on line 232 in vignettes/articles/simulate_xsectionalData.Rmd

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=vignettes/articles/simulate_xsectionalData.Rmd,line=232,col=1,[object_name_linter] Variable and function name style should match snake_case or symbols.
previous_plot = lik_HlyE_IgA,
pop_data = csdata,
curve_params = dmcmc,
Expand Down
4 changes: 2 additions & 2 deletions vignettes/methodology.qmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Introduction to seroincidence estimation"
title: "Methodology"
vignette: >
%\VignetteIndexEntry{Introduction to seroincidence estimation}
%\VignetteIndexEntry{Methodology}
%\VignetteEngine{quarto::html}
%\VignetteEncoding{UTF-8}
---
Expand Down Expand Up @@ -204,7 +204,7 @@
```{r}
#| fig-cap: "Example log(likelihood) curves"
#| label: fig-loglik
lik_HlyE_IgA <- graph_loglik(

Check warning on line 207 in vignettes/methodology.qmd

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=vignettes/methodology.qmd,line=207,col=1,[object_name_linter] Variable and function name style should match snake_case or symbols.
pop_data = xs_data,
curve_params = curves,
noise_params = noise,
Expand All @@ -212,7 +212,7 @@
log_x = TRUE
)

lik_HlyE_IgG <- graph_loglik(

Check warning on line 215 in vignettes/methodology.qmd

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=vignettes/methodology.qmd,line=215,col=1,[object_name_linter] Variable and function name style should match snake_case or symbols.
previous_plot = lik_HlyE_IgA,
pop_data = xs_data,
curve_params = curves,
Expand Down
Loading