add_sample_tibble: Add sample table to the tidyamplicons object

View source: R/adders_samples.R

add_sample_tibbleR Documentation

Add sample table to the tidyamplicons object

Description

add_sample_tibble adds a sample tibble to the tidyamplicons object.

Usage

add_sample_tibble(ta, sample_tibble)

Arguments

ta

Tidyamplicons object.

sample_tibble

A tibble containing sample data for each sample. samples should be rows, while sample data should be columns. At least one column name needs to be shared with the sample tibble of ta. The default shared column name is 'sample'.

Details

This function adds a sample tibble containing metadata for each sample to the tidyamplicons object. It is used after initiating a tidyamplicons object using a numerical abundance matrix and the function create_tidyamplicons. Also see add_taxon_tibble to update the taxon data of the tidyamplicons object.

Examples

# Initiate abundance matrix
x <- matrix(
 c(1500, 1300, 280, 356),
 ncol = 2
)
rownames(x) <- c("taxon1", "taxon2")
colnames(x) <- c("sample1", "sample2")

# Convert to tidyamplicons object
data <- create_tidyamplicons(x,
                     taxa_are_columns = FALSE
                     )

# Initiate sample tibble
sample <- c("sample1", "sample2")
environment <- c("food fermentation", "human stool")
sample_tibble <- tibble::tibble(sample, environment)

# Add sample tibble to tidyamplicons object
data <- data %>%
add_sample_tibble(sample_tibble)


SWittouck/tidyamplicons documentation built on Aug. 15, 2023, 3:14 a.m.