SFBM_corr_compact-class: Class SFBM_corr_compact

SFBM_corr_compact-classR Documentation

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())

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.

Value

The new SFBM_corr_compact.

Examples

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


bigsparser documentation built on Sept. 11, 2024, 8:29 p.m.