Learn R Programming

pedtools (version 0.9.6)

ped_utils: Pedigree utilities

Description

Various utility functions for ped objects

Usage

pedsize(x)

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.

chromType

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

Value

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

  • 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.

Details

The functions pedsize(), hasUnbrokenLoops(), hasInbredFounders() and hasSelfing() allow as input either a single ped object or a list of such. In the latter case each function returns TRUE if it is TRUE for any of the components.

Examples

Run this code
# NOT RUN {
x = fullSibMating(1)
stopifnot(pedsize(x) == 6)
stopifnot(hasUnbrokenLoops(x))

# 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