mergePed {pedtools} | R Documentation |
Merge two pedigrees
Description
This function merges two ped
objects, joining them at the indicated
individuals. Only ped objects without marker data are supported.
Usage
mergePed(x, y, by = NULL, relabel = FALSE, ...)
Arguments
x , y |
|
by |
The individuals to merge by. The most general form uses a named
vector with entries of the form |
relabel |
A logical, by default FALSE. If TRUE, |
... |
further arguments passed along to |
Details
Some internal checks are done to ensure that merging individuals have the same sex and the same parents.
If relabel = FALSE
, some relabelling might still be performed in order to
ensure unique labels for everyone. Specifically, this is the case if some ID
labels occur in both x
and y
other than those given in the by
argument.
In such cases, the relevant members of y
get a suffix .y
.
Value
A ped
object.
Author(s)
Magnus Dehli Vigeland
Examples
############
# Example 1
# A family trio where each parent have first cousin parents.
############
# Trio
x = nuclearPed(1)
# Add paternal family
pat = cousinPed(1, child = TRUE)
x = mergePed(x, pat, by = c("1" = "9"))
# Maternal family
mat = cousinPed(1, child = TRUE) |> swapSex("9")
x = mergePed(x, mat, by = c("2" = "9"))
# Relabel (Alternative: add `relabel = TRUE` in the previous call)
x = relabel(x, "asPlot")
plot(x)
##################################
# Example 2: Double first cousins
##################################
# First cousins, whose fathers are brothers
y = cousinPed(degree = 1)
# Create two sisters
motherPed = nuclearPed(2, sex = 2)
# Plot to see who is who: `plotPedList(list(y, motherPed))`
# Merge
z = mergePed(y, motherPed, by = c("4" = 3, "6" = 4), relabel = TRUE)
plot(z)