MyNixOS website logo
Description

Mutation Models for Pedigree Likelihood Computations.

A collection of functions for modelling mutations in pedigrees with marker data, as used e.g. in likelihood computations with microsatellite data. Implemented models include equal, proportional and stepwise models, as well as random models for experimental work, and custom models allowing the user to apply any valid mutation matrix. Allele lumping is done following the lumpability criteria of Kemeny and Snell (1976), ISBN:0387901922.

pedmut

CRANstatus

Introduction

The pedmut package is part of the ped suite ecosystem for pedigree analysis in R. Its aim is to provide a framework for modelling mutations in pedigree computations.

Although pedmut is self-contained, its main purpose is to be imported by other ped suite packages, like pedprobr (marker probabilities and pedigree likelihoods), forrel (forensic pedigree analysis) and dvir.

For the theoretical background of mutation models and their properties (stationarity, reversibility, lumpability), I recommend Chapter 5 of Pedigree analysis in R, and the references therein.

Installation

# The easiest way to get `pedmut` is to install the entire `ped suite`:
install.packages("pedsuite")

# Alternatively, you can install just `pedmut`:
install.packages("pedmut")

# If you need the latest development version, install it from GitHub:
# install.packages("devtools")
devtools::install_github("magnusdv/pedmut")

A simple likelihood example

The examples below require the packages pedtools and pedprobr in addition to pedmut. The first two are core members of the ped suite and can be loaded collectively with library(pedsuite).

library(pedsuite)
library(pedmut)

The figure below shows a father and son who are homozygous for different alleles. We assume that the locus is an autosomal marker with two alleles, labelled 1 and 2.

# Create pedigree
x = nuclearPed(father = "fa", mother = "mo", child = "boy")

# Add marker
x = addMarker(x, fa = "1/1", boy = "2/2")

# Plot with genotypes
plot(x, marker = 1)

The data clearly constitutes a Mendelian error, and gives a likelihood of 0 without mutation modelling:

likelihood(x, marker = 1)
#> [1] 0

The following code sets a simple mutation model and recomputes the pedigree likelihood.

x2 = setMutationModel(x, marker = 1, model = "equal", rate = 0.1)

likelihood(x2, marker = 1)
#> [1] 0.0125

Under the mutation model, the combination of genotypes is no longer impossible, yielding a non-zero likelihood. To see details about the mutation model, we can use the mutmod() accessor:

mutmod(x2, marker = 1)
#> Unisex mutation matrix:
#>     1   2
#> 1 0.9 0.1
#> 2 0.1 0.9
#> 
#> Model: equal 
#> Rate: 0.1 
#> Frequencies: 0.5, 0.5 
#> 
#> Stationary: Yes 
#> Reversible: Yes 
#> Lumpable: Always

Mutation models

A mutation matrix in pedmut is a stochastic matrix, with each row summing to 1, where the rows and columns are named with allele labels.

Two central functions of package are mutationMatrix() and mutationModel(). The first constructs a single mutation matrix according to various model specifications. The second produces what is typically required in applications, namely a list of two mutation matrices, named “male” and “female”.

The mutation models currently implemented in pedmut are:

  • equal: All mutations equally likely; probability 1-rate of no mutation. Parameters: rate.

  • proportional: Mutation probabilities are proportional to the target allele frequencies. Parameters: rate, afreq.

  • random: This produces a matrix of random numbers, each row normalised to have sum 1. Parameters: seed.

  • custom: Allows any valid mutation matrix to be provided by the user. Parameters: matrix.

  • onestep: Applicable if all alleles are integers. Mutations are allowed only to the nearest integer neighbour. Parameters: rate.

  • stepwise: For this model alleles must be integers or decimal numbers with a single decimal, such as ‘17.1’, indicating a microvariant. Mutation rates depend on whether transitions are within the same group or not, i.e., between integer alleles and microvariants in the latter case. Mutations also depend on the size of the mutation as modelled by the parameter range, the relative probability of mutating n+1 steps versus mutating n steps. Parameters: rate, rate2, range.

  • trivial: Diagonal mutation matrix with 1 on the diagonal. Parameters: None.

Model properties

Several properties of mutation models are of interest (both theoretical and practical) for likelihood computations. The pedmut package provides utility functions for quickly checking these:

  • isStationary(M, afreq): Checks if afreq is a right eigenvector of the mutation matrix M. Stationary models have the desirable property that allele frequencies don’t change across generations.

  • isReversible(M, afreq): Checks if M together with afreq form a reversible Markov chain, i.e., that they satisfy the detailed balance criterion.

  • isLumpable(M, lump): Checks if M allows clustering (“lumping”) of a given subset of alleles. This implements the necessary and sufficient condition of strong lumpability of Kemeny and Snell (Finite Markov Chains, 1976).

  • alwaysLumpable(M): Checks if M allows lumping of any allele subset.

Further examples

An equal model with rate 0.1:

mutationMatrix("equal", rate = 0.1, alleles = c("a", "b", "c"))
#>      a    b    c
#> a 0.90 0.05 0.05
#> b 0.05 0.90 0.05
#> c 0.05 0.05 0.90
#> 
#> Model: equal 
#> Rate: 0.1 
#> 
#> Lumpable: Always

Next, a proportional model with rate 0.1. Note that this model depends on the allele frequencies.

mutationMatrix("prop", rate = 0.1, alleles = c("a", "b", "c"), afreq = c(0.7, 0.2, 0.1))
#>            a          b          c
#> a 0.93478261 0.04347826 0.02173913
#> b 0.15217391 0.82608696 0.02173913
#> c 0.15217391 0.04347826 0.80434783
#> 
#> Model: proportional 
#> Rate: 0.1 
#> Frequencies: 0.7, 0.2, 0.1 
#> 
#> Stationary: Yes 
#> Reversible: Yes 
#> Lumpable: Always

To illustrate the stepwise model, we recreate the mutation matrix in Section 2.1.3 of Simonsson and Mostad (FSI:Genetics, 2015). This is done as follows:

mutationMatrix(model = "stepwise", alleles = c("16", "17", "18", "16.1", "17.1"),
               rate = 0.003, rate2 = 0.001, range = 0.5)
#>                16           17           18         16.1         17.1
#> 16   0.9960000000 0.0020000000 0.0010000000 0.0005000000 0.0005000000
#> 17   0.0015000000 0.9960000000 0.0015000000 0.0005000000 0.0005000000
#> 18   0.0010000000 0.0020000000 0.9960000000 0.0005000000 0.0005000000
#> 16.1 0.0003333333 0.0003333333 0.0003333333 0.9960000000 0.0030000000
#> 17.1 0.0003333333 0.0003333333 0.0003333333 0.0030000000 0.9960000000
#> 
#> Model: stepwise 
#> Rate: 0.003 
#> Rate2: 0.001 
#> Range: 0.5 
#> 
#> Lumpable: Not always

A simpler version of the stepwise model above, is the onestep model, in which only the immediate neighbouring integers are reachable by mutation. This model is only applicable when all alleles are integers.

mutationMatrix(model = "onestep", alleles = c("16", "17", "18"), rate = 0.04)
#>      16   17   18
#> 16 0.96 0.04 0.00
#> 17 0.02 0.96 0.02
#> 18 0.00 0.04 0.96
#> 
#> Model: onestep 
#> Rate: 0.04 
#> 
#> Lumpable: Not always
Metadata

Version

0.7.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows