add_taxon_tibble: Add taxon metadata to the tidyamplicons object

View source: R/adders_taxa.R

add_taxon_tibbleR Documentation

Add taxon metadata to the tidyamplicons object

Description

add_taxon_tibble adds a taxon tibble to the tidyamplicons object.

Usage

add_taxon_tibble(ta, taxon_tibble)

Arguments

ta

Tidyamplicons object.

taxon_tibble

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

Details

This function adds a taxon tibble containing taxon data (e.g. taxon ranks such as genus, family, ...) for each taxon 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_sample_tibble to update the sample 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 taxon tibble
taxon <- c("taxon1", "taxon2")
genus <- c("Salmonella", "Lactobacillus")
taxon_tibble <- tibble::tibble(taxon, genus)

# Add taxon tibble to tidyamplicons object
data <- data %>%
add_taxon_tibble(taxon_tibble)


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