Skip to content

Commit

Permalink
Merge pull request #18 from epiforecasts/feature-linerange-all-plots
Browse files Browse the repository at this point in the history
Remove point estimates and automate
  • Loading branch information
seabbs authored Dec 22, 2021
2 parents 21f0e84 + ca9274c commit efea7da
Show file tree
Hide file tree
Showing 11 changed files with 128 additions and 73 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
^.*\.Rproj$
^\.Rproj\.user$
^LICENSE\.md$
17 changes: 17 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cff-version: 1.2.0
message: "If you use this work, please cite it as below."
authors:
- family-names: "Abbott"
given-names: "Sam"
orcid: "https://orcid.org/0000-0001-8057-8037"
- family-names: "Sherratt"
given-names: "Katharine"
orcid: "https://orcid.org/0000-0003-2049-3423"
- family-names: "Funk"
given-names: "Sebastian"
orcid: "https://orcid.org/0000-0002-2842-3406"
title: "Real-time estimation of the time-varying transmission advantage of Omicron in England using S-Gene Target Status as a Proxy"
version: 1.0.0
doi: 10.5281/zenodo.1234
date-released: 2021-12-22
url: "https://github.com/epiforecasts/omicron-sgtf-forecast"
21 changes: 11 additions & 10 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
Package: omicron.sgtf.forcast
Title: Real-time estimation of the time-varying transmissibility advantage of Omicron in England using S-Gene Target Status as a Proxy
Version: 0.1.0
Title: Real-time estimation of the time-varying transmission advantage of Omicron in England using S-Gene Target Status as a Proxy
Version: 1.0.0
Authors@R:
c(person(given = "Katharine",
family = "Sherratt",
role = c("aut", "cre"),
email = "[email protected]",
comment = c(ORCID = "0000-0003-2049-3423")),
person(given = "Sam Abbott",
role = c("aut"),
c(person(given = "Sam Abbott",
role = c("aut", "cre"),
email = "[email protected]",
comment = c(ORCID = "0000-0001-8057-8037")),
person(given = "Katharine",
family = "Sherratt",
role = c("aut"),
email = "[email protected]",
comment = c(ORCID = "0000-0003-2049-3423")),
person(given = "Sebastian",
family = "Funk",
role = c("aut"),
email = "[email protected]",
comment = c(ORCID = "0000-0002-2842-3406")))
Description: Real-time estimation of the time-varying transmissibility advantage of Omicron in England using S-Gene Target Status as a Proxy.
Description: Real-time estimation of the time-varying transmission advantage of Omicron in England using S-Gene Target Status as a Proxy.
License: MIT + file LICENSE
Depends:
R (>= 2.10)
Expand All @@ -26,6 +26,7 @@ Imports:
cmdstanr,
dplyr,
forecast.vocs,
forcats,
future,
future.callr,
future.apply,
Expand Down
23 changes: 2 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,2 @@
MIT License

Copyright (c) 2021 kathsherratt

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
YEAR: 2021
COPYRIGHT HOLDER: omicron.sgtf.forcast authors
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2021 omicron.sgtf.forcast authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
18 changes: 11 additions & 7 deletions R/plot-omicron-95.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plot_omicron_95 <- function(voc_frac, forecast_start, forecast_end) {

omicron_95 <- voc_frac %>%
as_tibble() %>%
select(date, region, q_median = median, q5, q95) %>%
select(date, region, q_median = median, q5, q95, q20, q80) %>%
pivot_longer(cols = starts_with("q"),
names_to = "quantile", values_to = "omicron_prop") %>%
mutate(quantile = factor(quantile)) %>%
Expand All @@ -23,24 +23,28 @@ plot_omicron_95 <- function(voc_frac, forecast_start, forecast_end) {
complete(quantile) %>%
select(region, quantile, date) %>%
pivot_wider(id_cols = region, names_from = quantile, values_from = date) %>%
mutate(
across(starts_with("q"),
~ as.Date(ifelse(is.na(.x), forecast_end, .x),
origin = lubridate::origin))
) %>%
arrange(q_median) %>%
mutate(q5 = as.Date(ifelse(is.na(q5), forecast_end, q5),
origin = lubridate::origin),
region = factor(region, ordered = TRUE)) %>%
mutate(region = factor(region, ordered = TRUE)) %>%
filter(!is.na(region))

plot_95_percent <- omicron_95 %>%
mutate(region = forcats::fct_rev(region)) %>%
ggplot(aes(y = region)) +
geom_linerange(aes(xmin = q5, xmax = q95)) +
geom_point(aes(x = q_median)) +
geom_linerange(aes(xmin = q5, xmax = q95), alpha = 0.3, size = 3) +
geom_linerange(aes(xmin = q20, xmax = q80), alpha = 0.3, size = 3) +
geom_vline(xintercept = forecast_start, lty = 5, lwd = 1, col = "black") +
labs(y = NULL, x = "Date when 95% of reported cases are Omicron")

# copy code from forecast.vocs::plot_theme() to avoid overwriting x limits
plot_95_percent <- plot_95_percent +
theme_bw() +
theme(legend.position = "bottom", legend.box = "vertical") +
scale_x_date(date_breaks = "1 week", date_labels = "%b %d",
scale_x_date(date_breaks = "1 day", date_labels = "%b %d",
limits = c(forecast_start - 1, forecast_end)) +
theme(axis.text.x = element_text(angle = 90))

Expand Down
33 changes: 20 additions & 13 deletions R/plot-summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,54 @@ plot_summary <- function(sgtf_posterior, cum_per, bias_posterior,

# omicron transmission advantage
advantage <- summary(sgtf_posterior, type = "voc_advantage") %>%
mutate(value_type = "Omicron: transmission advantage")
mutate(value_type = "Omicron: current transmission advantage")

# growth
growth <- summary(sgtf_posterior, type = "growth") %>%
filter(type == "Omicron") %>%
mutate(value_type = "Omicron: growth rate")
mutate(value_type = "Omicron: current growth rate")

# cumulative pop
cumpercent <- cum_per %>%
select(region, date, median = c_median, q5 = c_q5, q95 = c_q95) %>%
select(region, date, q5 = c_q5, q95 = c_q95,
q20 = c_q20, q80 = c_q80
) %>%
mutate(value_type = "Omicron: cumulative % population",
region = as.character(region),
type = "Omicron",
across(median:q95, ~ . * 100))
across(starts_with("q"), ~ . * 100))

# bias
sampling <- summary(bias_posterior, type = "voc_advantage") %>%
mutate(value_type = "Bias: any-SGT vs no-SGT result")
mutate(value_type = "Current bias: any-SGT vs no-SGT result")

# join --------------------------------------------------------------------
region_factor <- as.character(sgtf$posterior$region)
region_factor <- as.character(sgtf_posterior$region)
region_factor <- unique(region_factor)
names(region_factor) <- region_factor

reference_lines <- c("Omicron: transmission advantage" = "1",
"Omicron: growth rate" = "0",
reference_lines <- c("Omicron: current transmission advantage" = "1",
"Omicron: current growth rate" = "0",
"Omicron: cumulative population proportion" = "",
"Bias: any-SGT vs no-SGT result" = "1")
"Current bias: any-SGT vs no-SGT result" = "1")

summary_data <- bind_rows(advantage, growth, cumpercent, sampling) %>%
filter(date == date_forecast_start & type %in% c("Omicron", "SGT-result")) %>%
filter(
date == date_forecast_start & type %in% c("Omicron", "SGT-result")
) %>%
mutate(region = recode_factor(region, !!!region_factor),
ref_line = as.numeric(recode(value_type, !!!reference_lines)))

summary_plot <- summary_data %>%
mutate(region = forcats::fct_rev(region)) %>%
ggplot(aes(y = region)) +
geom_linerange(aes(xmin = q5, xmax = q95)) +
geom_point(aes(x = median)) +
geom_linerange(aes(xmin = q5, xmax = q95), alpha = 0.3, size = 2) +
geom_linerange(aes(xmin = q20, xmax = q80), alpha = 0.3, size = 2) +
geom_vline(aes(xintercept = ref_line), lty = 2) +
facet_wrap(~ value_type, scales = "free_x") +
labs(y = NULL, x = NULL, caption = paste("Estimates for", date_forecast_start))
labs(y = NULL, x = NULL,
caption = paste("Estimates using data available up to: ",
date_forecast_start))
summary_plot <- forecast.vocs::plot_theme(summary_plot) +
scale_x_continuous(labels = scales::label_number(accuracy = 0.1))

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Real-time estimation of the time-varying transmissibility advantage of Omicron in England using S-Gene Target Status as a Proxy
# Real-time estimation of the time-varying transmission advantage of Omicron in England using S-Gene Target Status as a Proxy

In this work, we use S-gene target failure (SGTF) as a proxy of variant status combined with reported case counts to explore the evidence for changes in transmission advantage over time for the Omicron variant. If present this could indicate the impact of immune escape, bias in SGTF data or differences in the populations within which the variants are circulating. We also report estimates for growth rates by variant and overall, case counts overall and by variant for a 14 day forecast window assuming constant future growth, the date at which Omicron will become dominant in England and in each NHS region, and the estimated cumulative percentage of the population with a reported Omicron case.

Estimates are updated daily as new data is released but the summary of the situation is updated less frequently and so may not match current estimates. All data (both raw data and estimates) are available [here](https://github.com/epiforecasts/omicron-sgtf-forecast/tree/main/data) and the report should be fully reproducible. Reports and data as available at the time of release are available from the [release page](https://github.com/epiforecasts/omicron-sgtf-forecast/releases).

## Output

- Summary: [html](https://epiforecasts.io/omicron-sgtf-forecast/summary), [pdf](https://epiforecasts.io/omicron-sgtf-forecast/summary.pdf)
Expand Down
8 changes: 7 additions & 1 deletion data/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Data

Save raw data files here.
Processed input data and model outputs stored in dated sub-folders.

Folder | Purpose
---|---
[`estimates/sgtf`](estimates/sgtf/) | Posterior estimates, fit diagnostics, and model comparison metrics for models estimating the transmission advantage of Omicron vs non-Omicron using SGTF status in dated sub-folders. These estimates can be most easily accessed using the tooling provided in `R/load-local-data.R`.
[`estimates/bias`](estimates/bias/) | Posterior estimates, and fit diagnostic for models estimating the potential sampling bias for S-gene status in dated sub-folders. These estimates can be most easily accessed using the tooling provided in `R/load-local-data.R/`.
[public`](public/) | SGTF and reported cases data by specimen date downloaded from public sources saved in dated files using `scripts/update-regional-data.R`.
8 changes: 7 additions & 1 deletion writeup/library.bib
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,10 @@ @Article{loo-paper
doi = {10.1007/s11222-016-9696-4},
}

To cite the
@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}
}
Loading

0 comments on commit efea7da

Please sign in to comment.