Learn R Programming

pedtools (version 2.8.0)

inbreedingLoops: Pedigree loops

Description

Functions for identifying, breaking and restoring loops in pedigrees.

Usage

inbreedingLoops(x)

breakLoops(x, loopBreakers = NULL, verbose = TRUE, errorIfFail = TRUE)

tieLoops(x, verbose = TRUE)

findLoopBreakers(x)

findLoopBreakers2(x, errorIfFail = TRUE)

Value

For breakLoops, a ped object in which the indicated loop breakers are duplicated. The returned object will also have a non-null LOOP_BREAKERS entry, namely a matrix with the IDs of the original loop breakers in the first column and the duplicates in the second. If loop breaking fails, then depending on errorIfFail either an error is raised, or the input pedigree is returned, still containing unbroken loops.

For tieLoops, a ped object in which any duplicated individuals (as given in the x$LOOP_BREAKERS entry) are merged. For any ped object x, the call tieLoops(breakLoops(x)) should return x.

For inbreedingLoops, a list containing all inbreeding loops (not marriage loops) found in the pedigree. Each loop is represented as a list with elements top, bottom, pathA (individuals forming a path from top to bottom) and pathB (creating a different path from top to bottom, with no individuals in common with pathA). Note that the number of loops reported here counts all closed paths in the pedigree and will in general be larger than the genus of the underlying graph.

For findLoopBreakers and findLoopBreakers2, a vector of individual labels.

Arguments

x

a ped() object.

loopBreakers

either NULL (resulting in automatic selection of loop breakers) or a vector indicating the individuals to be used as loop breakers.

verbose

a logical: Verbose output or not?

errorIfFail

a logical: If TRUE an error is raised if the loop breaking is unsuccessful. If FALSE, the pedigree is returned unchanged.

Details

Pedigree loops are usually handled (by pedtools and related packages) under the hood -- using the functions described here -- without the need for explicit action from end users. When a ped object x is created, an internal routine detects if the pedigree contains loops, in which case x$UNBROKEN_LOOPS is set to TRUE.

In cases with complex inbreeding, it can be instructive to plot the pedigree after breaking the loops. Duplicated individuals are plotted with appropriate labels (see examples).

The function breakLoops breaks the loops of the input pedigree by duplicating the loop breakers. These may be given by the user; otherwise they are selected automatically. In the current implementation, only nonfounders can act as loop breakers. For automatic selection of loop breakers, breakLoops first calls findLoopBreakers, which identifies a set of individuals breaking all inbreeding loops and breaks at the returned individuals. If the resulting ped object still has loops, findLoopBreakers2 is called to handle marriage loops. In earlier versions of pedtools this required the igraph package, but now uses a custom implementation using a depth-first search algorithm to find a cycle in the marriage node graph of the pedigree.

Examples

Run this code

x = cousinPed(1, child = TRUE)
plot(breakLoops(x))

# Pedigree with marriage loop: Double first cousins
y = doubleCousins(1, 1, child = TRUE)
findLoopBreakers(y) # --> 9
findLoopBreakers2(y) # --> 5 and 9
y2 = breakLoops(y)
plot(y2)

# Or loop breakers chosen by user
y3 = breakLoops(y, 6:7)
plot(y3)

Run the code above in your browser using DataLab