Populate haplotypes from founder and down in all pedigrees. Note, that haplotypes are bounded by ladder_min and ladder_max. All founders get a haplotype from calling the user provided function get_founder_haplotype().

pedigrees_all_populate_haplotypes_ladder_bounded(
  pedigrees,
  mutation_rates,
  ladder_min,
  ladder_max,
  get_founder_haplotype = NULL,
  prob_two_step = 0,
  prob_genealogical_error = 0,
  progress = TRUE
)

Arguments

pedigrees

Pedigree list in which to populate haplotypes

mutation_rates

Vector with mutation rates

ladder_min

Lower bounds for haplotypes, same length as mutation_rates

ladder_max

Upper bounds for haplotypes, same length as mutation_rates; all entries must be strictly greater than ladder_min

get_founder_haplotype

Function taking no arguments returning a haplotype of length(mutation_rates)

prob_two_step

Given a mutation happens, this is the probability that the mutation is a two-step mutation; refer to details for information about behaviour around ladder boundaries

prob_genealogical_error

Probability that a genealogical error happens: if so, give individual haplotype get_founder_haplotype() instead of father's

progress

Show progress

Details

Given that a two step mutation should happen (probability specified by prob_two_step): With distances >= 2 to ladder bounds, mutations happen as usual. At distance = 0 or 1 to a ladder bound, the mutation is forced to move away from the boundary.

Note, that pedigrees must first have been inferred by build_pedigrees().

Examples

sim <- sample_geneology(100, 10)
peds <- build_pedigrees(sim$population)
pedigrees_all_populate_haplotypes_ladder_bounded(
  peds, c(1, 1), c(0L, 0L), c(10L, 10L), 
  function(x) c(10, 10))
get_haplotype(sim$end_generation_individuals[[1]])
#> [1] 9 7