sparse2full {ASRgenomics} | R Documentation |
Generates a full matrix form from a sparse form matrix
Description
Modifies the input sparse form matrix into its full form.
The sparse form has three columns per line, corresponding to the set:
Row, Col, Value
, and is defined by a lower triangle row-wise
of the full matrix and is sorted as columns within row.
Individual names should be assigned as attributes: attr(K, "rowNames")
and attr(K, "colNames")
. If these are not provided they are considered
as 1 to n
.
Usage
sparse2full(K = NULL)
Arguments
K |
A square matrix in sparse form (default = |
Details
Based on a function from ASReml-R 3 library by Butler et al. (2009).
Value
A full square matrix where individual names are assigned to
rownames
and colnames
.
If attribute INVERSE
is found this is also passed to the full matrix.
References
Butler, D.G., Cullis, B.R., Gilmour, A.R., and Gogel, B.J. 2009. ASReml-R reference manual. Version 3. The Department of Primary Industries and Fisheries (DPI&F).
Examples
# Get G matrix.
Gsp <- G.matrix(M = geno.apple, method = "VanRaden", sparseform = TRUE)$G.sparse
head(Gsp)
head(attr(Gsp, "rowNames"))
# Transform into full matrix.
G <- sparse2full(K = Gsp)
G[1:5, 1:5]