Learn R Programming

RcppPlanc (version 2.0.13)

H5Mat: 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 matrix as.H5Mat(x, filename, dataPath = "data", overwrite, ...)

# S3 method for dgCMatrix as.H5Mat(x, filename, dataPath = "data", overwrite = FALSE, ...)

# S3 method for default as.H5Mat(x, filename, dataPath = "data", ...)

Value

H5Mat object, indeed a list object.

Arguments

filename

Filename of the HDF5 file

dataPath

Path in the HDF5 file that points to a 2D dense matrix. Default "data" when using as.H5Mat.

x

For as.H5Mat, matrix of either dense or sparse type to be written; for print, a H5Mat argument list object

overwrite

Logical, whether to overwrite the file if already exists at the given path. Default FALSE.

...

Passed down to hdf5r.Extra::h5Write

Examples

Run this code
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()
}

Run the code above in your browser using DataLab