Learn R Programming

symDMatrix (version 2.1.1)

symDMatrix-class: A Matrix-Like Class to Represent a Symmetric Matrix Partitioned into File-Backed Blocks

Description

A symDMatrix is a symmetric matrix partitioned into file-backed blocks. This approach allows for very large symmetric matrices, commonly found for example when computing genetic relationship matrices on large cohorts. A symDMatrix object behaves similarly to a regular matrix by implementing key methods such as [, dim, and dimnames.

Arguments

Details

The symDMatrix class is a RowLinkedMatrix that nests multiple ColumnLinkedMatrix objects containing blocks of type ff_matrix. Because the matrix is symmetric, only the diagonal and upper-triangular blocks need to be stored, but for more efficient queries, the lower-triangular blocks are virtual transposes of their diagonal counterparts.

See Also

symDMatrix to create a symDMatrix object from scratch, or preferably, as.symDMatrix to create a symDMatrix object from other objects.

Examples

Run this code
# NOT RUN {
# Get the path to the example symmetric matrix
path <- system.file("extdata", "G.RData", package = "symDMatrix")

# Load the example symDMatrix object (G)
load.symDMatrix(path, readonly = TRUE)

# Get the dimensions
dim(G)

# Get the row names
rownames(G)

# Get the column names
colnames(G)

# Extract the diagonal
diag(G)

# Extract rows and columns
G[1, ]
G[1:3, ]
G["per0_per0", ]
G[c("per0_per0", "per1_per1", "per2_per2"), ]
# }

Run the code above in your browser using DataLab