Title: | Save and Load BumpyMatrices to/from file |
---|---|
Description: | Save BumpyMatrix objects into file artifacts, and load them back into memory. This is a more portable alternative to serialization of such objects into RDS files. Each artifact is associated with metadata for further interpretation; downstream applications can enrich this metadata with context-specific properties. |
Authors: | Aaron Lun [cre, aut] |
Maintainer: | Aaron Lun <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.5.0 |
Built: | 2024-09-28 02:56:59 UTC |
Source: | https://github.com/bioc/alabaster.bumpy |
Read a BumpyDataFrameMatrix from its on-disk representation.
readBumpyDataFrameMatrix(path, metadata, ...)
readBumpyDataFrameMatrix(path, metadata, ...)
path |
String containing a path to a directory, itself created using the |
metadata |
Named list of metadata for this object, see |
... |
Further arguments passed to internal |
A BumpyDataFrameMatrix object.
Aaron Lun
# Mocking up a BumpyMatrix. library(BumpyMatrix) library(S4Vectors) df <- DataFrame(x=runif(100), y=runif(100)) f <- factor(sample(letters[1:20], nrow(df), replace=TRUE), letters[1:20]) out <- S4Vectors::split(df, f) mat <- BumpyMatrix(out, c(5, 4)) # Saving it: tmp <- tempfile() saveObject(mat, tmp) # Reading it: readBumpyDataFrameMatrix(tmp)
# Mocking up a BumpyMatrix. library(BumpyMatrix) library(S4Vectors) df <- DataFrame(x=runif(100), y=runif(100)) f <- factor(sample(letters[1:20], nrow(df), replace=TRUE), letters[1:20]) out <- S4Vectors::split(df, f) mat <- BumpyMatrix(out, c(5, 4)) # Saving it: tmp <- tempfile() saveObject(mat, tmp) # Reading it: readBumpyDataFrameMatrix(tmp)
Save a BumpyDataFrameMatrix to its on-disk representation.
## S4 method for signature 'BumpyDataFrameMatrix' saveObject(x, path, ...)
## S4 method for signature 'BumpyDataFrameMatrix' saveObject(x, path, ...)
x |
A BumpyDataFrameMatrix object. |
path |
String containing the path to a directory in which to save |
... |
Further arguments to pass to specific methods. |
x
is saved into path
and NULL
is invisibly returned.
Aaron Lun
# Mocking up a BumpyMatrix. library(BumpyMatrix) library(S4Vectors) df <- DataFrame(x=runif(100), y=runif(100)) f <- factor(sample(letters[1:20], nrow(df), replace=TRUE), letters[1:20]) out <- S4Vectors::split(df, f) mat <- BumpyMatrix(out, c(5, 4)) # Saving it: tmp <- tempfile() saveObject(mat, tmp)
# Mocking up a BumpyMatrix. library(BumpyMatrix) library(S4Vectors) df <- DataFrame(x=runif(100), y=runif(100)) f <- factor(sample(letters[1:20], nrow(df), replace=TRUE), letters[1:20]) out <- S4Vectors::split(df, f) mat <- BumpyMatrix(out, c(5, 4)) # Saving it: tmp <- tempfile() saveObject(mat, tmp)
Use HDF5 for the underlying data frame, i.e., obtained after unlist
ing the BumpyMatrix.
This is less intuitive than a CSV but preserves the precision of floating-point numbers.
useBumpyHDF5(use)
useBumpyHDF5(use)
use |
Logical scalar indicating whether to save in HDF5. |
If use
is missing, a logical scalar is returned indicating whether data should be saved in HDF5.
If use
is provided, it is used to set the corresponding flag globally.
The previous value of the flag is returned invisibly.
useBumpyHDF5() old <- useBumpyHDF5(FALSE) useBumpyHDF5() # Setting it back. useBumpyHDF5(old)
useBumpyHDF5() old <- useBumpyHDF5(FALSE) useBumpyHDF5() # Setting it back. useBumpyHDF5(old)