randomPed {pedtools} | R Documentation |
Random pedigree
Description
Generate a random connected pedigree by applying random mating starting from a finite population.
Usage
randomPed(n, founders = 2, maxDirectGap = 1, selfing = FALSE, seed = NULL)
Arguments
n |
A positive integer: the total number of individuals. Must be at least 3. |
founders |
A positive integer: the number of founders. Must be at least 2 unless selfing is allowed. |
maxDirectGap |
An integer; the maximum distance between direct
descendants allowed to mate. For example, the default value of 1 allows
parent-child mating, but not grandparent-grandchild. Set to |
selfing |
A logical indicating if selfing is allowed. Default: FALSE. |
seed |
An integer seed for the random number generator (optional). |
Details
Starting from an initial set of founders, a sequence of n - founders
random
matings is performed. The sampling of parents in each mating is set up to
ensure that the final result is connected.
Value
A connected pedigree returned as a ped
object.
Examples
plot(randomPed(n = 7, seed = 12))
# Disallow mating between direct descendants
plot(randomPed(n = 7, seed = 12, maxDirectGap = 0))
# No restrictions on mating between direct descendants
plot(randomPed(n = 7, seed = 12, maxDirectGap = Inf))
# Allow selfing
y = randomPed(5, seed = 2, selfing = TRUE)
hasSelfing(y)
y
plot(y, arrows = TRUE)