H5Mat {RcppPlanc} | R Documentation |
Argument list object for using a dense matrix stored in HDF5 file
Description
For running inmf
, onlineINMF
or
uinmf
with dense matrix stored in HDF5 file, users will need
to construct an argument list for the filename of the HDF5 file as well as
the path in the file storing the matrix. H5Mat
is provided as an
instructed constructor. Meanwhile, since the INMF functions require that
all datasets should be of the same type, as.H5Mat
is provided for
writing in-memory data into a new HDF5 file on disk and returning the
constructed argument list.
Usage
H5Mat(filename, dataPath)
as.H5Mat(x, filename, dataPath = "data", overwrite = FALSE, ...)
## S3 method for class 'matrix'
as.H5Mat(x, filename, dataPath = "data", overwrite, ...)
## S3 method for class 'dgCMatrix'
as.H5Mat(x, filename, dataPath = "data", overwrite = FALSE, ...)
## Default S3 method:
as.H5Mat(x, filename, dataPath = "data", ...)
Arguments
filename |
Filename of the HDF5 file |
dataPath |
Path in the HDF5 file that points to a 2D dense matrix.
Default |
x |
For |
overwrite |
Logical, whether to overwrite the file if already exists at
the given path. Default |
... |
Passed down to hdf5r.Extra::h5Write |
Value
H5Mat object, indeed a list object.
Examples
if (require("withr")) {
H5MatEx <- function(){
withr::local_dir(withr::local_tempdir())
h <- H5Mat(system.file("extdata/ctrl_dense.h5", package = "RcppPlanc"),
"data")
print(h)
library(Matrix)
ctrl.dense <- as.matrix(ctrl.sparse)
h1 <- as.H5Mat(ctrl.dense, "ctrl_from_dense_to_dense.h5",
dataPath = "data")
h1
h2 <- as.H5Mat(ctrl.sparse, "ctrl_from_sparse_to_dense.h5",
dataPath = "data")
}
H5MatEx()
}