Contents

1 Overview

The alabaster.string package implements methods to save XStringSet 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.

2 Quick start

Given an XStringSet, we can use stageObject() to save it inside a staging directory:

library(Biostrings)
x <- DNAStringSet(c(seq1="CTCNACCAGTAT", seq2="TTGA", seq3="TACCTAGAG"))
mcols(x)$score <- runif(length(x))
x
## DNAStringSet object of length 3:
##     width seq                                               names               
## [1]    12 CTCNACCAGTAT                                      seq1
## [2]     4 TTGA                                              seq2
## [3]     9 TACCTAGAG                                         seq3
library(alabaster.string)
tmp <- tempfile()
dir.create(tmp)
meta <- stageObject(x, tmp, "dna")
.writeMetadata(meta, tmp)
## $type
## [1] "local"
## 
## $path
## [1] "dna/set.json"
list.files(tmp, recursive=TRUE)
## [1] "dna/sequence.fa.gz"                  
## [2] "dna/sequence.fa.gz.json"             
## [3] "dna/sequence_data/simple.csv.gz"     
## [4] "dna/sequence_data/simple.csv.gz.json"
## [5] "dna/set.json"

We can then load it back into the session with loadObject().

meta <- acquireMetadata(tmp, "dna/set.json")
roundtrip <- loadObject(meta, tmp)
class(roundtrip)
## [1] "DNAStringSet"
## attr(,"package")
## [1] "Biostrings"

More details on the metadata and on-disk layout are provided in the schema.

3 Quality scaled strings

The same approach works with QualityScaledXStringSet objects:

x <- DNAStringSet(c("TTGA", "CTCN"))
q <- PhredQuality(c("*+,-", "6789"))
y <- QualityScaledDNAStringSet(x, q)

library(alabaster.string)
tmp <- tempfile()
dir.create(tmp)
meta <- stageObject(y, tmp, "dna2")

roundtrip <- loadObject(meta, tmp)
class(roundtrip)
## [1] "QualityScaledDNAStringSet"
## attr(,"package")
## [1] "Biostrings"

Session information

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.string_1.0.1 alabaster.base_1.0.0   Biostrings_2.68.0     
## [4] GenomeInfoDb_1.36.0    XVector_0.40.0         IRanges_2.34.0        
## [7] S4Vectors_0.38.0       BiocGenerics_0.46.0    BiocStyle_2.28.0      
## 
## loaded via a namespace (and not attached):
##  [1] crayon_1.5.2            cli_3.6.1               knitr_1.42             
##  [4] rlang_1.1.1             xfun_0.39               jsonlite_1.8.4         
##  [7] RCurl_1.98-1.12         V8_4.3.0                htmltools_0.5.5        
## [10] sass_0.4.5              rmarkdown_2.21          evaluate_0.20          
## [13] jquerylib_0.1.4         bitops_1.0-7            fastmap_1.1.1          
## [16] Rhdf5lib_1.22.0         alabaster.schemas_1.0.1 yaml_2.3.7             
## [19] bookdown_0.33           jsonvalidate_1.3.2      BiocManager_1.30.20    
## [22] compiler_4.3.0          rhdf5filters_1.12.1     Rcpp_1.0.10            
## [25] rhdf5_2.44.0            digest_0.6.31           R6_2.5.1               
## [28] curl_5.0.0              GenomeInfoDbData_1.2.10 bslib_0.4.2            
## [31] tools_4.3.0             zlibbioc_1.46.0         cachem_1.0.8