View source: R/adders_samples.R
add_pcoa | R Documentation |
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.
add_pcoa(ta)
ta |
Tidyamplicons object. |
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
.
# 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()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.