pedModify {paramlink} | R Documentation |
Modify the pedigree of 'linkdat' objects
Description
Functions to modify the pedigree of a 'linkdat' object.
Usage
swapSex(x, ids, verbose = TRUE)
swapAff(x, ids, newval = NULL)
addOffspring(
x,
father,
mother,
noffs,
ids = NULL,
sex = 1,
aff = 1,
verbose = TRUE
)
addSon(x, parent, id = NULL, aff = 1, verbose = TRUE)
addDaughter(x, parent, id = NULL, aff = 1, verbose = TRUE)
addParents(x, id, father, mother, verbose = TRUE)
removeIndividuals(x, ids, verbose = TRUE)
branch(x, id)
trim(x, keep = c("available", "affected"), return.ids = FALSE, verbose = TRUE)
relabel(x, new, old)
Arguments
x |
A |
verbose |
A logical: Verbose output or not. |
newval |
A numeric, indicating affection status values for the
|
father , mother |
Integers indicating the IDs of parents. If missing, a new founder individual is created (whose ID will be 1+the largest ID already in the pedigree). |
noffs |
A single integer indicating the number of offspring to be created. |
sex , aff |
Integer vectors indicating the gender and affection statuses
of the offspring to be created (recycled if less than |
parent |
Integer ID of any pedigree member, which will be the father or mother (depending on its gender) of the new child. |
id , ids |
Individual ID label(s). In |
keep |
A character, either 'available' (trimming the pedigree for unavailable members) or 'affected' (trimming for unaffected members). |
return.ids |
A logical. If FALSE, the trimmed pedigree is returned as a
new |
new |
a numeric containing new labels to replace those in |
old |
a numeric containing ID labels to be replaced by those in
|
Details
When removing an individual, all descendants are also removed as well as founders remaining without offspring.
The branch()
function extracts the pedigree subset consisting of all
descendants of id
, including id
itself and all relevant
spouses.
Value
The modified linkdat
object.
See Also
Examples
x = linkdat(toyped)
# To see the effect of each command below, use plot(x) in between.
x = addParents(x, id=2, father=5, mother=6)
x = swapSex(x, c(1,5))
x = swapSex(x, c(2,6))
x = addOffspring(x, mother=6, noffs=2, id=c(7,10))
x = removeIndividuals(x, 3)
x = swapAff(x, c(4,10))
stopifnot(setequal(x$orig.ids, c(1,2,4,5,6,7,10,11)))
# Trimming a pedigree
x = linkdat(dominant)
x_affectedOnly = trim(x, keep='affected')
unavail = trim(x, keep='available', return.ids=TRUE)
nonaff = trim(x, keep='affected', return.ids=TRUE)
stopifnot(setequal(unavail, c(5, 19:23)), setequal(nonaff, c(6:7, 12:13, 19:23)))