ped_internal | R Documentation |
These functions give access to - and enable modifications of - the order in
which the members of a pedigree are stored. (This is the order in which the
members are listed when a ped
object is printed to the screen.)
reorderPed(x, neworder = NULL, internal = FALSE)
parentsBeforeChildren(x)
hasParentsBeforeChildren(x)
foundersFirst(x)
internalID(x, ids, errorIfUnknown = TRUE)
x |
A |
neworder |
A permutation of |
internal |
A logical (default: FALSE). If TRUE, |
ids |
A character vector (or coercible to one) of original ID labels. |
errorIfUnknown |
A logical. If TRUE (default), the function stops with
an error if not all elements of |
While the internal pedigree ordering rarely matters, it is occasionally
important. The function reorderPed()
permutes the internal ordering as
specified by the user. The most common use of this function is perhaps in
parentsBeforeChildren()
, which ensures that all parents precede their
children. This is required by many pedigree-traversing algorithms.
It should be noted that ped()
by default calls parentsBeforeChildren()
whenever a pedigree is created, unless explicitly avoided with reorder = FALSE
.
hasParentsBeforeChildren()
can be used as a quick test to decide if it is
necessary to call parentsBeforeChildren()
.
The foundersFirst()
function reorders the pedigree so that all the founders
come first.
The utility internalID()
converts ID labels to indices in the internal
ordering. If x
is a list of pedigrees, the output is a data frame
containing both the component number and internal ID (within the component).
ped()
x = ped(id = 3:1, fid = c(1,0,0), mid = c(2,0,0), sex = c(1,2,1), reorder = FALSE)
x
# The 'ids' argument is converted to character, hence these are the same:
internalID(x, ids = 3)
internalID(x, ids = "3")
hasParentsBeforeChildren(x)
# Put parents first
parentsBeforeChildren(x)
# Typical use of reorderPed: Swap sibling plot order
y = nuclearPed(2) |> reorderPed(4:3)
plot(y)
### If labels are numeric, argument `internal` is important
z = singleton(1) |> addParents(1)
z
reorderPed(z, 1:3, internal = FALSE) # ID order = "1","2","3"
reorderPed(z, 1:3, internal = TRUE) # index order: 1,2,3 (i.e., no change)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.