| Title: | Estimate Transmission Assortativity Coefficients |
|---|---|
| Description: | Estimates group transmission assortativity coefficients from transmission trees. Group transmission assortativity coefficients measure the tendency for individuals to transmit within their own group (e.g. age group, vaccination status, or location) compared to other groups. The package requires information on who infected whom, group membership for all individuals, and the relative sizes of each group in the population. For more details see Geismar et al. (2024) <doi:10.1371/journal.pone.0313037>. |
| Authors: | Cyril Geismar [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-8486-5890>) |
| Maintainer: | Cyril Geismar <[email protected]> |
| License: | CC BY 4.0 |
| Version: | 0.1.0 |
| Built: | 2026-05-23 15:18:10 UTC |
| Source: | https://github.com/cygei/linktree |
Convert delta to gamma
delta2gamma(delta)delta2gamma(delta)
delta |
A numeric vector of delta coefficients. |
A numeric vector of the corresponding gamma coefficients.
delta2gamma(delta = c(-1,0,1))delta2gamma(delta = c(-1,0,1))
Convert gamma to delta
gamma2delta(gamma)gamma2delta(gamma)
gamma |
A numeric vector of gamma coefficients. |
A numeric vector delta coefficients.
gamma2delta(gamma = c(0,1,10, Inf))gamma2delta(gamma = c(0,1,10, Inf))
Computes the scaled tansmission assortativity coefficient, see function gamma2delta.
get_delta(from, to, f, alpha = 0.05)get_delta(from, to, f, alpha = 0.05)
from |
A vector of infectors. |
to |
A vector of infectees. |
f |
A named numeric value representing the prevalence of each group in the population or directly the group sizes. |
alpha |
The significance level for the confidence interval. |
A data frame with the estimated delta, lower and upper confidence limits for each group.
from <- c("A", "A", NA, "C", "C", "C") to <- c("A", "B", "B", "C", "C", "C") f <- c(A = 0.3, B = 0.2, C = 0.5) get_delta(from, to, f, alpha = 0.05)from <- c("A", "A", NA, "C", "C", "C") to <- c("A", "B", "B", "C", "C", "C") f <- c(A = 0.3, B = 0.2, C = 0.5) get_delta(from, to, f, alpha = 0.05)
Computes the tansmission assortativity coefficient defined as the excess probability of a secondary infection taking place within-group compared to random expectations.
get_gamma(from, to, f, alpha = 0.05)get_gamma(from, to, f, alpha = 0.05)
from |
A vector of infectors. |
to |
A vector of infectees. |
f |
A named numeric value representing the prevalence of each group in the population or directly the group sizes. |
alpha |
The significance level for the confidence interval. |
A data frame with the estimated gamma, lower and upper confidence limits for each group.
from <- c("A", "A", NA, "C", "C", "C") to <- c("A", "B", "B", "C", "C", "C") f <- c(A = 0.3, B = 0.2, C = 0.5) get_gamma(from, to, f, alpha = 0.05)from <- c("A", "A", NA, "C", "C", "C") to <- c("A", "B", "B", "C", "C", "C") f <- c(A = 0.3, B = 0.2, C = 0.5) get_gamma(from, to, f, alpha = 0.05)
Calculates the within-group transmission proportion 'pi' for each group in the data.
get_pi(from, to, alpha = 0.05)get_pi(from, to, alpha = 0.05)
from |
A vector of infectors. |
to |
A vector of infectees. |
alpha |
The significance level for the confidence intervals. |
A data frame with the group names and the corresponding 'pi' values and confidence intervals.
from <- c("A", "A", "NA", "C", "C", "C") to <- c("A", "B", "B", "C", "C", "C") get_pi(from, to, alpha = 0.05)from <- c("A", "A", "NA", "C", "C", "C") to <- c("A", "B", "B", "C", "C", "C") get_pi(from, to, alpha = 0.05)
Plots error bars for objects of class linktree (with subclasses gamma, delta, or pi).
The method displays point estimates with confidence intervals for each group.
A horizontal dotted line is added at the neutral value: y = 1 for subclass gamma and y = 0 for subclass delta.
## S3 method for class 'linktree' plot(x, ...)## S3 method for class 'linktree' plot(x, ...)
x |
An object of class |
... |
Additional arguments passed to the base |
No return value, called for side effects (produces a plot).
from <- c("A", "A", NA, "C", "C", "C") to <- c("A", "B", "B", "C", "C", "C") f <- c(A = 0.3, B = 0.2, C = 0.5) plot(get_delta(from, to, f)) plot(get_gamma(from, to, f))from <- c("A", "A", NA, "C", "C", "C") to <- c("A", "B", "B", "C", "C", "C") f <- c(A = 0.3, B = 0.2, C = 0.5) plot(get_delta(from, to, f)) plot(get_gamma(from, to, f))
This dataset represents a simulated transmission tree.
This simulation was generated using the R package o2groups (see https://github.com/CyGei/o2groups for more information).
Group HCW is assortative with a gamma coefficient of 2 and group patient is disassortative with a gamma coefficient of 1/1.25.
Suceptible group sizes were 100 and 350, respectively.
Code to reproduce the data below:
pak::pak("CyGei/o2groups")
set.seed(123)
sim_tree <- o2groups::simulate_groups(
duration = 100,
group_n = 2,
size = c(100, 350), # susceptible group sizes
name = c("HCW", "patient"),
gamma = c(2, 0.8), # assortativity coefficients
intro_n = c(1, 3),
r0 = c(2, 2),
generation_time = c(0, 0.1, 0.2, 0.4, 0.2, 0.1, 0),
incubation_period = sample(1:14, 1000, replace = TRUE)
)
sim_treesim_tree
A data frame with 373 rows and 6 columns:
Character. The group to which the individual belongs.
Character. Unique identifier for each individual in the study.
Character. The ID of the individual who was the source of infection, if known. NA indicates an unknown source.
Character. The group of the source individual. NA for unknown sources.
Numeric. The date of infection. Represented as the number of days since the start of the study.
Numeric. The date of onset of symptoms. Represented as the number of days since the start of the study.
This dataset is simulated (see R package o2groups) and does not correspond to real-world data.