scale.HDF5Matrix

scale.HDF5Matrix

OTHER

1 Usage

scale.HDF5Matrix(...)

2 Arguments

Parameter Description
x An object.
center Logical (or numeric vector, see Details). If (default) subtract column means before scaling.
scale Logical (or numeric vector, see Details). If (default) divide by column standard deviations.
byrows Logical. If normalize row-wise instead of column-wise. Default .
wsize Integer or NULL. Block size for HDF5 reads (NULL = auto).
result_path Output location. (default) writes to in the same file. A character string writes to that path in the same file. A named list writes to a different file.
compression Integer (0-9) or NULL. gzip compression level for the result datasets. NULL uses the global option set by (default 6). Use to disable compression (faster for benchmarks).

3 Value

An pointing to the normalized dataset on disk.

4 Details

Passing a pre-computed numeric vector as center or scale is not currently supported. If a vector is supplied it is coerced to a logical (TRUE if length(x) > 0) and a warning is issued.

The returned HDF5Matrix carries scaled:center and scaled:scale attributes (numeric vectors), mirroring the behavior of base::scale().

5 Examples

\donttest{
tmp <- tempfile(fileext = ".h5")
X   <- hdf5_create_matrix(tmp, "data/M",
                           data = matrix(rnorm(500), 50, 10))
Xs  <- scale(X)                         # center=TRUE, scale=TRUE by cols
cat("scaled:center[1]:", attr(Xs, "scaled:center")[1], "\n")
X$close(); Xs$close(); unlink(tmp)
}