Skip to content

Commit

Permalink
Published documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Dec 28, 2021
0 parents commit ca66758
Show file tree
Hide file tree
Showing 10 changed files with 1,854 additions and 0 deletions.
12 changes: 12 additions & 0 deletions footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
 
<hr />
<p style="text-align: center;">Developed by <a href="https://samabbott.co.uk/about">Sam Abbott</a>, Katharine Sherratt, and Sebastian Funk </p>
<!-- Add icon library -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<!-- Add font awesome icons -->
<p style="text-align: center;">
<a href="https://github.com/epiforecasts/omicron-sgtf-forecast/" class="fa fa-github"></a>
</p>

&nbsp;
1 change: 1 addition & 0 deletions header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<a href="https://github.com/epiforecasts/omicron-sgtf-forecast" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#70B7FD; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
74 changes: 74 additions & 0 deletions library.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
@Manual{R,
title = {R: A Language and Environment for Statistical Computing},
author = {{R Core Team}},
organization = {R Foundation for Statistical Computing},
address = {Vienna, Austria},
year = {2019},
url = {https://www.R-project.org/},
}

@Manual{cmdstanr,
title = {cmdstanr: R Interface to 'CmdStan'},
author = {Jonah Gabry and Rok Češnovar},
year = {2021},
note = {https://mc-stan.org/cmdstanr, https://discourse.mc-stan.org},
}

@Manual{stan,
title = {Stan Modeling Language Users Guide and Reference Manual, 2.28.1},
author = {Stan Development Team},
year = {2021},
note = {https://mc-stan.org},
}

@Manual{scoringutils,
title = {scoringutils: A collection of proper scoring rules and metrics to assess predictions},
author = {Nikos Bosse},
year = {2020},
note = {R package version 0.0.0.9000},
url = {https://github.com/epiforecasts/scoringutils}
}

@Article{betancourt_2017,
title={Diagnosing biased inference with divergences},
author={Betancourt, Michael},
year={2017},
volume={4},
journal={Stan Case Studies},
url={https://mc-stan.org/users/documentation/case-studies/divergences_and_bias.html}
}

@Article{forecast.vocs,
title = {forecast.vocs: Forecast case and sequence notifications using variant of concern strain dynamics},
author = {Sam Abbott},
journal = {Zenodo},
year = {2021},
doi = {10.5281/zenodo.5559016},
}

@Misc{loo,
title = {loo: Efficient leave-one-out cross-validation and WAIC for Bayesian models},
author = {Aki Vehtari and Jonah Gabry and Mans Magnusson and Yuling Yao and Paul-Christian Bürkner and Topi Paananen and Andrew Gelman},
year = {2020},
note = {R package version 2.4.1},
url = {https://mc-stan.org/loo/},
}

@Article{loo-paper,
title = {Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC},
author = {Aki Vehtari and Andrew Gelman and Jonah Gabry},
year = {2017},
journal = {Statistics and Computing},
volume = {27},
issue = {5},
pages = {1413--1432},
doi = {10.1007/s11222-016-9696-4},
}

@Article{pearson-omicron,
title={Bounding the levels of transmissibility & immune evasion of the Omicron
variant in South Africa},
author={Carl A. B. Pearson and Sheetal P. Silal and Michael W.Z. Li and Jonathan Dushoff and Benjamin M. Bolker and Sam Abbott and Cari van Schalkwyk and Nicholas G. Davies and Rosanna C. Barnard and W. John Edmunds and Jeremy Bingham and Gesine Meyer-Rath and Lise Jamieson and Allison Glass and Nicole Wolter and Nevashan Govender and Wendy S. Stevens and Lesley Scott and Koleka Mlisana and Harry Moultrie and Juliet R. C. Pulliam},
year={2021},
url={https://www.sacmcepidemicexplorer.co.za/downloads/Pearson_etal_Omicron.pdf}
}
157 changes: 157 additions & 0 deletions omicron-delay.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
---
title: "Real-time estimation of the difference in the test seeking distribution of Omicron compared to Delta in England using S-Gene Target Status as a Proxy"
subtitle: "Summary report"
author: Sam Abbott (1)
bibliography: library.bib
csl: https://raw.githubusercontent.com/citation-style-language/styles/master/apa-numeric-superscript-brackets.csl
date: "`r format(Sys.Date(), format = '%B %d, %Y')`"
output:
html_document:
theme: cosmo
toc: true
toc_float: true
toc_depth: 4
includes:
before_body: header.html
after_body: footer.html
pdf_document:
extra_dependencies: ["float"]
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, include = TRUE,
warning = FALSE, message = FALSE,
root.dir = here::here(),
fig.width = 12, fig.height = 9)
options(digits = 1)
library(here)
library(forecast.vocs)
library(dplyr)
library(loo)
library(scoringutils)
library(knitr)
library(data.table)
```

```{r load-results}
# load packages
library(ggplot2)
library(scales)
library(dplyr)
library(here)
library(readr)
library(data.table)
# load functions
source(here("R", "load-local-data.R"))
source(here("R", "plot-summary.R"))
source(here("R", "plot-daily-cases.R"))
source(here("R", "plot-omicron-95.R"))
source(here("R", "plot-cumulative-percent.R"))
```

1. Centre for the Mathematical Modelling of Infectious Diseases, London School of Hygiene & Tropical Medicine, London WC1E 7HT, United Kingdom


## Introduction

## Methods

### Data

We use S-gene status by specimen date sourced from UKHSA as a direct proxy for the Omicron variant with a target failure indicating a case has the Omicron variant. Data was available by UKHSA region.

```{r munge-data}
# get latest date
date_latest <- get_latest_date()
# load data
daily <- load_local_data(date_latest)
# start date
start_date <- as.Date("2021-11-23")
daily <- daily %>%
filter(date >= start_date) %>%
filter(!is.na(sgtf)) %>%
filter(!(region %in% "England"))
# munge fraction, logit scaling, difference, and dow
daily <- daily %>%
mutate(frac_sgtf = sgtf / total_sgt) %>%
mutate(logit_frac_sgtf = log(frac_sgtf / (1 - frac_sgtf))) %>%
group_by(region) %>%
arrange(date) %>%
mutate(diff_logit_sgtf = logit_frac_sgtf - lag(logit_frac_sgtf)) %>%
ungroup() %>%
mutate(weekday = weekdays(date) %>%
factor(levels = c("Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday"))) %>%
mutate(mondays = ifelse(weekday %in% "Monday", date, NA_Date_))
```

### Models

### Statistical Inference

### Implementation

All models were implemented using the [`forecast.vocs` R package](https://epiforecasts.io/forecast.vocs/) [@R; @forecast.vocs] and fit using `stan` [@stan] and `cmdstanr` [@cmdstanr]. Each model was fit using 2 chains with each chain having 1000 warmup steps and 2000 sampling steps. Convergence was assessed using the Rhat diagnostic [@stan]. Models were compared using approximate leave-one-out (LOO) cross-validation [@loo; @loo-paper] where negative values indicate an improved fit for the correlated model.


## Limitations


## Results

### Summary

### Data description

#### Daily
```{r data, fig.cap = "Daily cases in England and by UKHSA region, with S-gene target result (failed, confirmed detected, or unknown), and centred 7-day moving average up to date of data truncation (dotted line). Source: UKHSA and coronavirus.gov.uk; data by specimen date."}
daily %>%
plot_daily_cases(
truncate_date = max(daily$date), caption = "",
start_date = start_date, smooth_total = TRUE
) +
geom_vline(aes(xintercept = mondays), linetype = 2, alpha = 0.5)
```

#### Fraction of those tested for the S gene with target failure by UKHSA region

```{r logit-frac-sgtf-by-region, fig.cap = "Daily fraction of those tested for S gene status with SGTF by UKHSA region on the logit scale. The dashed vertical lines indicate Mondays. Note that the data is by specimen date and more recent dates may be from an incomplete sample . Source: UKHSA"}
daily %>%
ggplot() +
aes(x = date, y = logit_frac_sgtf, col = region) +
geom_vline(aes(xintercept = mondays), linetype = 2, alpha = 0.5) +
geom_point(alpha = 0.8) +
geom_line(alpha = 0.4) +
scale_color_brewer(palette = "Paired") +
theme_bw() +
theme(legend.position = "bottom") +
labs(x = "Specimen date",
y = "Fraction of those tested for the S gene with target failure
(logit scale)",
col = "UKHSA region")
```

#### Growth in those with SGTF by day on the week for each UKHSA region

```{r logit-diff-by-day-of-week, fig.cap = "Daily fraction of those tested for S gene status with SGTF by UKHSA region on the logit scale. The dashed vertical lines indicate Mondays. Note that the data is by specimen date and more recent dates may be from an incomplete sample . Source: UKHSA"}
daily %>%
ggplot() +
aes(x = weekday, y = diff_logit_sgtf, col = region) +
geom_violin(aes(col = NULL), alpha = 0.4, fill = "grey",
draw_quantiles = c(0.25, 0.5, 0.75)) +
geom_jitter(alpha = 0.6) +
scale_color_brewer(palette = "Paired") +
theme_bw() +
theme(legend.position = "bottom") +
guides(fill = NULL) +
labs(x = "Day of week",
y = "Difference in SGTF fraction from the previous day (logit scale)",
col = "UKHSA region")
```

## References
450 changes: 450 additions & 0 deletions omicron-delay.html

Large diffs are not rendered by default.

Binary file added omicron-delay.pdf
Binary file not shown.
Loading

0 comments on commit ca66758

Please sign in to comment.