Learn R Programming

pedmut (version 0.8.0)

makeReversible: Transformations to reversibility

Description

This function implements three methods for transforming a mutation matrix into a reversible one. All methods are based on Metropolis-Hastings proposal functions.

Usage

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

Value

A reversible mutation matrix with the same allele frequencies.

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().

Examples

Run this code
m = mutationMatrix("equal", afreq = c(a=0.2, b=0.3, c=0.5), rate = 0.2)
makeReversible(m)
makeReversible(m, adjust = FALSE)  # rate differs!

makeReversible(m, "MH")
# makeReversible(m, "PR") # not well-defined

# 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)

Run the code above in your browser using DataLab