| as.matrix.ped | R Documentation |
ped to matrixConverts a ped object to a numeric matrix using internal labels, with
additional info necessary to recreate the original ped attached as
attributes.
## S3 method for class 'ped'
as.matrix(x, include.attrs = TRUE, ...)
restorePed(x, attrs = NULL, validate = TRUE)
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 |
restorePed is the reverse of as.matrix.ped.
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 whether x has unbroken loops
LOOP_BREAKERS a numerical matrix, or NULL
markerattr a list of length nMarkers(x), containing the attributes of
each marker
For restorePed: A ped object.
Magnus Dehli Vigeland
ped()
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.