add_pcoa: Add first two dimensions of PCOA

View source: R/adders_samples.R

add_pcoaR Documentation

Add first two dimensions of PCOA

Description

add_pcoa adds the first two dimensions of a principal components analysis on a Bray-Curtis dissimilarity matrix to two new variables of the samples tibble of a tidyamplicons object.

Usage

add_pcoa(ta)

Arguments

ta

Tidyamplicons object.

Details

This function calculates the Bray-Curtis distance between samples followed by a principal components analysis. It will then add the two first dimensions to the samples tibble of a tidyamplicons object named "pcoa1" and "pcoa2". This function will also add relative abundances if not present using add_rel_abundance.

Examples

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

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

# Add total abundance
data <- data %>%
 add_pcoa()


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