fstArray-class: fst datasets as array-like objects

Description Usage Arguments Value See Also Examples

Description

We provide 2 classes for representing an (on-disk) fst dataset as an array-like object in R:

Usage

1
2
3
fstArraySeed(filepath, old_format = FALSE)

fstArray(filepath, old_format = FALSE)

Arguments

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 TRUE to read fst files generated with a fst package version lower than v0.8.0.

Value

An fstArray object for fstArray().

An fstArraySeed object for fstArraySeed().

See Also

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
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))

PeteHaitch/fstArray documentation built on May 5, 2019, 12:27 p.m.