| pedhalflife | R Documentation |
Calculates the diversity half-life (T_{1/2}) of a pedigree across
time points using a Renyi-2 entropy cascade framework. The total loss rate of
genetic diversity is partitioned into three additive components:
\lambda_e: foundation bottleneck (unequal founder
contributions).
\lambda_b: breeding bottleneck (overuse of key ancestors).
\lambda_d: genetic drift (random sampling loss).
The function rolls over time points defined by timevar, computing
f_e and f_a (via pedcontrib) and f_g
(via the internal coancestry engine) for each time point. No redundant
Ne calculations are performed.
pedhalflife(
ped,
timevar = "Gen",
at = NULL,
nsamples = 1000,
ncores = 1,
seed = NULL
)
## S3 method for class 'pedhalflife'
print(x, ...)
## S3 method for class 'pedhalflife'
plot(x, type = c("log", "raw"), ...)
ped |
A |
timevar |
Character.
Column name in |
at |
Optional vector of values selecting which time points to include
(e.g., |
nsamples |
Integer. Sample size per time point for coancestry estimation (passed to the internal coancestry engine). Default: 1000. |
ncores |
Integer. Number of OpenMP threads for C++ backends. Default: 1. |
seed |
Integer or |
x |
A |
... |
Additional arguments (ignored). |
type |
Character.
|
The mathematical identity underlying the cascade is:
\ln f_g = \ln f_e + \ln(f_a / f_e) + \ln(f_g / f_a)
Taking the negative time-slope of each term gives the \lambda
components, which sum exactly by linearity of OLS:
\lambda_{total} = \lambda_e + \lambda_b + \lambda_d
T_{1/2} = \ln 2 / \lambda_{total} is the number of time-units
(time points, years, generations) for diversity to halve.
A list of class pedhalflife with two data.table
components:
timeseriesPer-time-point tracking with columns
Time (time-point label from timevar), NRef,
fe, fa, fg and their log transformations
(lnfe, lnfa, lnfg, lnfafe,
lnfgfa), plus TimeStep (numeric OLS time axis).
decaySingle-row table with lambda_e,
lambda_b, lambda_d, lambda_total, and
thalf.
pediv, pedcontrib, tidyped
library(visPedigree)
data(simple_ped)
tp <- tidyped(simple_ped)
# 1. Calculate half-life using all available generations
hl <- pedhalflife(tp, timevar = "Gen")
print(hl)
# 2. View the underlying log-linear decay plot
plot(hl, type = "log")
# 3. Calculate half-life for a specific time window (e.g., Generations 2 to 4)
hl_subset <- pedhalflife(tp, timevar = "Gen", at = c(2, 3, 4))
print(hl_subset)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.