MyNixOS website logo
Description

Create a Table with Row, Column, and Table Annotations.

Offers a TableContainer() function to create tables enriched with row, column, and table annotations. This package is similar to 'SummarizedExperiment' in Bioconductor <doi:10.18129/B9.bioc.SummarizedExperiment>, but designed to work independently of Bioconductor, it ensures annotations are automatically updated when the table is subset. Additionally, it includes format_tbl() methods for enhanced table formatting and display.

R-CMD-check Codecov testcoverage

TableContainer

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.

Features

  • Matrix-like Data Storage: Store data in a matrix or data frame format.
  • Row and Column Annotations: Add metadata to rows and columns using data frames.
  • Flexible Metadata: Attach arbitrary metadata to the container.
  • Automatic Annotation Updates: Automatically update annotations when subsetting the table.

Installation

To install the development version of TableContainer:

remote::install_github("Jiefei-Wang/TableContainer")

To install the stable version from CRAN:

install.packages("TableContainer")

Usage

Creating a TableContainer

You can create a TableContainer object using the TableContainer() constructor:

library(TableContainer)

# Example data
tbl <- matrix(1:12, nrow = 3, ncol = 4)
row_dt <- data.frame(row1 = 1:3, row2 = letters[1:3])
col_dt <- data.frame(col1 = 1:4, col2 = letters[1:4])
metadata <- list(meta1 = "meta1", meta2 = "meta2")

# Create a TableContainer
container <- TableContainer(
  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

Subsetting

Subset the TableContainer object while maintaining consistency in annotations:

# Subset rows and columns
subset_container <- container[1:2, 2:4]

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

Accessing and Modifying Data

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

Documentation

For detailed documentation, see the vignette of the package:

vignette("TableContainer")

License

This package is licensed under the MIT License.

Author

Developed by Jiefei Wang ([email protected]).

Metadata

Version

1.0.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows