In R, what is the most efficient way to column-wise bind (‘cbind()’) a numeric matrix with a large filebacked big.matrix?
In order to analyze genome-wide association data with a particular modeling tool, I need a design matrix X that has columns for both the non-genomic factors for which I want to adjust and the genomic features. To create such a matrix, I need a function that acts like cbind()
— in particular, I need to column-wise combine the in-memory matrix A of non-genomic predictors with the filebacked matrix B of genomic predictors. Note that B will have type = 'raw'
(coming from an upstream function in the script), as all values in B are 0, 1, or 2. I need something like C <- cbind(A, B)
, where C is a filebacked matrix with type = 'double'
.