Skip to contents

Transpose the matrix and swap row and column metadata. This operation works regardless of which component is active. Uses base R's t() generic, so it works correctly even when tidyverse is loaded.

Usage

# S3 method for class 'tidymatrix'
t(x)

Arguments

x

A tidymatrix object

Value

A tidymatrix object with transposed matrix and swapped metadata

Examples

mat <- matrix(1:12, nrow = 3, ncol = 4)
row_data <- data.frame(gene = paste0("G", 1:3))
col_data <- data.frame(sample = paste0("S", 1:4))
tm <- tidymatrix(mat, row_data, col_data)

# Transpose: genes × samples → samples × genes
tm_t <- t(tm)
dim(tm_t$matrix)  # Now 4 × 3
#> [1] 4 3