as.matrix.ped {pedtools} | R Documentation |
Convert ped
to matrix
Description
Converts a ped
object to a numeric matrix using internal labels, with
additional info necessary to recreate the original ped
attached as
attributes.
Usage
## S3 method for class 'ped'
as.matrix(x, include.attrs = TRUE, ...)
restorePed(x, attrs = NULL, validate = TRUE)
Arguments
x |
a |
include.attrs |
a logical indicating if marker annotations and other info should be attached as attributes. See Value. |
... |
not used. |
attrs |
a list containing labels and other |
validate |
a logical, forwarded to |
Details
restorePed
is the reverse of as.matrix.ped
.
Value
For as.matrix
: A numerical matrix with pedsize(x)
rows. If
include.attrs = TRUE
the following attributes are added to the matrix,
allowing x
to be exactly reproduced by restorePed
:
-
FAMID
the family identifier (a string) -
LABELS
the ID labels (a character vector) -
UNBROKEN_LOOPS
a logical indicating whetherx
has unbroken loops -
LOOP_BREAKERS
a numerical matrix, or NULL -
markerattr
a list of lengthnMarkers(x)
, containing the attributes of each marker
For restorePed
: A ped
object.
Author(s)
Magnus Dehli Vigeland
See Also
Examples
x = relabel(nuclearPed(1), letters[1:3])
# To examplify the ped -> matrix -> ped trick, we show how to
# reverse the internal ordering of the pedigree.
m = as.matrix(x, include.attrs = TRUE)
m[] = m[3:1, ]
# Must reverse the labels also:
attrs = attributes(m)
attrs$LABELS = rev(attrs$LABELS)
# Restore ped:
y = restorePed(m, attrs = attrs)
# Of course a simpler way is use reorderPed():
z = reorderPed(x, 3:1)
stopifnot(identical(y, z))