Learn R Programming

paramlink (version 0.8-3)

as.matrix.linkdat: linkdat to matrix conversions

Description

as.matrix creates a matrix representing the given linkdat object in standard LINKAGE format, with marker annotations and other info attached as attributes. restore_linkdat is the reverse of as.matrix.

Usage

## S3 method for class 'linkdat':
as.matrix(x, include.attrs = TRUE, ...)

restore_linkdat(x, attrs = NULL)

Arguments

x
a linkdat object. In restore_linkdat: A numerical matrix in LINKAGE format.
include.attrs
a logical indicating if marker annotations and other info should be attached as attributes. See value.
attrs
a list containing marker annotations and other linkdat info compatible with x, in the format produced by as.matrix. If NULL, the attributes of x itself are used.
...
not used.

Value

  • 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) allel coding and 0 for missing alleles. If include.attrs = TRUE the matrix has the attributes markerattr (a list of marker annotations), available (the availability vector) and model (the disease model, if present). restore_linkdat: A linkdat object.

Details

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.

See Also

linkdat

Examples

Run this code
data(toyped)
x = linkdat(toyped, model=1)
y = restore_linkdat(as.matrix(x))
stopifnot(all.equal(x,y))

m = as.matrix(x)

Run the code above in your browser using DataLab