Contents

1 Overview

The alabaster.files package implements methods to save common bioinformatics file formats within the alabaster framework. It does not perform any validation or parsing of the files, it just provides very light-weight wrappers for processing via alabaster.base::stageObject(). Check out the alabaster.base package for more details on the motivation and concepts behind alabaster.

2 Quick start

We’ll start with an indexed BAM file from the Rsamtools package:

bam.file <- system.file("extdata", "ex1.bam", package="Rsamtools", mustWork=TRUE)
bam.index <- paste0(bam.file, ".bai")

We can wrap this inside a BamFileReference class:

library(alabaster.files)
library(S4Vectors)
wrapped.bam <- BamFileReference(bam.file, index=bam.index)

Then we can save it to file:

dir <- tempfile()
saveObject(wrapped.bam, dir)

… and load it back at some later time.

readObject(dir)
## BamFileReference object
## path: /tmp/Rtmp3luloR/file2e8d62b0110ae/file.bam 
## index: /tmp/Rtmp3luloR/file2e8d62b0110ae/file.bam.bai

3 Integration with other objects

The example above isn’t very exciting, but it demonstrates how these files can be easily added to an alabaster project. This allows us to incorporate the Wrapper objects into other Bioconductor data structures, like:

df <- DataFrame(Sample=LETTERS[1:4])

# Adding a column of assorted wrapper files:
df$File <- list(
    wrapped.bam,
    BigWigFileReference(system.file("tests", "test.bw", package = "rtracklayer")),
    BigBedFileReference(system.file("tests", "test.bb", package = "rtracklayer")),
    BcfFileReference(system.file("extdata", "ex1.bcf.gz", package = "Rsamtools"))
)

# Saving it all to the staging directory:
dir <- tempfile()
saveObject(df, dir)

# Now reading it back in:
roundtrip <- readObject(dir)
roundtrip$File
## [[1]]
## BamFileReference object
## path: /tmp/Rtmp3luloR/file2e8d66ea0b536/other_columns/1/other_contents/0/file.bam 
## index: /tmp/Rtmp3luloR/file2e8d66ea0b536/other_columns/1/other_contents/0/file.bam.bai
## 
## [[2]]
## BigWigFileReference object
## path: /tmp/Rtmp3luloR/file2e8d66ea0b536/other_columns/1/other_contents/1/file.bw 
## 
## [[3]]
## BigBedFileReference object
## path: /tmp/Rtmp3luloR/file2e8d66ea0b536/other_columns/1/other_contents/2/file.bb 
## 
## [[4]]
## BcfFileReference object
## path: /tmp/Rtmp3luloR/file2e8d66ea0b536/other_columns/1/other_contents/3/file.bcf 
## index: NULL

Similarly, if the staging directory is uploaded to a remote store, the wrapped files will automatically be included in the upload. This avoids the need for a separate process to handle these files.

4 Validation

alabaster.files will try to perform some cursory validation of the wrapped file to catch errors in user inputs. The level of validation is format-dependent but should be fast, e.g., BAM file validation is performed by scanning the header. In all cases, users should not expect an exhaustive check of file validity, as that would take too long and involve more parsing than desired for the scope of alabaster.files. If stricter validation is required, applications calling alabaster.files should override the saveObject() methods for the relevant FileReference classes.

Session information

sessionInfo()
## R Under development (unstable) (2024-10-21 r87258)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.1 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.21-bioc/R/lib/libRblas.so 
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.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] S4Vectors_0.45.0      BiocGenerics_0.53.0   alabaster.files_1.5.0
## [4] alabaster.base_1.7.0  BiocStyle_2.35.0     
## 
## loaded via a namespace (and not attached):
##  [1] jsonlite_1.8.9          crayon_1.5.3            compiler_4.5.0         
##  [4] BiocManager_1.30.25     Rcpp_1.0.13             Rsamtools_2.23.0       
##  [7] GenomicRanges_1.59.0    rhdf5filters_1.19.0     bitops_1.0-9           
## [10] Biostrings_2.75.0       parallel_4.5.0          jquerylib_0.1.4        
## [13] IRanges_2.41.0          BiocParallel_1.41.0     yaml_2.3.10            
## [16] fastmap_1.2.0           R6_2.5.1                XVector_0.47.0         
## [19] GenomeInfoDb_1.43.0     knitr_1.48              bookdown_0.41          
## [22] GenomeInfoDbData_1.2.13 bslib_0.8.0             rlang_1.1.4            
## [25] cachem_1.1.0            xfun_0.48               sass_0.4.9             
## [28] cli_3.6.3               Rhdf5lib_1.29.0         zlibbioc_1.53.0        
## [31] digest_0.6.37           alabaster.schemas_1.7.0 rhdf5_2.51.0           
## [34] lifecycle_1.0.4         evaluate_1.0.1          codetools_0.2-20       
## [37] rmarkdown_2.28          httr_1.4.7              tools_4.5.0            
## [40] htmltools_0.5.8.1       UCSC.utils_1.3.0