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

add episodes on introduction and read delays #104

Merged
merged 130 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 129 commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
6951c3a
add first draft to solve #70
avallecam Nov 22, 2023
70c4483
add introduction episode for lesson_build
avallecam Nov 22, 2023
24b131c
fix writing of objectives
avallecam Nov 22, 2023
deeae92
add structure of questions to last two sections
avallecam Nov 22, 2023
8ca3248
remove temporally setup logs chunk
avallecam Nov 22, 2023
eec8bb2
reduce object names and visible arguments
avallecam Nov 22, 2023
b373ec7
change heading level
avallecam Nov 22, 2023
1049801
replace episode title
avallecam Nov 23, 2023
dd4f681
add template and questions for read data episode
avallecam Nov 23, 2023
f594398
add draft chunk for discussion or challenge
avallecam Nov 23, 2023
4fa5dfc
add template and questions for describe data episode
avallecam Nov 23, 2023
6e10b65
add new episodes for build review
avallecam Nov 23, 2023
d0a40cc
update heading titles
avallecam Nov 23, 2023
a2c87fa
add paragraphs to the what and how
avallecam Nov 23, 2023
d8c5edd
add keypoints from episode
avallecam Nov 23, 2023
7341359
arrange text in what and how sections
avallecam Nov 23, 2023
7de41f9
clear template content
avallecam Nov 23, 2023
e64dd80
rename figure
avallecam Nov 24, 2023
bdc9edc
remove space within epinow function
avallecam Nov 24, 2023
0ccf851
fix intro line to et1
avallecam Nov 24, 2023
d74e4dc
rewrite intro sentence
avallecam Nov 24, 2023
a92d6d4
add prerequisites
avallecam Nov 24, 2023
c8cc532
replace prerequisite
avallecam Nov 24, 2023
8a343ab
add clear wording
avallecam Nov 24, 2023
bd24bf5
add text on why and epinow2 steps
avallecam Nov 24, 2023
d6175dc
add definitions for delays
avallecam Nov 24, 2023
545e8e7
replace link with new R0 definition
avallecam Nov 24, 2023
ad7f23e
specify the task as a point of reference
avallecam Nov 24, 2023
fbd0eda
edits after first review with grammarly
avallecam Nov 24, 2023
a6659c9
relocate discussion after why section
avallecam Nov 24, 2023
57b2bca
rename episode for delays previous to read data
avallecam Nov 29, 2023
1a32ca8
add placeholder for episoap episode
avallecam Nov 29, 2023
c779f18
rename episode for read cases data
avallecam Nov 29, 2023
bba336d
use a simpler epinow2 with generation time only
avallecam Nov 30, 2023
bea61b7
add summative code content
avallecam Nov 30, 2023
49dd781
add sections content and names
avallecam Nov 30, 2023
5acce71
add placeholder for describe cases episode
avallecam Nov 30, 2023
33fb92a
replace serial interval with generation time
avallecam Nov 30, 2023
c0d03e3
add figure and references
avallecam Nov 30, 2023
92ed182
expand argument detail in intro episode
avallecam Nov 30, 2023
5255c4f
update key points
avallecam Nov 30, 2023
e4d1c3d
replace license file content to epiverse-trace
avallecam Dec 2, 2023
fa1fd07
amend change in license by error
avallecam Dec 2, 2023
94ae38a
Revert "amend change in license by error"
Dec 2, 2023
d760939
Revert "replace license file content to epiverse-trace"
Dec 2, 2023
b7c2465
add callout draft for delays from data
avallecam Dec 2, 2023
18fec37
add placeholder to show how to get delays from contact data
avallecam Dec 2, 2023
a8c1776
add period delay figures
avallecam Dec 7, 2023
25d0a81
edit text after review
avallecam Dec 7, 2023
3980291
add symptom onset for reporting delay definition
avallecam Dec 7, 2023
ad5b08c
remove figures replaced in previous commit
avallecam Dec 7, 2023
ec9a9ad
add infectiousness to glossary
avallecam Dec 7, 2023
4ef9b2e
add new distribution delays figures
avallecam Dec 7, 2023
c8bc355
add more definitions
avallecam Dec 7, 2023
5f51ee3
add figures and text for first section
avallecam Dec 7, 2023
3ea7742
add callout on reminder about the adjustments for Rt
avallecam Dec 8, 2023
55a0b80
add episode et1 content
avallecam Dec 8, 2023
5661d7b
fix and extend the definitions
avallecam Dec 11, 2023
09709ed
add objectives
avallecam Dec 11, 2023
2c6413f
add an explanation on serial interval biases
avallecam Dec 11, 2023
a21a2be
add content about growth rate curve
avallecam Dec 11, 2023
1feba74
write text for epiparameter epidist_db
avallecam Dec 11, 2023
ccd7e7c
add text before about exploring the epidist class object
avallecam Dec 11, 2023
68367c4
add challenge format
avallecam Dec 11, 2023
cd79f59
complete with the max argument for dist_spec
avallecam Dec 11, 2023
2e1d1c0
add spoiler on distribution plus explore output
avallecam Dec 11, 2023
ff72a76
add offspring distribution to glossary
avallecam Dec 12, 2023
7a6ca59
add formative assessments on distributions
avallecam Dec 12, 2023
878c26a
add text and assessment about continuous
avallecam Dec 14, 2023
a1065e5
add normal distribution figure
avallecam Dec 14, 2023
301545f
complete with assessments until epiparam + epinow2
avallecam Dec 14, 2023
3255ae0
relevel titles to isolate content index
avallecam Dec 14, 2023
46e87d3
add formative assessment + block all epinow2
avallecam Dec 14, 2023
5a6a990
write the structure of content
avallecam Dec 14, 2023
e8f8584
move questions to section on from your data
avallecam Dec 14, 2023
6ef20b1
translate questions to cases
avallecam Dec 14, 2023
4c4f9bb
update title
avallecam Dec 14, 2023
9e079ad
update questions and objectives
avallecam Dec 16, 2023
044f0dc
add question on serial interval from data
avallecam Dec 16, 2023
c3712e4
move read-cases file to separate branch
avallecam Dec 16, 2023
b9ca407
move describe-cases to separate branch
avallecam Dec 16, 2023
1c1796f
move create-report to separate branch
avallecam Dec 16, 2023
45c9813
add chunk placeholder for reactive hexwall
avallecam Dec 17, 2023
9a67e71
rephrase questions, move one to other branch
avallecam Dec 17, 2023
09498d4
add rcompendium paths to data as suggested in #90
avallecam Dec 17, 2023
45db86a
add idea callout to move from lollipop chart to distribution
avallecam Dec 20, 2023
cd5ee87
add one more figure on infectiousness
avallecam Dec 20, 2023
93c8b4a
add figure tags to url links
avallecam Dec 18, 2023
26aaed4
add reference on sampling and censoring bias to si
avallecam Dec 21, 2023
31eb082
add distributions affected by censoring
avallecam Dec 21, 2023
f90c19a
add figures to callout on cases to distributions
avallecam Dec 21, 2023
7b013c2
remove episodes out of feature branch
avallecam Dec 21, 2023
c8f8874
fix text and references on distrib params
avallecam Dec 21, 2023
4bfc607
add figure of observed serial intervals
avallecam Dec 21, 2023
2858982
relocate bias section to generation time
avallecam Dec 21, 2023
a60d9be
remove figures from infectious period
avallecam Dec 21, 2023
fba4e0e
edit text with grammarly
avallecam Dec 22, 2023
749c270
fix links to figures and tables in distribution presentation
avallecam Dec 22, 2023
c6ae5b5
add presymptomatic line and reference
avallecam Dec 22, 2023
2294034
edit challenge writing
avallecam Dec 22, 2023
e0cec38
remove installation code from episodes
avallecam Dec 22, 2023
12aca30
replace ver to express calculation
avallecam Dec 22, 2023
1a608c4
add delay word for generation time
avallecam Dec 22, 2023
fff8ee5
review intro with grammarly
Dec 22, 2023
4df8644
add specific objectives and keypoints
avallecam Dec 23, 2023
6aed597
homogenize reference to delays
avallecam Dec 23, 2023
f26c5ba
complete introduction section
avallecam Dec 23, 2023
716491c
relocate episode goal to introduction
avallecam Dec 23, 2023
1c17adf
complete content writing
avallecam Dec 23, 2023
188866d
separate linelist
avallecam Dec 23, 2023
0ec7536
complete editing of episode
avallecam Dec 23, 2023
807a1d7
add definitions on biases
avallecam Dec 23, 2023
e19c4c5
reduce to lower keys on subtitle
avallecam Dec 23, 2023
66f8847
edit with grammarly
avallecam Dec 23, 2023
915c6ce
edits after visual inspection of render website
avallecam Dec 23, 2023
385d4bf
relocate one challenge, remove eval in solutions
avallecam Dec 23, 2023
7fae338
add renv file for early task 1 episodes
avallecam Dec 23, 2023
b949724
add eval false to hints, edit one question and sol
avallecam Dec 23, 2023
306b500
fix typo to use incubation instead of serial
avallecam Jan 19, 2024
5a6aba8
remove redundant "delays" separator
avallecam Jan 23, 2024
89b8666
update renv after resolve conflicts
Jan 24, 2024
53e18ea
add install.R file to solve RcppParallel gh action
avallecam Jan 24, 2024
183e2bd
install RcppParallel from RSPM to renv.lock
avallecam Jan 25, 2024
6ceda33
fix lintr warnings and move hexwall code to issue
avallecam Feb 1, 2024
e433db0
fix partially lintr warnings
avallecam Feb 1, 2024
52715db
edits to reduce lintr warnings
avallecam Feb 1, 2024
8cb2253
edits to reduce lintr warnings
avallecam Feb 2, 2024
7570220
relocate hint as extension of solution challenge
avallecam Feb 2, 2024
0866c26
remove discrete distribution plot output
avallecam Feb 2, 2024
6a5a730
remove cache from chunk options
avallecam Feb 6, 2024
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
13 changes: 8 additions & 5 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ carpentry: 'incubator'
title: 'Outbreak analytics with R'

# Date the lesson was created (YYYY-MM-DD, this is empty by default)
created: ~
created:

# Comma-separated list of keywords for the lesson
keywords: 'forecasts, epidemic models, interventions' #FIXME
keywords: 'forecasts, epidemic models, interventions'

# Life cycle stage of the lesson
# possible values: pre-alpha, alpha, beta, stable
life_cycle: 'pre-alpha'

# License of the lesson
license: 'CC-BY 4.0' #FIXME
# License of the lesson materials (recommended CC-BY 4.0)
license: 'CC-BY 4.0'

# Link to the source repository for this lesson
source: 'https://github.com/epiverse-trace/tutorials'
Expand All @@ -33,7 +33,7 @@ source: 'https://github.com/epiverse-trace/tutorials'
branch: 'main'

# Who to contact if there are any issues
contact: '[email protected]' #FIXME
contact: '[email protected]'

# Navigation ------------------------------------------------
#
Expand All @@ -59,6 +59,8 @@ contact: '[email protected]' #FIXME

# Order of episodes in your lesson
episodes:
- introduction.Rmd
- read-delays.Rmd
- quantify-transmissibility.Rmd
- create-forecast.Rmd
- simulating-transmission.Rmd
Expand All @@ -79,6 +81,7 @@ profiles:
#
# This space below is where custom yaml items (e.g. pinning
# sandpaper and varnish versions) should live

varnish: epiverse-trace/varnish@epiversetheme
# this is carpentries/sandpaper#533 in our fork so we can keep it up to date with main
sandpaper: epiverse-trace/sandpaper@patch-renv-github-bug
Binary file added episodes/fig/disease-reporting.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added episodes/fig/fig5a-normaldistribution.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added episodes/fig/infectiousness-covid19.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added episodes/fig/pkgs-hexlogos.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added episodes/fig/reproduction-generation-time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added episodes/fig/rt-adjusting-delays.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added episodes/fig/serial-interval-covid-sars.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added episodes/fig/serial-interval-observed.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added episodes/fig/serial-interval-pairs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added episodes/fig/time-periods.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
179 changes: 179 additions & 0 deletions episodes/introduction.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
---
title: 'Outbreak analytics pipelines'
teaching: 10
exercises: 2
editor_options:
chunk_output_type: console
---

:::::::::::::::::::::::::::::::::::::: questions

- Why use R packages for Outbreak analytics?
- What can we do to analyse our outbreak data?
- How can I start doing Outbreak Analytics with R?

::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::: objectives

- Explain our vision on the need for outbreak analytics R packages.
- Share our strategy to create R packages into an outbreak analytics pipeline.
- Define our plan to start your learning path in outbreak analytics with R.

::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::::::::::::::::: prereq

## Prerequisites

This episode requires you to be familiar with:

**Data science** : Basic programming with R.

**Epidemic theory** : Reproduction number.

:::::::::::::::::::::::::::::::::

## Why to use R packages for Outbreak analytics?

Outbreaks appear with different diseases and in different contexts, but what all of them have in common are the key public health questions ([Cori et al. 2017](https://royalsocietypublishing.org/doi/10.1098/rstb.2016.0371#d1e605)).

Is the epidemic going to take off? Is it under control? How much effort will be needed to control it? We can answer them by _quantifying the transmissibility_ of the disease. The most used parameter for this is the reproduction number ($R$), the average number of secondary infections caused by a typical primary case in the population
of interest ([Prism, 2016](http://prism.edu.au/publications/prism-modeling-guideline/)). We can intuitively interpret it as:

Check warning on line 42 in episodes/introduction.Rmd

View workflow job for this annotation

GitHub Actions / Build markdown source files if valid

[needs HTTPS]: [Prism, 2016](http://prism.edu.au/publications/prism-modeling-guideline/)

- if $R>1$, the epidemic is likely to grow,
- if $R<1$, the epidemic is likely to decline.

We can estimate the reproduction number by initially using two __data inputs__: the incidence of reported cases and the [generation time](../learners/reference.md#generationtime) distribution. But to calculate it, we must apply the appropriate mathematical models written in code with the required computational methods. That is not enough! Following _good practices_, the code we write should be peer-reviewed and contain internal tests to double-check that we are getting the estimates we expect. Imagine rewriting all of it during a health emergency!

In R, the fundamental unit of shareable code is the _package_. A package bundles together code, data, documentation, and tests and is easy to share with others ([Wickham and Bryan, 2023](https://r-pkgs.org/introduction.html)). We, as epidemiologists, can contribute to their collaborative maintenance as a community to perform less error-prone data analysis pipelines.

::::::::::::::::::::::::::::::::: discussion

### Questions to think about

Remember your last experience with outbreak data and reflect on these questions:

- What data sources did you need to understand the outbreak?
- How did you get access to that data?
- Is that analysis pipeline you followed reusable for the next response?

Reflect on your experiences.

:::::::::::::::::::::::::::::::::::::::::::


## Example: Quantify transmission

The `{EpiNow2}` package provides a three-step solution to _quantify the transmissibility_. Let's see how to do this with a minimal example. First, load the package:

```{r,warning=FALSE}
library(EpiNow2)
```

### First, get your case data

Case incidence data must be stored in a data frame with the observed number of cases per day. We can read an example from the package:

```{r}
example_confirmed
```

### Then, set the generation time

Not all primary cases have the same probability of generating a secondary case. The onset and cessation of [infectiousness](../learners/reference.md#infectiousness) may occur gradually. For `{EpiNow2}`, we can specify it as a probability `distribution` with `mean`, standard deviation `sd`, and maximum value `max`:

```{r}
generation_time <- dist_spec(
mean = 3.6,
sd = 3.1,
max = 20,
distribution = "lognormal"
)
```

### Let's calculate the reproduction number!

In the `epinow()` function we can add:

- the `reported_cases` data frame,
- the `generation_time` delay distribution, and
- the computation `stan` parameters for this calculation:

```{r,message=FALSE,warning=FALSE,cache=TRUE}
epinow_estimates <- epinow(
# cases
reported_cases = example_confirmed[1:60],
# delays
generation_time = generation_time_opts(generation_time),
# computation
stan = stan_opts(
cores = 4, samples = 1000, chains = 3,
control = list(adapt_delta = 0.99)
)
)
```

As an output, we get the time-varying (or [effective](../learners/reference.md#effectiverepro)) reproduction number, as well as the cases by date of report and date of infection:

```{r}
base::plot(epinow_estimates)
```

::::::::::::::::: callout

### Is this $Rt$ estimation biased?

Review [Gostic et al., 2020](https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1008409) about what additional adjustments this estimation requires to avoid false precision in $Rt$.

:::::::::::::::::::::::::

## The problem!

However, _quantifying the transmissibility_ during a real-life outbreak response is more challenging than this example!

Usually, we receive outbreak data in non-standard formats, requiring specific steps and taking the most time to prepare usable data inputs. Some of them are:

- Read delay distributions from the literature
- Read and clean case data
- Validate your line list
- Describe case data

And this is not the end. After _quantifying transmissibility_ we need to answer more key public health questions like: What is the attack rate we expect? What would be the impact of a given intervention? We can use the reproduction number and other outputs as new inputs for complementary tasks. For example:

- Estimate severity
- Create short-term forecast
- Simulate transmission scenarios
- Compare interventions

So, all these tasks can be interconnected in a pipeline:

![The outbreak analytics pipeline.](https://epiverse-trace.github.io/task_pipeline-minimal.svg)

Check warning on line 151 in episodes/introduction.Rmd

View workflow job for this annotation

GitHub Actions / Build markdown source files if valid

[image missing alt-text]: https://epiverse-trace.github.io/task_pipeline-minimal.svg

## What can we do?

Our strategy is gradually incorporating specialised R packages into our traditional analysis pipeline. These packages should fill the gaps in these epidemiology-specific tasks in response to outbreaks.

Epiverse-TRACE's aim is to provide a software ecosystem for outbreak analytics. We support the development of software pieces, make the existing ones interoperable for the user experience, and stimulate a community of practice.

![](fig/pkgs-hexlogos.png)

Check warning on line 159 in episodes/introduction.Rmd

View workflow job for this annotation

GitHub Actions / Build markdown source files if valid

[image missing alt-text]: fig/pkgs-hexlogos.png

## How can I start?

Our plan for these tutorials is to introduce key solutions from packages in all the tasks before and after the _Quantify transmission_ task, plus the required theory concepts to interpret modelling outputs and make rigorous conclusions.

- In the first set of episodes, you will learn how to optimise the reading of delay distributions and cleaning of case data to input them into the _Quantify transmission_ task. These preliminary tasks are the __Early tasks__. These include packages like `{readepi}`, `{cleanepi}`, `{linelist}`, `{epiparameter}`, and `{episoap}`.

- Then, we will get deeper into the packages and required theory to _Quantify transmission_ and perform more real-time analysis tasks next to it. These are the __Middle tasks__. This includes `{EpiNow2}`, `{cfr}`, `{epichains}`, and `{superspreading}`.

- Lastly, we will use _Quantify transmission_ data outputs to compare it to other indicators and simulate epidemic scenarios as part of the __Late tasks__. This includes `{finalsize}`, `{epidemics}`, and `{scenarios}`.


::::::::::::::::::::::::::::::::::::: keypoints

- Our vision is to have pipelines of R packages for outbreak analytics.
- Our strategy is to create interconnected tasks to get relevant outputs for public health questions.
- We plan to introduce package solutions and theory bits for each of the tasks in the outbreak analytics pipeline.

::::::::::::::::::::::::::::::::::::::::::::::::

Loading
Loading