Description Usage Arguments Value See Also Examples
We provide 2 classes for representing an (on-disk) fst dataset as an array-like object in R:
fstArray: A high-level class, fstArray extends DelayedArray::DelayedArray. All the operations available on DelayedArray::DelayedArray objects work on fstArray objects.
fstArraySeed: A low-level class for pointing to a fst dataset. No operation can be performed directly on an fstArraySeed object. It needs to be wrapped in a DelayedArray::DelayedArray or fstArray object first. An fstArray object is just an fstArraySeed wrapped in a DelayedArray::DelayedArray object.
1 2 3 | fstArraySeed(filepath, old_format = FALSE)
fstArray(filepath, old_format = FALSE)
|
filepath |
The path (as a single character string) to the fst file where the dataset is located or an fst::fst_table instance. |
old_format |
use |
An fstArray object for fstArray()
.
An fstArraySeed object for fstArraySeed()
.
fst::write_fst()
for writing a data frame to disk as an 'fst' file.
DelayedArray::DelayedArray objects.
DelayedArray::DelayedArray-utils for common operations on DelayedArray::DelayedArray objects
base::array objects in base R.
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | # ----------------------------------------------------------------------
# CONSTRUCTION
# ----------------------------------------------------------------------
# Simulate some data in a data frame and write to disk as an 'fst' file
library(fst)
x <- as.data.frame(replicate(10, runif(10000)))
fst_file <- tempfile(fileext = ".fst")
write_fst(x, fst_file)
# Construct an fstArray from an fst file
fst_array <- fstArray(fst_file)
fst_array
# Construct an fstArray from an fst::fst_table
fst_table <- fst(fst_file)
class(fst_table)
fstArray(fst_table)
# ----------------------------------------------------------------------
# dim/dimnames
# ----------------------------------------------------------------------
dim(fst_array)
dimnames(fst_array)
dimnames(fst_array) <- list(paste0("gene", seq_len(nrow(fst_array))),
paste0("S", seq_len(ncol(fst_array))))
fst_array
# ----------------------------------------------------------------------
# SLICING (A.K.A. SUBSETTING)
# ----------------------------------------------------------------------
fst_array2 <- drop(fst_array[31:40, c("S3", "S6")])
fst_array2
dim(fst_array2)
as.array(fst_array2)
stopifnot(identical(dim(as.array(fst_array2)), dim(fst_array2)))
stopifnot(identical(dimnames(as.array(fst_array2)), dimnames(fst_array2)))
# ----------------------------------------------------------------------
# SummarizedExperiment OBJECTS WITH DELAYED ASSAYS
# ----------------------------------------------------------------------
library(SummarizedExperiment)
se <- SummarizedExperiment(fst_array)
se
stopifnot(validObject(se, complete = TRUE))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.