Description Details Author(s) Examples
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.
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:
If k
is not specified, this will either produce another BumpyDataFrameMatrix corresponding to the specified submatrix,
or a CompressedSplitDataFrameList containing the entries of interest if drop=TRUE
.
If k
is specified, it should contain the names or indices of the columns of the underlying DataFrame to retain.
For multiple fields or with .dropk=FALSE
, a new BumpyDataFrameMatrix is returned with the specified columns in the DataFrame.
If k
only specifies a single column and .dropk=TRUE
,
a BumpyMatrix (or CompressedList, if drop=TRUE
) corresponding to the type of the field is returned.
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.
Aaron Lun
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]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.