You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DESCRIPTION
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ Title: Tools for outbreaker2
3
3
Version: 0.0.1
4
4
Authors@R:
5
5
person("Cyril", "Geismar", email = "c.geismar21@imperial.ac.uk", role = c("aut", "cre"))
6
-
Description: Helper functions for the outbreaker2 package.
6
+
Description: Streamlines the post-processing, summarisation, and visualisation of outbreaker2 output via a suite of helper functions. Facilitates tidy manipulation of posterior samples, integration with case metadata, and generation of diagnostic plots and summary statistics.
The *o2ools* package provides helper functions to process and summarise the results from *outbreaker2* and to extend the analyses with other packages. In this vignette, we show how to use *o2ools* with *linktree* and *mixtree*.
29
-
30
-
*linktree* is a framework for estimating *group transmission assortativity*—the tendency for individuals to transmit within their own group rather than to others. The method is described in our [paper](https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0313037), and briefly discussed on [youtube](https://www.youtube.com/watch?v=Ib5dBunDPN0).
31
-
32
-
*mixtree* is a package for comparing *epidemic forests*—collections of transmission trees. It can help assess the convergence of *outbreaker2* results, and to compare the trees from different models.
33
-
34
-
## `linktree`
35
-
36
-
A detailed [vignette](https://cygei.github.io/linktree/articles/linktree_vignette.html) is available, so we do not cover it fully here. Instead, we show how to estimate assortativity from *outbreaker2*'s posterior trees. This requires knowledge of group sizes or their relative proportions. In our example, say the staff-to-patient ratio in the hospital is 1:4. It is also advised to analyse the transmission chains before *saturation* (i.e. the epidemic peak).
30
+
# Reproduction number
37
31
38
-
### Estimate the peak date
39
-
We'll estimate the peak date with the *incidence2* package.
32
+
We can estimate the case reproductive number ($R_i$), *i.e.* the number of secondary infections generated by each case, with the `get_Ri` function:
title = "Posterior offspring distribution with 95% credible intervals")+
67
+
theme_bw()
58
68
```
59
69
70
+
# Serial interval
60
71
61
-
### Mask non-direct transmissions
62
-
Group transmission assortativity is estimated from direct transmissions only. We can use the `filter_chain` function to mask non-direct transmissions (i.e. where `kappa`>1).
# keeps only rows where both onset dates are on or before peak
78
-
cut_trees <- lapply(trees, function(tree) {
79
-
tree |> filter(from_onset <= peak, to_onset <= peak)
80
-
})
72
+
The serial interval (SI) is the time between the onset of symptoms in an infector-infectee pair. You can compute the SI's empirical cumulative density functionusing with `get_si()` :
81
73
82
-
```
83
-
### Estimate group transmission assortativity
84
-
For a given tree, we can estimate the groups' transmission assortativity coefficients with:
85
74
```{r}
86
-
library(linktree)
87
-
# staff-to-patient ratio
88
-
ratio <- c("hcw" = 1, "patient" = 3)
89
-
90
-
max_post <- trees[[which.max(out$post)]]
91
-
delta <- linktree::get_delta(from = max_post$from_group, to = max_post$to_group, f = ratio)
92
-
plot(delta)
93
-
```
94
-
95
-
To account for uncertainty in who infected whom, we can compute the posterior distribution of assortativity coefficients. This is done by estimating `delta` for each tree in the posterior sample.
96
-
97
-
```{r}
98
-
deltas <- lapply(trees, function(x) {
99
-
linktree::get_delta(from = x$from_group, to = x$to_group, f = ratio)
100
-
}) |>
101
-
bind_rows(.id = "tree")
102
-
103
-
ggplot(deltas) +
104
-
geom_density(aes(x = est, fill = group), bw = 0.03, color = "white") +
*outbreaker2* uses Bayesian inference to account for uncertainty in who infected whom by sampling multiple plausible transmission trees from the posterior distribution. Standard MCMC diagnostics evaluate parameter chains (see `?plot.outbreaker_chains` and `?coda::gelman.diag`) rather than transmission events themselves.
125
91
126
-
Healthcare workers are nearly 5 times more likely to infect other HCWs whereas patients are 2.6 (`1/0.387`) times more likely to infect other HCWs.
92
+
[*mixtree*](https://cygei.github.io/mixtree/) provides a statistical framework for comparing collections of transmission trees (*epidemic forests*) to assess whether they originate from the same generative process. To evaluate MCMC convergence, *mixtree* can be used to compare epidemic forests sampled from multiple parallel MCMC chains. If the chains have converged, the resulting epidemic forests should be statistically indistinguishable.
127
93
94
+
## Run multiple chains of *outbreaker2*
128
95
129
-
## `mixtree`
130
-
131
-
A detailed [vignette](https://cygei.github.io/mixtree/articles/mixtree.html) is available, so we do not cover it fully here. Instead, we show how to use *mixtree* to assess the convergence of *outbreaker2* results.
We now have 5 collections of transmission trees, one for each chain. We can use *mixtree* to test that the compared epidemic forests stem from the same generative process.
122
+
We now have 5 epidemic forests, one for each chain.
test_args = list(simulate.p.value = TRUE, B = 999)
171
133
)))
172
134
```
173
-
We used the chi-squared test to test the null hypothesis that the frequency of infector-infectee pairs is the similar between chains. A p-value of 1 indicates similarity between the chains, suggesting convergence. The chi-squared test allows for multiple introductions, unlike PERMANOVA.
174
135
175
-
#### PERMANOVA
176
-
PERMANOVA only accepts one introduction event, so we need to re-run *outbreaker2* allowing for a single introduction event only. We can do this by setting the `find_import` argument to `FALSE`.
177
-
136
+
We used the chi-squared test to test the null hypothesis that the frequency of infector-infectee pairs is the similar between forests. A p-value of 1 indicates similarity between the forests, suggesting convergence. The chi-squared test allows for multiple introductions, unlike PERMANOVA.
137
+
138
+
#### PERMANOVA
139
+
140
+
PERMANOVA only accepts one introduction event, so we need to re-run *outbreaker2* allowing for a single introduction event only. We can do this by setting the `find_import` argument to `FALSE`.
PERMANOVA tests whether the variance in tree topology is similar between chains. A p-value >0.05 suggests that the topologies of the trees do not differ significantly across the 5 chains, suggesting convergence.
168
+
PERMANOVA tests whether the variance in tree topology is similar between *forests*. A p-value \> 0.05 suggests that the topologies of the trees do not differ significantly across the 5 *forests*, suggesting convergence.
169
+
170
+
# Group transmission patterns
171
+
172
+
Transmission chains can inform on the patterns of transmission between groups. [*linktree*](https://cygei.github.io/linktree/) provides a framework for estimating *group transmission assortativity* which quantifies the extent to which individuals transmit within their own group compared to others.
173
+
174
+
This requires knowledge of group sizes or their relative proportions. In our example, say the staff-to-patient ratio in the hospital is 1:3. It is also advised to analyse the transmission chains before *saturation* (*i.e.* the epidemic peak).
175
+
176
+
## Estimate the peak date
177
+
178
+
We'll estimate the peak date with the *incidence2* package.
Group transmission assortativity is estimated from direct transmissions only. We can use the `filter_chain` function to mask non-direct transmissions (*i.e.* where `kappa`\>1).
delta <- linktree::get_delta(from = max_post$from_group, to = max_post$to_group, f = ratio)
229
+
plot(delta)
230
+
```
231
+
232
+
To account for uncertainty in who infected whom, we can compute the posterior distribution of assortativity coefficients. This is done by estimating `delta` for each tree in the posterior sample.
0 commit comments