Learn R Programming

bigsparser (version 0.7.3)

SFBM_corr_compact-class: Class SFBM_corr_compact

Description

A reference class for storing and accessing from disk a sparse correlation matrix where non-zero values in columns are mostly contiguous. It rounds correlation values with precision 1/32767 to store them using 2 bytes only. This class has been specifically designed for package 'bigsnpr'.

Convert a 'dgCMatrix' or 'dsCMatrix' to an SFBM_corr_compact.

Usage

as_SFBM_corr_compact(spmat, backingfile = tempfile())

Value

The new SFBM_corr_compact.

Arguments

spmat

A 'dgCMatrix' (non-symmetric sparse matrix of type 'double') or 'dsCMatrix' (symmetric sparse matrix of type 'double').

backingfile

Path to file where to store data. Extension .sbk is automatically added.

Details

It inherits the fields and methods from class SFBM_compact.

Examples

Run this code
spmat2 <- as(cor(iris[1:4]), "dsCMatrix")
(X2 <- as_SFBM_corr_compact(spmat2))
(bin <- readBin(X2$sbk, what = integer(), size = 2, n = 100))
matrix(bin / 32767, 4)
spmat2

Run the code above in your browser using DataLab