Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

big_copy

Copy as a Filebacked Big Matrix


Description

Deep copy of a Filebacked Big Matrix with possible subsetting. This should also work for any matrix-like object.

Usage

big_copy(
  X,
  ind.row = rows_along(X),
  ind.col = cols_along(X),
  type = typeof(X),
  backingfile = tempfile(),
  block.size = block_size(length(ind.row)),
  is_read_only = FALSE
)

Arguments

X

Could be any matrix-like object.

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.

type

Type of the Filebacked Big Matrix (default is double). Either

  • "double" (double precision – 64 bits)

  • "float" (single precision – 32 bits)

  • "integer"

  • "unsigned short": can store integer values from 0 to 65535. It has vocation to become the basis for a FBM.code65536.

  • "raw" or "unsigned char": can store integer values from 0 to 255. It is the basis for class FBM.code256 in order to access 256 arbitrary different numeric values. It is used in package bigsnpr.

backingfile

Path to the file storing the Big Matrix on disk. An extension ".bk" will be automatically added. Default stores in the temporary directory.

block.size

Maximum number of columns read at once. Default uses block_size.

is_read_only

Whether the FBM is read-only? Default is FALSE.

Value

A copy of X as a new FBM object.

Examples

X <- FBM(10, 10, init = 1:100)
X[]
X2 <- big_copy(X, ind.row = 1:5)
X2[]

mat <- matrix(101:200, 10)
X3 <- big_copy(mat, type = "double")  # as_FBM() would be faster here
X3[]

X.code <- big_attachExtdata()
class(X.code)
X2.code <- big_copy(X.code)
class(X2.code)
all.equal(X.code[], X2.code[])

bigstatsr

Statistical Tools for Filebacked Big Matrices

v1.5.1
GPL-3
Authors
Florian Privé [aut, cre], Michael Blum [ths], Hugues Aschard [ths]
Initial release
2021-04-05

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.