DFE parametrizations

DFE parametrizations#

The DFE needs to be parametrized in some way in order to be amenable to maximum likelihood estimation. GammaExpParametrization is used by default. Other parametrizations are also implemented (cf. parametrization). You can also create your own parametrization by subclassing Parametrization.

To see how the parametrization affects the shape of the DFE, we use our example data for B. pendula.

library(fastdfe)

# load the fastdfe package
fd <- load_fastdfe()
# the different DFE parametrizations
parametrizations = c(
    fd$GammaExpParametrization(),
    fd$DiscreteParametrization(),
    fd$GammaDiscreteParametrization(),
    fd$DisplacedGammaParametrization()
)

inferences <- vector("list", length = 4)

for(i in seq_along(parametrizations)) {
    # create inference object
    inference <- fd$BaseInference(
        sfs_neut = fd$Spectrum(c(177130, 997, 441, 228, 156, 117, 114, 83, 105, 109, 0)),
        sfs_sel = fd$Spectrum(c(797939, 1329, 499, 265, 162, 104, 117, 90, 94, 119, 0)),
        fixed_params = list(all = list(h = 0.5, eps = 0)),
        model = parametrizations[[i]]
    )

    # run inference
    inference$run()

    inferences[[i]] <- inference
}
# plot the inferred DFEs
p <- fd$Inference$plot_discretized(
    inferences = inferences,
    labels = c("GammaExp", "Discrete", "GammaDiscrete", "DisplacedGamma"),
    intervals = c(-Inf, -100, -10, -1, 1, Inf),
)

The overall shape is similar, but {class}~fastdfe.parametrization.DiscreteParametrization shows noticeably wider confidence intervals. In general, estimating the full DFE with a sample size of 10 and the limited SNP count used here leads to substantial uncertainty.