SummarizedExperiment
s to artifacts and back againalabaster.se 1.0.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.0 RC (2023-04-13 r84269)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 22.04.2 LTS
##
## Matrix products: default
## BLAS: /home/biocbuild/bbs-3.17-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.0.0 alabaster.base_1.0.0
## [3] SummarizedExperiment_1.30.0 Biobase_2.60.0
## [5] GenomicRanges_1.52.0 GenomeInfoDb_1.36.0
## [7] IRanges_2.34.0 S4Vectors_0.38.0
## [9] BiocGenerics_0.46.0 MatrixGenerics_1.12.0
## [11] matrixStats_0.63.0 BiocStyle_2.28.0
##
## loaded via a namespace (and not attached):
## [1] Matrix_1.5-4 jsonlite_1.8.4 compiler_4.3.0
## [4] BiocManager_1.30.20 Rcpp_1.0.10 rhdf5filters_1.12.0
## [7] bitops_1.0-7 alabaster.matrix_1.0.0 jquerylib_0.1.4
## [10] yaml_2.3.7 fastmap_1.1.1 jsonvalidate_1.3.2
## [13] lattice_0.21-8 R6_2.5.1 XVector_0.40.0
## [16] curl_5.0.0 knitr_1.42 DelayedArray_0.26.0
## [19] bookdown_0.33 GenomeInfoDbData_1.2.10 bslib_0.4.2
## [22] rlang_1.1.0 V8_4.3.0 HDF5Array_1.28.0
## [25] cachem_1.0.7 xfun_0.39 alabaster.ranges_1.0.0
## [28] sass_0.4.5 cli_3.6.1 Rhdf5lib_1.22.0
## [31] zlibbioc_1.46.0 digest_0.6.31 grid_4.3.0
## [34] alabaster.schemas_1.0.0 rhdf5_2.44.0 evaluate_0.20
## [37] RCurl_1.98-1.12 rmarkdown_2.21 tools_4.3.0
## [40] htmltools_0.5.5