Skip to contents
library(diseasy)
#> Loading required package: diseasystore
#> 
#> Attaching package: 'diseasy'
#> The following object is masked from 'package:diseasystore':
#> 
#>     diseasyoption

Introduction

The DiseasyVariant is the module responsible for the implementation of variants.

Configuring the module

The module can be initialized without setting any parameters.

variant <- DiseasyVariant$new()

By default, the module initializes with no variant scenario, and produces non-informative outputs.

variant$variants
#> NULL

To define a variant scenario, we manually add the variants of interest and their characteristics. In the example below, we add the wild-type variant and a mutant variant named “Alpha”.

variant$add_variant(name = "WT")
variant$add_variant(
  name = "Alpha",
  characteristics = list(
    "relative_infection_risk" = 1.5,
    "introduction_date" = as.Date("2020-12-01")
  )
)

variant$variants
#> $WT
#> list()
#> 
#> $Alpha
#> $Alpha$relative_infection_risk
#> [1] 1.5
#> 
#> $Alpha$introduction_date
#> [1] "2020-12-01"

In the above example, there is perfect cross immunity between the variants (since we did not specify otherwise). These interactions are in DiseasyVariant captured via $cross_immunity, a matrix showing the overlap in immunity between the variants.

We can inspect the cross immunity matrix via $cross_immunity.

variant$cross_immunity
#>       WT Alpha
#> WT     1     1
#> Alpha  1     1

Cross immunity interactions

If the variants have different levels of cross immunity, we can specify this in the cross_immunity characteristic during initialisation.

Here we add a variant which has 85% cross immunity with the wild-type and the Alpha variant. That is, when the Delta variant infects a host previously infected with the wild-type or Alpha variant, protection provided the natural immunity in the host is reduced by 15%.

This cross immunity is asymmetric, meaning that when the wild-type or Alpha variant infects a host previously infected with the Delta variant, the protection provided by the immunisation with the Delta variant is not reduced.

variant$add_variant(
  name = "Delta",
  characteristics = list(
    "introduction_date" = as.Date("2021-05-01"),
    "cross_immunity" = list("WT" = 0.85, "Alpha" = 0.85)
  )
)

variant$cross_immunity
#>         WT Alpha Delta
#> WT    1.00  1.00     1
#> Alpha 1.00  1.00     1
#> Delta 0.85  0.85     1

Summarising the scenario

As with other diseasy modules, the $describe() method can be used to get a human readable summary of the scenario.

variant$describe()
#> # DiseasyVariant #############################################
#> Variant: WT
#> Variant: Alpha
#>  - relative_infection_risk: 1.5
#>  - introduction_date: 2020-12-01
#> Variant: Delta
#>  - introduction_date: 2021-05-01
#>  - cross_immunity: 0.85 - cross_immunity: 0.85
#> Cross immunity interactions:
#> (Index ij indicates variant j infecting host with immunity i)
#> 110.85110.85111