ped_utils {pedtools} | R Documentation |
Pedigree utilities
Description
Various utility functions for ped
objects.
Usage
pedsize(x)
generations(x, what = c("max", "compMax", "indiv", "depth"))
hasUnbrokenLoops(x)
hasInbredFounders(x, chromType = "autosomal")
hasSelfing(x)
hasCommonAncestor(x)
subnucs(x)
peelingOrder(x)
Arguments
x |
A |
what |
Either "max", "compMax", "indiv" or "depth" (See Value.) |
chromType |
Either "autosomal" (default) or "x". |
Value
-
pedsize(x)
returns the number of pedigree members in each component ofx
. -
generations(x)
by default returns the number of generations inx
, defined as the number of individuals in the longest line of parent-child links. (Note that this is well-defined also ifx
has loops and/or cross-generational marriages.) For individual generation numbers, usewhat = "indiv"
(generation numbering as in the plot) orwhat = "depth" (length of the longest chain up to a founder). Finally, if
x has multiple components, and what = "compMax"
, the function returns a vector with the generation count from each component. -
hasUnbrokenLoops(x)
returns TRUE ifx
has loops, otherwise FALSE. (No computation is done here; the function simply returns the value ofx$UNBROKEN_LOOPS
). -
hasInbredFounders(x)
returns TRUE is founder inbreeding is specified forx
and at least one founder has positive inbreeding coefficient. SeefounderInbreeding()
for details. -
hasSelfing(x)
returns TRUE if the pedigree contains selfing events. This is recognised by father and mother begin equal for some child. (Note that for this to be allowed, the gender code of the parent must be 0.) -
hasCommonAncestor(x)
computes a logical matrixA
whose entryA[i,j]
is TRUE if pedigree members i and j have a common ancestor inx
, and FALSE otherwise. By convention,A[i,i]
is TRUE for all i. -
subnucs(x)
returns a list of all nuclear sub-pedigrees ofx
, wrapped asnucleus
objects. Each nucleus is a list with entriesfather
,mother
andchildren
. -
peelingOrder(x)
callssubnucs(x)
and extends each entry with alink
individual, indicating a member linking the nucleus to the remaining pedigree. One application of this function is the fact that if fails to find a complete peeling order if and only if the pedigree has loops. (In fact it is called each time a newped
object is created byped()
in order to detect loops.) The main purpose of the function, however, is to prepare for probability calculations in other packages, as e.g. inpedprobr::likelihood
.
Examples
x = fullSibMating(1)
stopifnot(pedsize(x) == 6)
stopifnot(hasUnbrokenLoops(x))
stopifnot(generations(x) == 3)
# All members have common ancestors except the grandparents
CA = hasCommonAncestor(x)
stopifnot(!CA[1,2], !CA[2,1], sum(CA) == length(CA) - 2)
# Effect of breaking the loop
y = breakLoops(x)
stopifnot(!hasUnbrokenLoops(y))
stopifnot(pedsize(y) == 7)
# A pedigree with selfing (note the necessary `sex = 0`)
z1 = singleton(1, sex = 0)
z2 = addChildren(z1, father = 1, mother = 1, nch = 1)
stopifnot(!hasSelfing(z1), hasSelfing(z2))
# Nucleus sub-pedigrees
stopifnot(length(subnucs(z1)) == 0)
peelingOrder(cousinPed(1))
# Plot with generation numbers as labels
w = cousinPed(1)
g = generations(w, what = "indiv")
labs = setNames(labels(w), g)
plot(w, labs = labs)
# ... compare with
plot(relabel(w, "generations"))