big_tcrossprodSelf: Tcrossprod In bigstatsr: Statistical Tools for Filebacked Big Matrices

Description

Compute X.row X.row^T for a Filebacked Big Matrix X after applying a particular scaling to it.

Usage

  1 2 3 4 5 6 7 8 9 10 big_tcrossprodSelf( X, fun.scaling = big_scale(center = FALSE, scale = FALSE), ind.row = rows_along(X), ind.col = cols_along(X), block.size = block_size(nrow(X)) ) ## S4 method for signature 'FBM,missing' tcrossprod(x, y) 

Arguments

 X An object of class FBM. fun.scaling A function that returns a named list of mean and sd for every column, to scale each of their elements such as followed: \frac{X_{i,j} - mean_j}{sd_j}. Default doesn't use any scaling. ind.row An optional vector of the row indices that are used. If not specified, all rows are used. Don't use negative indices. ind.col An optional vector of the column indices that are used. If not specified, all columns are used. Don't use negative indices. block.size Maximum number of columns read at once. Default uses block_size. x A 'double' FBM. y Missing.

Value

A temporary FBM, with the following two attributes:

• a numeric vector center of column scaling,

• a numeric vector scale of column scaling.

Matrix parallelization

Large matrix computations are made block-wise and won't be parallelized in order to not have to reduce the size of these blocks. Instead, you may use Microsoft R Open or OpenBLAS in order to accelerate these block matrix computations. You can also control the number of cores used with bigparallelr::set_blas_ncores().

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 X <- FBM(13, 17, init = rnorm(221)) true <- tcrossprod(X[]) # No scaling K1 <- tcrossprod(X) class(K1) all.equal(K1, true) K2 <- big_tcrossprodSelf(X) class(K2) K2\$backingfile all.equal(K2[], true) # big_tcrossprodSelf() provides some scaling and subsetting # Example using only half of the data: n <- nrow(X) ind <- sort(sample(n, n/2)) K3 <- big_tcrossprodSelf(X, fun.scaling = big_scale(), ind.row = ind) true2 <- tcrossprod(scale(X[ind, ])) all.equal(K3[], true2)