Dump an object to disk in the wobbegong format for easy HTTP range requests.

wobbegongify(x, path, ...)

# S4 method for class 'SummarizedExperiment'
wobbegongify(x, path, SummarizedExperiment.assay.check = NULL, ...)

# S4 method for class 'SingleCellExperiment'
wobbegongify(x, path, SummarizedExperiment.assay.check = NULL, ...)

# S4 method for class 'DataFrame'
wobbegongify(x, path, ...)

Arguments

x

A supported R object, typically a SummarizedExperiment or an instance of one of its subclasses.

path

String containing a path to the directory to dump x.

...

Additional arguments for specific methods.

SummarizedExperiment.assay.check

Function that accepts the index of the assay, the name of the assay, and the assay matrix. It should return a logical scalar specifying whether to save the assay; if FALSE, the assay is skipped. If NULL, no assays are skipped.

Value

path is populated with the contents of x. NULL is returned invisibly.

Details

For SummarizedExperiment objects, assays will be skipped if they are not 2-dimensional matrix-like objects of integer, logical or numeric type (according to type). Assays will also be skipped if SummarizedExperiment.assay.check is supplied and does not return TRUE when called with the assay's details.

When passing DataFrame objects as x, columns will be skipped if they are not atomic (i.e., integer, logical, numeric or character). Factors will be automatically converted into character vectors.

Author

Aaron Lun

Examples

library(SingleCellExperiment)
#> Loading required package: SummarizedExperiment
#> Loading required package: MatrixGenerics
#> Loading required package: matrixStats
#> 
#> Attaching package: ‘MatrixGenerics’
#> The following objects are masked from ‘package:matrixStats’:
#> 
#>     colAlls, colAnyNAs, colAnys, colAvgsPerRowSet, colCollapse,
#>     colCounts, colCummaxs, colCummins, colCumprods, colCumsums,
#>     colDiffs, colIQRDiffs, colIQRs, colLogSumExps, colMadDiffs,
#>     colMads, colMaxs, colMeans2, colMedians, colMins, colOrderStats,
#>     colProds, colQuantiles, colRanges, colRanks, colSdDiffs, colSds,
#>     colSums2, colTabulates, colVarDiffs, colVars, colWeightedMads,
#>     colWeightedMeans, colWeightedMedians, colWeightedSds,
#>     colWeightedVars, rowAlls, rowAnyNAs, rowAnys, rowAvgsPerColSet,
#>     rowCollapse, rowCounts, rowCummaxs, rowCummins, rowCumprods,
#>     rowCumsums, rowDiffs, rowIQRDiffs, rowIQRs, rowLogSumExps,
#>     rowMadDiffs, rowMads, rowMaxs, rowMeans2, rowMedians, rowMins,
#>     rowOrderStats, rowProds, rowQuantiles, rowRanges, rowRanks,
#>     rowSdDiffs, rowSds, rowSums2, rowTabulates, rowVarDiffs, rowVars,
#>     rowWeightedMads, rowWeightedMeans, rowWeightedMedians,
#>     rowWeightedSds, rowWeightedVars
#> Loading required package: GenomicRanges
#> Loading required package: stats4
#> Loading required package: BiocGenerics
#> Loading required package: generics
#> 
#> Attaching package: ‘generics’
#> The following objects are masked from ‘package:base’:
#> 
#>     as.difftime, as.factor, as.ordered, intersect, is.element, setdiff,
#>     setequal, union
#> 
#> Attaching package: ‘BiocGenerics’
#> The following objects are masked from ‘package:stats’:
#> 
#>     IQR, mad, sd, var, xtabs
#> The following objects are masked from ‘package:base’:
#> 
#>     Filter, Find, Map, Position, Reduce, anyDuplicated, aperm, append,
#>     as.data.frame, basename, cbind, colnames, dirname, do.call,
#>     duplicated, eval, evalq, get, grep, grepl, is.unsorted, lapply,
#>     mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int,
#>     rank, rbind, rownames, sapply, saveRDS, table, tapply, unique,
#>     unsplit, which.max, which.min
#> Loading required package: S4Vectors
#> 
#> Attaching package: ‘S4Vectors’
#> The following object is masked from ‘package:utils’:
#> 
#>     findMatches
#> The following objects are masked from ‘package:base’:
#> 
#>     I, expand.grid, unname
#> Loading required package: IRanges
#> Loading required package: GenomeInfoDb
#> Loading required package: Biobase
#> Welcome to Bioconductor
#> 
#>     Vignettes contain introductory material; view with
#>     'browseVignettes()'. To cite Bioconductor, see
#>     'citation("Biobase")', and for packages 'citation("pkgname")'.
#> 
#> Attaching package: ‘Biobase’
#> The following object is masked from ‘package:MatrixGenerics’:
#> 
#>     rowMedians
#> The following objects are masked from ‘package:matrixStats’:
#> 
#>     anyMissing, rowMedians
se <- SingleCellExperiment(
    assays = list(
        counts=matrix(rpois(200, lambda=5), ncol=10), 
        logcounts=matrix(rnorm(200), ncol=10)
    ),
    colData = DataFrame(
        yy = letters[1:10],
        xx = LETTERS[1:10]
    ),
    rowData = DataFrame(row.names=sprintf("GENE_%i", 1:20)),
    reducedDims = list(
        PCA = matrix(rnorm(50), nrow=10),
        TSNE = matrix(rnorm(20), nrow=10)
    )
)

tmp <- tempfile()
wobbegongify(se, tmp)
#> $object
#> [1] "single_cell_experiment"
#> 
#> $row_count
#> [1] 20
#> 
#> $column_count
#> [1] 10
#> 
#> $has_row_data
#> [1] TRUE
#> 
#> $has_column_data
#> [1] TRUE
#> 
#> $assay_names
#> [1] "counts"    "logcounts"
#> 
#> $reduced_dimension_names
#> [1] "PCA"  "TSNE"
#> 
#> $alternative_experiment_names
#> character(0)
#> 
list.files(tmp, recursive=TRUE)
#>  [1] "assays/0/content"                  "assays/0/stats"                   
#>  [3] "assays/0/summary.json"             "assays/1/content"                 
#>  [5] "assays/1/stats"                    "assays/1/summary.json"            
#>  [7] "column_data/content"               "column_data/summary.json"         
#>  [9] "reduced_dimensions/0/content"      "reduced_dimensions/0/summary.json"
#> [11] "reduced_dimensions/1/content"      "reduced_dimensions/1/summary.json"
#> [13] "row_data/content"                  "row_data/summary.json"            
#> [15] "summary.json"