TileDBArray: Delayed TileDB arrays

View source: R/TileDBArray.R

TileDBArrayR Documentation

Delayed TileDB arrays

Description

The TileDBArray class provides a DelayedArray backend for TileDB arrays (sparse and dense).

Constructing a TileDBArray

TileDBArray(x, attr) returns a TileDBArray object given:

  • x, a string containing a URI to a TileDB backend, most typically a path to a directory.

  • attr, a string specifying the attribute to represent in the array. Defaults to the first attribute.

Alternatively, x can be a TileDBArraySeed object, in which case attr is ignored.

TileDBArraySeed(x, attr) returns a TileDBArraySeed with the same arguments as described for TileDBArray. If x is already a TileDBArraySeed, it is returned directly without further modification.

DelayedArray(x) returns a TileDBArray object given x, a TileDBArraySeed.

In all cases, two-dimensional arrays will automatically generate a TileDBMatrix, a subclass of the TileDBArray.

Available operations

extract_array(x, index) will return an ordinary array containing values from the TileDBArraySeed x, subsetted to the indices specified in index. The latter should be a list of length equal to the number of dimensions in x, where each entry is an integer vector or NULL (in which case the entirety of the dimension is used).

extract_sparse_array(x, index) will return a COO_SparseArray representing the subset of x corresponding to the indices in index. The latter should be a list of the same structure as described for extract_array.

type(x) will return a string containing the type of the TileDBArraySeed object x. Currently, only "integer", "logical" and "double"-precision is supported.

is_sparse(x) will return a logical scalar indicating whether the TileDBArraySeed x uses a sparse format in the TileDB backend.

path(x) will return a string containing the path to the TileDB backend directory.

chunkdim(x) will return an integer vector containing the tile extent in each dimension. This will be used as the chunk dimensions in methods like chunkGrid.

All of the operations described above are also equally applicable to TileDBArray objects, as their methods simply delegate to those of the TileDBArraySeed.

All operations supported by DelayedArray objects are also available for TileDBArray objects.

Author(s)

Aaron Lun

Examples

data <- matrix(rpois(10000, 5), nrow=100, ncol=100)
B <- as(data, "TileDBArray")
B

# Apply typical DelayedArray operations:
as.matrix(B[1:10,1:10])
B %*% runif(ncol(B))

# This also works for sparse arrays:
sdata <- Matrix::rsparsematrix(nrow=100, ncol=100, density=0.1)
C <- as(sdata, "TileDBArray")
C


LTLA/TileDBArray documentation built on Oct. 9, 2024, 7:52 a.m.