Learn R Programming

pedtools (version 1.1.0)

ped_utils: Pedigree utilities

Description

Various utility functions for ped objects.

Usage

pedsize(x)

generations(x, maxOnly = TRUE, maxComp = TRUE)

hasUnbrokenLoops(x)

hasInbredFounders(x, chromType = "autosomal")

hasSelfing(x)

hasCommonAncestor(x)

subnucs(x)

peelingOrder(x)

Arguments

x

A ped object, or (in some functions - see Details) a list of such.

maxOnly

A logical, by default TRUE. (See Value.)

maxComp

A logical, by default TRUE. (See Value.)

chromType

Either "autosomal" (default) or "x".

Value

  • pedsize(x) returns the number of pedigree members in each component of x.

  • generations(x) by default returns the number of generations in x, defined as the number of individuals in the longest line of parent-child links. (Note that this definition is valid also if x has loops.) If maxOnly = FALSE, the output is a named integer vector, showing the generation number of each pedigree member. If x has multiple components, the output depends on the parameter maxComp. If this is FALSE, the output is a vector containing the result for each component. If TRUE (default), only the highest number is returned.

  • hasUnbrokenLoops(x) returns TRUE if x has loops, otherwise FALSE. (No computation is done here; the function simply returns the value of x$UNBROKEN_LOOPS).

  • hasInbredFounders(x) returns TRUE is founder inbreeding is specified for x and at least one founder has positive inbreeding coefficient. See founderInbreeding() 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 matrix A whose entry A[i,j] is TRUE if pedigree members i and j have a common ancestor in x, and FALSE otherwise. By convention, A[i,i] is TRUE for all i.

  • subnucs(x) returns a list of all nuclear sub-pedigrees of x, wrapped as nucleus objects. Each nucleus is a list with entries father, mother and children.

  • peelingOrder(x) calls subnucs(x) and extends each entry with a link 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 new ped object is created by ped() in order to detect loops.) The main purpose of the function, however, is to prepare for probability calculations in other packages, as e.g. in pedprobr::likelihood.

Examples

Run this code
# NOT RUN {
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))

# }

Run the code above in your browser using DataLab