| as.matrix.ped | R Documentation |
ped to matrixConverts a ped object or a list of such to a numeric matrix using internal labels,
with additional information attached as attributes.
## S3 method for class 'ped'
as.matrix(x, include.attrs = TRUE, ...)
## S3 method for class 'list'
as.matrix(x, include.attrs = TRUE, ...)
## S3 method for class 'pedList'
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 sum(pedsize(x)) rows. If
include.attrs = TRUE the following attributes are attached (where applicable),
allowing a single ped to be 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 containing the attributes of each marker
For lists, different family IDs are replaced by "", and attributes for loop
breakers and founder inbreeding are not retained.
For restorePed: A ped object or a list of such.
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))
as.matrix(singletons(1:2))
x = list(nuclearPed(), singleton("X")) |>
addMarker(`1` = "1/2", X = "1/3", alleles = 1:3)
as.matrix(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.