TableContainer
is an R package that provides a
lightweight and flexible container for managing tabular data with
associated row and column annotations. It is inspired by Bioconductor’s
SummarizedExperiment
but does not rely on Bioconductor
dependencies, making it easier to integrate into various workflows.
To install the development version of
TableContainer
:
::install_github("Jiefei-Wang/TableContainer") remote
To install the stable version from CRAN:
install.packages("TableContainer")
You can create a TableContainer
object using the
TableContainer()
constructor:
library(TableContainer)
# Example data
<- matrix(1:12, nrow = 3, ncol = 4)
tbl <- data.frame(row1 = 1:3, row2 = letters[1:3])
row_dt <- data.frame(col1 = 1:4, col2 = letters[1:4])
col_dt <- list(meta1 = "meta1", meta2 = "meta2")
metadata
# Create a TableContainer
<- TableContainer(
container table = tbl,
rowData = row_dt,
colData = col_dt,
metaData = metadata
)
Example output:
> container
# TableContainer: 3 rows x 4 cols ( matrix )
[,1] [,2] [,3] [,4]
[1,] 1 4 7 10
[2,] 2 5 8 11
[3,] 3 6 9 12
---
rowData: [2 vars] row1, row2
colData: [2 vars] col1, col2
metadata: [2 elements] meta1, meta2
Subset the TableContainer
object while maintaining
consistency in annotations:
# Subset rows and columns
<- container[1:2, 2:4] subset_container
Example output:
> subset_container
# TableContainer: 2 rows x 3 cols ( matrix )
[,1] [,2] [,3]
[1,] 4 7 10
[2,] 5 8 11
---
rowData: [2 vars] row1, row2
colData: [2 vars] col1, col2
metadata: [2 elements] meta1, meta2
You can access and modify the table, row annotations, column annotations, and metadata using accessor methods:
# Access data
tblData(container)
rowData(container)
colData(container)
metaData(container)
# Modify data
tblData(container) <- matrix(13:24, nrow = 3, ncol = 4)
rowData(container) <- data.frame(newRow = 1:3)
colData(container) <- data.frame(newCol = 1:4)
metaData(container) <- list(newMeta = "updated metadata")
For detailed documentation, see the vignette of the package:
vignette("TableContainer")
This package is licensed under the MIT License.
Developed by Jiefei Wang (szwjf08@gmail.com).