Description Writing a TileDBArray Coercing to a TileDBArray Sink internals Examples
View source: R/TileDBRealizationSink.R
Write array data to a TileDB backend via DelayedArray's RealizationSink machinery.
1 2 3 4 5 6 7 8 9 10 | TileDBRealizationSink(
dim,
dimnames=NULL,
type="double",
path=getTileDBPath(),
attr=getTileDBAttr(),
sparse=FALSE,
extent=getTileDBExtent(),
context=getTileDBContext()
)
|
returns a TileDBRealizationSink object that can be used to write content to a TileDB backend. It accepts the following arguments:
dim
, an integer vector (usually of length 2) to specify the array dimensions.
dimnames
, a list of length equal to dim
, containing character vectors with names for each dimension.
Defaults to NULL
, i.e., no dimnames.
type
, a string specifying the data type.
Currently only numeric, logical and integer arrays are supported.
path
, a string containing the location of the new TileDB backend.
attr
, a string specifying the name of the attribute to store.
sparse
is a logical scalar indicating whether the array should be stored in sparse form.
extent
is an integer scalar (or vector of length equal to dim
)
specifying the tile extent for each dimension.
context
is the TileDB context, defaulting to the output of tiledb_ctx()
.
writeTileDBArray(x, sparse=is_sparse(x), ...)
writes the matrix-like object x
to a TileDB backend,
returning a TileDBArray object referring to that backend.
Appropriate values for dim
, dimnames
and type
are determined automatically from x
itself.
All other arguments described for TileDBRealizationSink
can be passed into ...
to configure the representation.
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.
write_block(sink, viewport, block)
will write the subarray block
to the TileDBRealizationSink sink
at the specified viewport
, returning sink
upon completion.
See write_block
in DelayedArray for more details.
type(x)
will return a string specifying the type of the TileDBRealizationSink x
.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.