linkdat to matrix conversion
Converts a linkdat object to a matrix (basically following a pre-makeped
LINKAGE format), with marker annotations and other info attached as attributes.
## S3 method for class 'linkdat' as.matrix(x, include.attrs = TRUE, ...) restore_linkdat(x, attrs = NULL, checkped = 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 marker annotations and other |
checkped |
a logical, forwarded to |
restore_linkdat is the reverse of as.matrix.
The way linkdat objects are created in paramlink, marker data
are stored as a list of marker objects. Each of these is essentially
a matrix with various attributes like allele frequencies, map info a.s.o..
This format works well for marker-by-marker operations (e.g. likelihoods and
LOD scores), but makes it somewhat awkward to operate 'horizontally', i.e.
individual-by-individual, for instance if one wants to delete all genotypes
of a certain individual, or rearrange the pedigree in some way.
It is therefore recommended to convert the linkdat object to a matrix
first, do the necessary manipulations on the matrix, and finally use
restore_linkdat. Attributes are often deleted during matrix
manipulation, so it may be necessary to store them in a variable and feed
them manually to restore_linkdat using the attrs argument.
With default parameters, restore_linkdat(as.matrix(x)) should
reproduce x exactly.
For as.matrix: A matrix with x$nInd rows and 6 +
2*x$nMark columns. The 6 first columns describe the pedigree in LINKAGE
format, and the remaining columns contain marker alleles, using the internal
(numerical) allele coding and 0 for missing alleles. If include.attrs
= TRUE the matrix has the following attributes:
markerattr (a list of marker annotations)
available (the availability vector)
model (the disease model, if present)
plot.labels (plot labels, if present)
orig.ids (original individual IDs)
For restore_linkdat: A linkdat object.
Magnus Dehli Vigeland
x = linkdat(toyped, model=1) y = restore_linkdat(as.matrix(x)) stopifnot(all.equal(x,y)) # If attributes are lost during matrix manipulation: Use the 'attrs' argument. xmatr = as.matrix(x) newmatr = xmatr[-4, ] # NB: attributes are lost here z = restore_linkdat(newmatr, attrs = attributes(xmatr)) # Should be the same as: z2 = removeIndividuals(x, 4) stopifnot(all.equal(z, z2))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.