SummarizedExperiment
s to artifacts and back againalabaster.se 1.2.0
The alabaster.se package implements methods to save SummarizedExperiment
objects to file artifacts and load them back into R.
Check out the alabaster.base for more details on the motivation and concepts of the alabaster framework.
Given a (Ranged)SummarizedExperiment
, we can use stageObject()
to save it inside a staging directory:
library(SummarizedExperiment)
example(SummarizedExperiment, echo=FALSE) # can't be bothered to copy it here.
rse
## class: RangedSummarizedExperiment
## dim: 200 6
## metadata(0):
## assays(1): counts
## rownames: NULL
## rowData names(1): feature_id
## colnames(6): A B ... E F
## colData names(1): Treatment
library(alabaster.se)
tmp <- tempfile()
dir.create(tmp)
meta <- stageObject(rse, tmp, "se")
.writeMetadata(meta, tmp)
## $type
## [1] "local"
##
## $path
## [1] "se/experiment.json"
list.files(tmp, recursive=TRUE)
## [1] "se/assay-1/array.h5"
## [2] "se/assay-1/array.h5.json"
## [3] "se/coldata/simple.csv.gz"
## [4] "se/coldata/simple.csv.gz.json"
## [5] "se/experiment.json"
## [6] "se/rowdata/simple.csv.gz"
## [7] "se/rowdata/simple.csv.gz.json"
## [8] "se/rowranges/ranges.csv.gz"
## [9] "se/rowranges/ranges.csv.gz.json"
## [10] "se/rowranges/seqinfo/simple.csv.gz"
## [11] "se/rowranges/seqinfo/simple.csv.gz.json"
We can then load it back into the session with loadObject()
.
meta <- acquireMetadata(tmp, "se/experiment.json")
roundtrip <- loadObject(meta, tmp)
class(roundtrip)
## [1] "RangedSummarizedExperiment"
## attr(,"package")
## [1] "SummarizedExperiment"
More details on the metadata and on-disk layout are provided in the schema.
sessionInfo()
## R version 4.3.1 (2023-06-16)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 22.04.3 LTS
##
## Matrix products: default
## BLAS: /home/biocbuild/bbs-3.18-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] stats4 stats graphics grDevices utils datasets methods
## [8] base
##
## other attached packages:
## [1] alabaster.se_1.2.0 alabaster.base_1.2.0
## [3] SummarizedExperiment_1.32.0 Biobase_2.62.0
## [5] GenomicRanges_1.54.0 GenomeInfoDb_1.38.0
## [7] IRanges_2.36.0 S4Vectors_0.40.0
## [9] BiocGenerics_0.48.0 MatrixGenerics_1.14.0
## [11] matrixStats_1.0.0 BiocStyle_2.30.0
##
## loaded via a namespace (and not attached):
## [1] sass_0.4.7 SparseArray_1.2.0 bitops_1.0-7
## [4] lattice_0.22-5 jsonvalidate_1.3.2 digest_0.6.33
## [7] evaluate_0.22 grid_4.3.1 bookdown_0.36
## [10] fastmap_1.1.1 jsonlite_1.8.7 Matrix_1.6-1.1
## [13] alabaster.schemas_1.2.0 BiocManager_1.30.22 HDF5Array_1.30.0
## [16] jquerylib_0.1.4 abind_1.4-5 cli_3.6.1
## [19] rlang_1.1.1 crayon_1.5.2 XVector_0.42.0
## [22] cachem_1.0.8 DelayedArray_0.28.0 yaml_2.3.7
## [25] S4Arrays_1.2.0 tools_4.3.1 Rhdf5lib_1.24.0
## [28] GenomeInfoDbData_1.2.11 alabaster.ranges_1.2.0 alabaster.matrix_1.2.0
## [31] curl_5.1.0 R6_2.5.1 rhdf5_2.46.0
## [34] zlibbioc_1.48.0 V8_4.4.0 bslib_0.5.1
## [37] Rcpp_1.0.11 xfun_0.40 knitr_1.44
## [40] rhdf5filters_1.14.0 htmltools_0.5.6.1 rmarkdown_2.25
## [43] compiler_4.3.1 RCurl_1.98-1.12