TileDBRealizationSink: Write arrays to TileDB

Description Writing a TileDBArray Coercing to a TileDBArray Sink internals Examples

View source: R/TileDBRealizationSink.R

Description

Write array data to a TileDB backend via DelayedArray's RealizationSink machinery.

Writing a TileDBArray

 1
 2
 3
 4
 5
 6
 7
 8
 9
10

returns a TileDBRealizationSink object that can be used to write content to a TileDB backend. It accepts the following arguments:

writeTileDBArray(x, sparse=is_sparse(x), ...) writes the matrix-like object x to a TileDB backend, returning a TileDBArray object referring to that backend. Whether a sparse array should be created is determined automatically from x itself. Arguments in ... are passed to TileDBRealizationSink to configure the TileDB representation; all arguments listed above aside from dim, dimnames and type are applicable.

Coercing to a TileDBArray

as(x, "TileDBArray") will coerce a matrix-like object x to a TileDBArray object.

as(x, "TileDBArraySeed") will coerce a matrix-like object x to a TileDBArraySeed object.

as(x, "TileDBMatrix") will coerce a matrix-like object x to a TileDBArraySeed object.

as(x, "TileDBArray") will coerce a TileDBRealizationSink x to a TileDBArray object.

as(x, "TileDBArraySeed") will coerce a TileDBRealizationSink x to a TileDBArraySeed object.

as(x, "DelayedArray") will coerce a TileDBRealizationSink x to a TileDBArray object.

Sink internals

write_block(x, viewport, block) will write the subarray block to the TileDBRealizationSink x at the specified viewport, returning a NULL upon completion. See write_block in DelayedArray for more details.

type(x) will return a string specifying the type of the TileDBRealizationSink x.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
X <- matrix(rnorm(100000), ncol=200)
path <- tempfile()
out <- writeTileDBArray(X, path=path)

# Works for integer matrices.
Xi <- matrix(rpois(100000, 2), ncol=200)
pathi <- tempfile()
outi <- writeTileDBArray(Xi, path=pathi)

# Works for logical matrices.
Xl <- matrix(rpois(100000, 0.5) > 0, ncol=200)
pathl <- tempfile()
outl <- writeTileDBArray(Xl, path=pathl)

# Works for sparse numeric matrices.
Y <- Matrix::rsparsematrix(1000, 1000, density=0.01)
path2 <- tempfile()
out2 <- writeTileDBArray(Y, path=path2)

# And for sparse logical matrices.
path2l <- tempfile()
out2l <- writeTileDBArray(Y > 0, path=path2l)

# Works for dimnames.
rownames(X) <- sprintf("GENE_%i", seq_len(nrow(X)))
path3 <- tempfile()
out3 <- writeTileDBArray(X, path=path3)

aaronwolen/testtest documentation built on June 12, 2020, 12:01 a.m.