full2sparse {ASRgenomics} | R Documentation |
Modifies the input square matrix into its sparse form with three columns per line,
corresponding to the set: Row, Col, Value
. This matrix defines the lower triangle
row-wise of the original matrix and it is sorted as columns within row.
Values of zero on the matrix are dropped by default. Individual
names should be assigned to rownames
and colnames
.
full2sparse(K = NULL, drop.zero = TRUE)
K |
A square matrix in full form ( |
drop.zero |
If |
Based on the function published by Borgognone et al. (2016).
A matrix in sparse form with columns: Row, Col, Value
together with the attributes rowNames
and colNames
.
If attribute INVERSE
is found this is also passed to the sparse matrix.
Borgognone, M.G., Butler, D.G., Ogbonnaya, F.C and Dreccer, M.F. 2016. Molecular marker information in the analysis of multi-environment trial helps differentiate superior genotypes from promising parents. Crop Science 56:2612-2628.
# Get G matrix.
G <- G.matrix(M = geno.apple, method = "VanRaden", sparseform = FALSE)$G
G[1:5, 1:5]
# Transform matrix into sparse.
G.sparse <- full2sparse(K = G)
head(G.sparse)
head(attr(G.sparse, "rowNames"))
head(attr(G.sparse, "colNames"))