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: episodes/superspreading-simulate.Rmd
+35-24Lines changed: 35 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -386,29 +386,31 @@ If you need help, return to the "Chain size and length" callout box from the beg
386
386
```{r,echo=FALSE}
387
387
#### get simulated chain with more infections --------------------------------
388
388
389
-
chains_subgroup <- simulated_chains_map %>%
389
+
epichain_output <- multiple_epichains
390
+
391
+
chains_subgroup <- epichain_output %>%
390
392
as_tibble() %>%
391
-
group_by(simulation_id) %>%
393
+
group_by(chain) %>%
392
394
distinct(infector) %>%
393
-
count(simulation_id) %>%
395
+
count(chain) %>%
394
396
filter(n < 5, n >= 3) %>%
395
-
pull(simulation_id)
397
+
pull(chain)
396
398
397
-
chain_to_observe <- simulated_chains_map %>%
399
+
chain_to_observe <- epichain_output %>%
398
400
as_tibble() %>%
399
-
count(simulation_id, sort = TRUE) %>%
401
+
count(chain, sort = TRUE) %>%
400
402
filter(
401
403
magrittr::is_in(
402
-
simulation_id, chains_subgroup
404
+
chain, chains_subgroup
403
405
)
404
406
) %>%
405
-
filter(n < 10) %>%
407
+
# filter(n < 10) %>%
406
408
filter(n == max(n)) %>%
407
-
slice_min(simulation_id) %>%
408
-
pull(simulation_id)
409
+
slice_min(chain) %>%
410
+
pull(chain)
409
411
```
410
412
411
-
To explore the output format of the `<epichains>` class object of name `simulated_chains_map`, let's look at the simulated `simulation_id` number `r chain_to_observe`.
413
+
To explore the output format of the `<epichains>` class object of name `multiple_epichains`, let's look at the simulated `chain` number `r chain_to_observe`.
412
414
413
415
:::::::::::::::::::::::::::::::::
414
416
@@ -419,24 +421,27 @@ To explore the output format of the `<epichains>` class object of name `simulate
419
421
Let's use `dplyr::filter()` for this:
420
422
421
423
```r
422
-
chain_to_observe<-806
424
+
chain_to_observe<-30
423
425
```
424
426
425
427
```{r}
426
428
#### get epichain summary ----------------------------------------------------
427
429
428
-
simulated_chains_map %>%
429
-
dplyr::filter(simulation_id == chain_to_observe)
430
+
multiple_epichains %>%
431
+
dplyr::filter(chain == chain_to_observe)
430
432
```
431
433
432
-
Key elements from this output are in the footer, the piece of text that appears at the bottom:
434
+
This output contains two parts:
435
+
436
+
- A `head()` print of the infector-infectee pairs __starting from the first known infector__.
437
+
- A summary footer, the piece of text that appears at the bottom:
433
438
434
439
```output
435
440
Number of infectors (known): 3
436
441
Number of generations: 3
437
442
```
438
443
439
-
The simulated `simulation_id` number `r chain_to_observe` has three known infectors and three generations. These numbers are more visible when reading the `<epichains>` objects as a data frame.
444
+
The simulated `chain` number `r chain_to_observe` has three known infectors and three generations. These numbers are more visible when printing the `<epichains>` objects as a data frame (or `<tibble>`).
440
445
441
446
:::::::::::::::::::::::::
442
447
@@ -447,15 +452,21 @@ The simulated `simulation_id` number `r chain_to_observe` has three known infect
447
452
```{r}
448
453
#### infector-infectee data frame --------------------------------------------
"In the first transmission generation at `time = 0`, one index case (`infector = NA`) infected the first case with `infectee = 1`.
457
-
Then, in the second transmission generation (between `time` 10 to 16), `infector = 1` infected five cases.
458
-
Later, in the third transmission generation (between `time` 26 to 30), `infector = 2` infected three new cases."
461
+
462
+
"In the first transmission generation at `time = 0`, one subject (`ID = NA`) infected the subject with `ID = 1`.
463
+
Subject `ID = 1` is the first known infector.
464
+
465
+
"Then, in the second transmission generation, subject `ID = 1` infected seven subjects, from `ID = 2` to `ID = 8`.
466
+
These infections ocurred in `time` between day 9 and day 15, after the first known infection.
467
+
468
+
"Later, in the third transmission generation, subject `ID = 4` infected six new subjects, from `ID = 9` to `ID = 14`.
469
+
These infections ocurred in `time` between day 24 and day 31, after the first known infection."
459
470
460
471
:::::::::::::::::::::::::
461
472
@@ -465,12 +476,12 @@ Later, in the third transmission generation (between `time` 26 to 30), `infector
465
476
466
477
The output data frame collects **infectees** as the observation unit:
467
478
468
-
- Each infectee has a `infectee` "id".
479
+
- Each infectee has a `infectee` "ID".
469
480
- Each _infectee_ that behaved as an _infector_ is registered in the `infector` column using `infectee` "id".
470
481
- Each infectee got infected in a specific `generation` and (continuous) `time`.
471
-
- The simulation number is registered under the `simulation_id` column.
482
+
- The simulation number is registered under the `chain` column.
472
483
473
-
**Note:** The `Number of infectors (known)` includes the `NA`observation under the `infector` column. This refers to the infector specified as index case (in the `n_chains` argument), which started the transmission chain to the infectee of `sim_id = 1`, at `generation = 1`, and `time = 0`.
484
+
**Note:** The `Number of infectors (known)` includes the subject `ID = NA` under the `infector` column. This refers to the infector specified as index case (in the `n_chains` argument), which started the transmission chain to the infectee of `ID = 1`, at `generation = 1`, and `time = 0`.
0 commit comments