diff --git a/R/readArray.R b/R/readArray.R index 9aeb7c0..4cf4e7f 100644 --- a/R/readArray.R +++ b/R/readArray.R @@ -1,8 +1,10 @@ #' Read a dense array from disk #' #' Read a dense high-dimensional array from its on-disk representation. +#' This is usually not directly called by users, but is instead called by dispatch in \code{\link{readObject}}. #' #' @param path String containing a path to a directory, itself created by the \code{\link{saveObject}} method for a dense array. +#' @param metadata Named list of metadata for this object, see \code{\link{readObject}} for more details. #' @param array.output.type String specifying the output type for this function. #' This can be \code{"array"} or \code{"ReloadedArray"} (the default). #' @param ... Further arguments, ignored. @@ -28,14 +30,14 @@ #' #' dir <- tempfile() #' saveObject(arr, dir) -#' readArray(dir) +#' readObject(dir) #' #' @export #' @aliases #' loadArray #' @importFrom HDF5Array HDF5Array #' @importFrom DelayedArray type<- -readArray <- function(path, array.output.type=NULL, ...) { +readArray <- function(path, metadata, array.output.type=NULL, ...) { fpath <- file.path(path, "array.h5") details <- local({ diff --git a/R/readSparseMatrix.R b/R/readSparseMatrix.R index bc5da1f..c62f746 100644 --- a/R/readSparseMatrix.R +++ b/R/readSparseMatrix.R @@ -1,8 +1,10 @@ #' Read a sparse matrix from disk #' #' Read a sparse matrix from its on-disk representation. +#' This is usually not directly called by users, but is instead called by dispatch in \code{\link{readObject}}. #' #' @param path String containing a path to a directory, itself created by the \code{\link{saveObject}} method for a spars matrix. +#' @param metadata Named list of metadata for this object, see \code{\link{readObject}} for more details. #' @param sparsematrix.output.type String specifying the output type for this function. #' This can be \code{"CsparseMatrix"}, \code{"SVT_SparseMatrix"} or \code{"ReloadedArray"} (the default). #' @param ... Further arguments, ignored. @@ -23,12 +25,12 @@ #' rownames(mat) <- paste0("GENE_", seq_len(nrow(mat))) #' dir <- tempfile() #' saveObject(mat, dir) -#' readSparseMatrix(dir) +#' readObject(dir) #' #' @export #' @importFrom HDF5Array H5SparseMatrixSeed #' @importFrom DelayedArray type<- -readSparseMatrix <- function(path, sparsematrix.output.type=NULL, ...) { +readSparseMatrix <- function(path, metadata, sparsematrix.output.type=NULL, ...) { fpath <- file.path(path, "matrix.h5") name <- "compressed_sparse_matrix" diff --git a/R/saveArray.R b/R/saveArray.R index 45e57a6..0928ec6 100644 --- a/R/saveArray.R +++ b/R/saveArray.R @@ -65,7 +65,7 @@ NULL } save_names(ghandle, x, transpose=TRUE) - write(name, file=file.path(path, "OBJECT")) + saveObjectFile(path, name, list(dense_array=list(version="1.0"))) invisible(NULL) } diff --git a/R/saveSparseMatrix.R b/R/saveSparseMatrix.R index b65b1af..f068135 100644 --- a/R/saveSparseMatrix.R +++ b/R/saveSparseMatrix.R @@ -49,7 +49,7 @@ NULL } save_names(ghandle, x) - write(name, file=file.path(path, "OBJECT")) + saveObjectFile(path, name, list(compressed_sparse_matrix=list(version="1.0"))) invisible(NULL) } diff --git a/man/readArray.Rd b/man/readArray.Rd index d5027c5..0340afe 100644 --- a/man/readArray.Rd +++ b/man/readArray.Rd @@ -5,11 +5,13 @@ \alias{loadArray} \title{Read a dense array from disk} \usage{ -readArray(path, array.output.type = NULL, ...) +readArray(path, metadata, array.output.type = NULL, ...) } \arguments{ \item{path}{String containing a path to a directory, itself created by the \code{\link{saveObject}} method for a dense array.} +\item{metadata}{Named list of metadata for this object, see \code{\link{readObject}} for more details.} + \item{array.output.type}{String specifying the output type for this function. This can be \code{"array"} or \code{"ReloadedArray"} (the default).} @@ -20,6 +22,7 @@ A multi-dimensional array-like object. } \description{ Read a dense high-dimensional array from its on-disk representation. +This is usually not directly called by users, but is instead called by dispatch in \code{\link{readObject}}. } \details{ By default, a file-backed \linkS4class{ReloadedArray} is returned to save memory and to preserve the provenance of the object. @@ -35,7 +38,7 @@ dimnames(arr) <- list( dir <- tempfile() saveObject(arr, dir) -readArray(dir) +readObject(dir) } \seealso{ diff --git a/man/readSparseMatrix.Rd b/man/readSparseMatrix.Rd index 756e454..20f2064 100644 --- a/man/readSparseMatrix.Rd +++ b/man/readSparseMatrix.Rd @@ -4,11 +4,13 @@ \alias{readSparseMatrix} \title{Read a sparse matrix from disk} \usage{ -readSparseMatrix(path, sparsematrix.output.type = NULL, ...) +readSparseMatrix(path, metadata, sparsematrix.output.type = NULL, ...) } \arguments{ \item{path}{String containing a path to a directory, itself created by the \code{\link{saveObject}} method for a spars matrix.} +\item{metadata}{Named list of metadata for this object, see \code{\link{readObject}} for more details.} + \item{sparsematrix.output.type}{String specifying the output type for this function. This can be \code{"CsparseMatrix"}, \code{"SVT_SparseMatrix"} or \code{"ReloadedArray"} (the default).} @@ -19,6 +21,7 @@ A sparse \linkS4class{DelayedMatrix} object. } \description{ Read a sparse matrix from its on-disk representation. +This is usually not directly called by users, but is instead called by dispatch in \code{\link{readObject}}. } \details{ By default, a file-backed \linkS4class{ReloadedArray} is returned to save memory and to preserve the provenance of the object. @@ -29,7 +32,7 @@ mat <- Matrix::rsparsematrix(100, 200, density=0.2) rownames(mat) <- paste0("GENE_", seq_len(nrow(mat))) dir <- tempfile() saveObject(mat, dir) -readSparseMatrix(dir) +readObject(dir) } \seealso{