alabaster.bumpy 1.8.0
The BumpyMatrix
class provides a representation of complex ragged data structures - see the BumpyMatrix package for more information.
This is used to coerce immune repertoire, spatial transcriptomics and drug response data into a familiar 2D array for easy manipulation.
The alabaster.bumpy package allows users to save a BumpyMatrix
to file within the alabaster framework.
BumpyMatrix
Let’s make a BumpyMatrix
to demonstrate:
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])
mat <- BumpyMatrix(split(df, f), c(5, 4))
Saving it to file involves calling saveObject
:
library(alabaster.bumpy)
tmp <- tempfile()
saveObject(mat, tmp)
list.files(tmp, recursive=TRUE)
## [1] "OBJECT" "_environment.json"
## [3] "concatenated/OBJECT" "concatenated/basic_columns.h5"
## [5] "partitions.h5"
BumpyMatrix
The loading procedure is even simpler as the metadata of the saved BumpyMatrix
remembers how it was saved.
We can just use alabaster.base::readObject()
or related functions, and the R interface will automatically do the rest.
readObject(tmp)
## 5 x 4 BumpyDataFrameMatrix
## rownames: NULL
## colnames: NULL
## preview [1,1]:
## DataFrame with 9 rows and 2 columns
## x y
## <numeric> <numeric>
## 1 0.968753 0.46943853
## 2 0.357353 0.93171673
## 3 0.634380 0.00306481
## 4 0.895022 0.35987253
## 5 0.889755 0.97895129
## 6 0.411806 0.72317410
## 7 0.692828 0.11179753
## 8 0.226135 0.03634411
## 9 0.122910 0.89456378
sessionInfo()
## R version 4.5.0 RC (2025-04-04 r88126 ucrt)
## Platform: x86_64-w64-mingw32/x64
## Running under: Windows Server 2022 x64 (build 20348)
##
## Matrix products: default
## LAPACK version 3.12.1
##
## locale:
## [1] LC_COLLATE=C
## [2] LC_CTYPE=English_United States.utf8
## [3] LC_MONETARY=English_United States.utf8
## [4] LC_NUMERIC=C
## [5] LC_TIME=English_United States.utf8
##
## time zone: America/New_York
## tzcode source: internal
##
## attached base packages:
## [1] stats4 stats graphics grDevices utils datasets methods
## [8] base
##
## other attached packages:
## [1] alabaster.bumpy_1.8.0 alabaster.base_1.8.0 S4Vectors_0.46.0
## [4] BiocGenerics_0.54.0 generics_0.1.3 BumpyMatrix_1.16.0
## [7] BiocStyle_2.36.0
##
## loaded via a namespace (and not attached):
## [1] cli_3.6.4 knitr_1.50 rlang_1.1.6
## [4] xfun_0.52 jsonlite_2.0.0 htmltools_0.5.8.1
## [7] sass_0.4.10 rmarkdown_2.29 grid_4.5.0
## [10] evaluate_1.0.3 jquerylib_0.1.4 fastmap_1.2.0
## [13] Rhdf5lib_1.30.0 alabaster.schemas_1.8.0 yaml_2.3.10
## [16] IRanges_2.42.0 lifecycle_1.0.4 bookdown_0.43
## [19] BiocManager_1.30.25 compiler_4.5.0 Rcpp_1.0.14
## [22] rhdf5filters_1.20.0 rhdf5_2.52.0 lattice_0.22-7
## [25] digest_0.6.37 R6_2.6.1 bslib_0.9.0
## [28] Matrix_1.7-3 tools_4.5.0 cachem_1.1.0