Contents

1 Overview

The alabaster.matrix package implements methods to save matrix-like objects to file artifacts and load them back into R. Check out the alabaster.base for more details on the motivation and the alabaster framework.

2 Quick start

Given an array-like object, we can use saveObject() to save it inside a staging directory:

library(Matrix)
y <- rsparsematrix(1000, 100, density=0.05)

library(alabaster.matrix)
tmp <- tempfile()
saveObject(y, tmp)

list.files(tmp, recursive=TRUE)
## [1] "OBJECT"    "matrix.h5"

We then load it back into our R session with loadObject(). This creates a HDF5-backed S4 array that can be easily coerced into the desired format, e.g., a dgCMatrix.

roundtrip <- readObject(tmp)
class(roundtrip)
## [1] "ReloadedMatrix"
## attr(,"package")
## [1] "alabaster.matrix"

This process is supported for all base arrays, Matrix objects and DelayedArray objects.

3 Saving delayed operations

🚧🚧🚧 Oops. Yet to migrate the delayed operations to the new saveObject/readObject world - stay tuned. 🚧🚧🚧

Session information

sessionInfo()
## R version 4.4.0 beta (2024-04-15 r86425)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 22.04.4 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.19-bioc/R/lib/libRblas.so 
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_GB              LC_COLLATE=C              
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## time zone: America/New_York
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] alabaster.matrix_1.3.13 alabaster.base_1.3.23   Matrix_1.7-0           
## [4] BiocStyle_2.31.0       
## 
## loaded via a namespace (and not attached):
##  [1] jsonlite_1.8.8          compiler_4.4.0          BiocManager_1.30.22    
##  [4] crayon_1.5.2            Rcpp_1.0.12             rhdf5filters_1.15.5    
##  [7] jquerylib_0.1.4         IRanges_2.37.1          yaml_2.3.8             
## [10] fastmap_1.1.1           lattice_0.22-6          R6_2.5.1               
## [13] XVector_0.43.1          S4Arrays_1.3.7          knitr_1.46             
## [16] BiocGenerics_0.49.1     DelayedArray_0.29.9     bookdown_0.39          
## [19] MatrixGenerics_1.15.1   bslib_0.7.0             rlang_1.1.3            
## [22] cachem_1.0.8            HDF5Array_1.31.6        xfun_0.43              
## [25] sass_0.4.9              SparseArray_1.3.5       cli_3.6.2              
## [28] Rhdf5lib_1.25.3         zlibbioc_1.49.3         digest_0.6.35          
## [31] grid_4.4.0              alabaster.schemas_1.3.1 rhdf5_2.47.7           
## [34] lifecycle_1.0.4         S4Vectors_0.41.6        evaluate_0.23          
## [37] abind_1.4-5             stats4_4.4.0            rmarkdown_2.26         
## [40] matrixStats_1.3.0       tools_4.4.0             htmltools_0.5.8.1