BumpyDataFrameMatrix: The BumpyDataFrameMatrix class

Description Details Author(s) Examples

Description

The BumpyDataFrameMatrix provides a two-dimensional object where each entry is a DataFrame. This is useful for storing data that has a variable number of observations per sample/feature combination, e.g., for inclusion as another assay in a SummarizedExperiment object.

Details

In the following code snippets, x is a BumpyDataFrameMatrix.

commonColnames(x) will return a character vector with the names of the available commonColnames. This can be modified with commonColnames(x) <- value.

x[i, j, k, ..., .dropk=drop, drop=TRUE] will subset the BumpyDataFrameMatrix:

x[i, j, k, ...] <- value will modify x by replacing the specified values with those in the BumpyMatrix value of the same dimensions. If k is not specified, value should be a BumpyDataFrameMatrix with the same fields as x. If k is specified, value should be a BumpyDataFrameMatrix with the specified fields. If k contains a single field, value can also be a BumpyAtomicMatrix containing the values to use in that field.

All methods described for the BumpyMatrix parent class are available.

Author(s)

Aaron Lun

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
library(S4Vectors)
df <- DataFrame(x=runif(100), y=runif(100))
f <- factor(sample(letters[1:20], nrow(df), replace=TRUE), letters[1:20])
out <- split(df, f)

# Making our BumpyDataFrameMatrix.
mat <- BumpyMatrix(out, c(5, 4))
mat[,1]
mat[1,]

# Subsetting capabilities.
xmat <- mat[,,"x"]
ymat <- mat[,,"y"]
filtered <- mat[xmat > 0.5 & ymat > 0.5]
filtered[,1]

# Subset replacement works as expected.
mat2 <- mat
mat2[,,"x"] <- mat2[,,"x"] * 2
mat2[,1]

LTLA/BumpyMatrix documentation built on July 5, 2021, 2:21 a.m.