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
:
## [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.
## 5 x 4 BumpyDataFrameMatrix
## rownames: NULL
## colnames: NULL
## preview [1,1]:
## DataFrame with 7 rows and 2 columns
## x y
## <numeric> <numeric>
## 1 0.371623 0.0723172
## 2 0.515152 0.7912885
## 3 0.632342 0.1646043
## 4 0.111350 0.2891360
## 5 0.126150 0.8824490
## 6 0.124710 0.0581405
## 7 0.260341 0.8338354
## R version 4.4.3 (2025-02-28)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.2 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 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: Etc/UTC
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats4 stats graphics grDevices utils datasets methods
## [8] base
##
## other attached packages:
## [1] alabaster.bumpy_1.7.0 alabaster.base_1.7.8 S4Vectors_0.45.4
## [4] BiocGenerics_0.53.6 generics_0.1.3 BumpyMatrix_1.15.0
## [7] BiocStyle_2.35.0
##
## loaded via a namespace (and not attached):
## [1] cli_3.6.4 knitr_1.49 rlang_1.1.5
## [4] xfun_0.51 jsonlite_1.9.1 buildtools_1.0.0
## [7] htmltools_0.5.8.1 maketools_1.3.2 sys_3.4.3
## [10] sass_0.4.9 rmarkdown_2.29 grid_4.4.3
## [13] evaluate_1.0.3 jquerylib_0.1.4 fastmap_1.2.0
## [16] Rhdf5lib_1.29.1 alabaster.schemas_1.7.0 yaml_2.3.10
## [19] IRanges_2.41.3 lifecycle_1.0.4 BiocManager_1.30.25
## [22] compiler_4.4.3 Rcpp_1.0.14 rhdf5filters_1.19.2
## [25] rhdf5_2.51.2 lattice_0.22-6 digest_0.6.37
## [28] R6_2.6.1 Matrix_1.7-2 bslib_0.9.0
## [31] tools_4.4.3 cachem_1.1.0