-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simplified saving methods for DelayedArrays.
Currently these just divert to the dense/sparse savers; support for preservation of delayed operations via chihaya will be added later. Also unlocked the sparse tests so that they check the block processing. This also involved some bugfixes.
- Loading branch information
Showing
6 changed files
with
135 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#' Save DelayedArrays to disk | ||
#' | ||
#' Save \link{DelayedArray} objects to their on-disk representation. | ||
#' | ||
#' @param x A \linkS4class{DelayedArray} object. | ||
#' @param path String containing a path to a directory in which to save \code{x}. | ||
#' @param delayedarray.preserve.ops Logical scalar indicating whether delayed operations should be preserved on-disk. | ||
#' @param ... Further arguments, ignored. | ||
#' | ||
#' @return | ||
#' \code{x} is saved to \code{path} and \code{NULL} is invisibly returned. | ||
#' | ||
#' @author Aaron Lun | ||
#' @examples | ||
#' mat <- Matrix::rsparsematrix(100, 200, density=0.2) | ||
#' rownames(mat) <- paste0("GENE_", seq_len(nrow(mat))) | ||
#' dmat <- DelayedArray::DelayedArray(mat) * 1 | ||
#' | ||
#' dir <- tempfile() | ||
#' saveObject(dmat, dir) | ||
#' list.files(dir) | ||
#' | ||
#' @name saveDelayedArray | ||
NULL | ||
|
||
#' @export | ||
#' @rdname saveDelayedArray | ||
#' @importFrom DelayedArray isPristine seed | ||
setMethod("saveObject", "DelayedArray", function(x, path, delayedarray.preserve.ops=FALSE, ...) { | ||
if (isPristine(x)) { | ||
s <- seed(x) | ||
fun <- selectMethod("saveObject", class(s), optional=TRUE) | ||
if (!is.null(fun)) { | ||
return(fun(s, path, ...)) | ||
} | ||
} | ||
|
||
if (!delayedarray.preserve.ops) { | ||
if (is_sparse(x)) { | ||
.save_compressed_sparse_matrix(x, path, ...) | ||
} else { | ||
.save_array(x, path, ...) | ||
} | ||
} else { | ||
stop("preservation of delayed operations is not currently supported") | ||
} | ||
|
||
invisible(NULL) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
expect_identical_without_names <- function(x, y) { | ||
if (!is.null(dimnames(x))) { | ||
if (identical(dimnames(x), vector("list", length(dim(x))))) { | ||
dimnames(x) <- NULL | ||
} | ||
} | ||
if (!is.null(dimnames(y))) { | ||
if (identical(dimnames(y), vector("list", length(dim(x))))) { | ||
dimnames(y) <- NULL | ||
} | ||
} | ||
expect_identical(x, y) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters