Contents

1 Overview

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.

2 Saving a 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"                        "concatenated/OBJECT"          
## [3] "concatenated/basic_columns.h5" "partitions.h5"

3 Loading a 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 5 rows and 2 columns
##             x         y
##     <numeric> <numeric>
##   1  0.566599 0.6893051
##   2  0.651144 0.2132889
##   3  0.241832 0.1701088
##   4  0.702889 0.0604255
##   5  0.271773 0.7919775

Session info

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] stats4    stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
## [1] alabaster.bumpy_1.3.1 alabaster.base_1.3.23 S4Vectors_0.41.6     
## [4] BiocGenerics_0.49.1   BumpyMatrix_1.11.0    BiocStyle_2.31.0     
## 
## loaded via a namespace (and not attached):
##  [1] cli_3.6.2               knitr_1.46              rlang_1.1.3            
##  [4] xfun_0.43               jsonlite_1.8.8          htmltools_0.5.8.1      
##  [7] sass_0.4.9              rmarkdown_2.26          grid_4.4.0             
## [10] evaluate_0.23           jquerylib_0.1.4         fastmap_1.1.1          
## [13] Rhdf5lib_1.25.3         alabaster.schemas_1.3.1 yaml_2.3.8             
## [16] IRanges_2.37.1          lifecycle_1.0.4         bookdown_0.39          
## [19] BiocManager_1.30.22     compiler_4.4.0          Rcpp_1.0.12            
## [22] rhdf5filters_1.15.5     rhdf5_2.47.7            lattice_0.22-6         
## [25] digest_0.6.35           R6_2.5.1                bslib_0.7.0            
## [28] Matrix_1.7-0            tools_4.4.0             cachem_1.0.8