convert_from_matrix: Convert a wide matrix to a tidy tibble

View source: R/convert.R

convert_from_matrixR Documentation

Convert a wide matrix to a tidy tibble

Description

This functions transforms a matrix holding a wide feature table into a "long" and tidy tibble to use it with functions provided in the metamorphr package. convert_from_matrix works with objects of class matrix. To convert a data frame or tibble, see convert_from_wide.

Usage

convert_from_matrix(data, samples_in_cols = TRUE)

Arguments

data

A feature table matrix in wide format. To convert a wide data frame, see convert_from_wide.

samples_in_cols

TRUE if samples are in columns and features in rows, FALSE if it is reversed. See examples for more information.

Value

A tidy tibble.

Examples

# Using a small fictional data set
dataset <- matrix(1:9, ncol = 3)
colnames(dataset) <- paste0("sample", 1:3)
rownames(dataset) <- paste0("feature", 1:3)


# Example 1: Samples in columns
dataset
convert_from_matrix(dataset)

# Example 2: Samples in rows
dataset_transposed <- t(dataset)
dataset_transposed

convert_from_matrix(dataset, samples_in_cols = FALSE)

metamorphr documentation built on June 10, 2026, 5:07 p.m.