H5SpMat | R Documentation |
For running inmf
, onlineINMF
or
uinmf
with sparse matrix stored in HDF5 file, users will need
to construct an argument list for the filename of the HDF5 file as well as
the paths in the file storing the arrays that construct the CSC (compressed
sparse column) matrix. H5SpMat
is provided as an instructed
constructor. Meanwhile, since the INMF functions require that all datasets
should be of the same type, as.H5SpMat
is provided for writing
in-memory data into a new HDF5 file on disk and returning the
constructed argument list.
H5SpMat(filename, valuePath, rowindPath, colptrPath, nrow, ncol)
as.H5SpMat(x, filename, dataPath, overwrite = FALSE)
## S3 method for class 'matrix'
as.H5SpMat(x, filename, dataPath = "", overwrite = FALSE)
## S3 method for class 'dgCMatrix'
as.H5SpMat(x, filename, dataPath = "", overwrite = FALSE)
## Default S3 method:
as.H5SpMat(x, filename, dataPath = "", overwrite = FALSE, ...)
filename |
Filename of the HDF5 file |
valuePath |
Path in the HDF5 file that points to a 1D array storing the
non-zero values of the sparse matrix. Default |
rowindPath |
Path in the HDF5 file that points to a 1D integer array
storing the row indices of non-zero values in each column of the sparse
matrix. Default |
colptrPath |
Path in the HDF5 file that points to a 1D integer array
storing the number of non-zero values in each column of the sparse matrix.
Default |
nrow , ncol |
Integer, the true dimensionality of the sparse matrix. |
x |
For |
dataPath |
For |
overwrite |
Logical, whether to overwrite the file if already exists at
the given path. Default |
... |
not used |
H5SpMat object, indeed a list object.
if (require("withr")) {
H5SpMatEx <- function() {
withr::local_dir(withr::local_tempdir())
h <- H5SpMat(system.file("extdata/ctrl_sparse.h5", package = "RcppPlanc"),
"data", "indices", "indptr", 173, 300)
dim(h)
library(Matrix)
ctrl.dense <- as.matrix(ctrl.sparse)
h1 <- as.H5SpMat(ctrl.sparse, "ctrl_from_sparse_to_sparse.h5", "matrix")
h1
h2 <- as.H5SpMat(ctrl.dense, "ctrl_from_dense_to_sparse.h5", "matrix")
h2
}
H5SpMatEx()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.