lumpMutSpecial: Special lumping of mutation models

View source: R/lumpMutSpecial.R

lumpMutSpecialR Documentation

Special lumping of mutation models

Description

This function implements methods for special, or pedigree-aware, allele lumping. This is typically attempted if the model is not generally lumpable as determined by alwaysLumpable(). Note that the resulting lumped model is tailor-made for a specific likelihood calculation, and may violate the properties of a well-defined mutation model.

Usage

lumpMutSpecial(mut, lump, uSign, afreq = NULL, verbose = TRUE)

Arguments

mut

A square mutation matrix; typically a mutationMatrix() or mutationModel().

lump

A vector containing the alleles to be lumped together.

uSign

The U-signature of the pedigree for which lumping is attempted. See Details.

afreq

A vector with allele frequencies, of the same length as the size of mut. Extracted from the model if not given.

verbose

A logical.

Details

The lumping procedure depends on the location of untyped individuals in the pedigree, summarised by the so-called U-signature:

  • F-depth: The length of the longest chain of untyped, starting with a founder

  • F-width: The maximum number of children of an untyped founder

  • N-depth: The length of the longest chain of untyped, starting with a nonfounder

  • N-width: The maximum number of children of an untyped nonfounder

Value

A reduced mutation model, if lumping was possible, otherwise the original model is returned unchanged.

See Also

lumpedModel().

Examples


af = rep(0.05, 20)
names(af) = 1:20
m = mutationMatrix("random", afreq = af, rate = 0.1, seed = 1)

# Degree 1 lumping
mL = lumpMutSpecial(m, lump = 3:20, uSign = c(1,1,0,0))
mL

# Check
afL = attr(mL, "afreq")
stopifnot(sum(af * m[, 1]) == sum(afL * mL[, 1]))

# Degree 2
mL2 = lumpMutSpecial(m, lump = 3:20, uSign = c(1,2,0,0))
mL2
afL2 = attr(mL2, "afreq")

stopifnot(all.equal(af %*% m[, 1]^2, afL2 %*% mL2[, 1]^2),
          all.equal(af %*% m[, 2]^2, afL2 %*% mL2[, 2]^2),
          all.equal(af %*% ( m[, 1]*m[, 2]),
                    afL2 %*% (mL2[, 1]*mL2[, 2])))


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