makeReversible: Transformations to reversibility

View source: R/makeReversible.R

makeReversibleR Documentation

Transformations to reversibility

Description

This function implements three methods for transforming a mutation model ⁠(M,p)⁠ into a reversible one, ⁠(R,p)⁠. All methods are based on Metropolis- Hastings proposal functions.

Usage

makeReversible(
  mutmat,
  method = c("BA", "MH", "PR"),
  adjust = TRUE,
  afreq = NULL
)

Arguments

mutmat

A mutationMatrix() or mutationModel().

method

A character indicating which transformation to use. Either "BA" (Barker), "MH" (Metropolis-Hastings) or "PR" (preserved rate).

adjust

Logical. If TRUE (default), the overall mutation rate is adjusted to preserve the original rate; see adjustRate(). Not relevant for method "PR", which by construction always preserves the overall rate.

afreq

A vector of allele frequencies. Extracted from mutmat if not provided.

Details

These transformations may also be applied through the transform argument of mutationMatrix() and mutationModel().

Value

A reversible mutation matrix with the same allele frequencies.

Examples

m = mutationMatrix("equal", afreq = c(a=0.2, b=0.3, c=0.5), rate = 0.2)
makeReversible(m, "BA")
makeReversible(m, "MH")
makeReversible(m, "PR")

makeReversible(m, "BA", adjust = FALSE)  # rate differs!

# Apply to full model with different female/male rates
mod = mutationModel("equal", afreq = c(a=0.2, b=0.3, c=0.5),
                    rate = list(female = 0.1, male = 0.2))
modR = makeReversible(mod)


magnusdv/pedmut documentation built on June 8, 2025, 4:26 a.m.