View source: R/adders_samples.R
add_sample_clustered | R Documentation |
add_sample_clustered
adds a new variable defining a sample order based
on similarity after clustering to the samples tibble of a tidyamplicons
object.
add_sample_clustered(ta)
ta |
Tidyamplicons object. |
This function calculates the Bray-Curtis distance between samples followed by hierarchical average linkage clustering of samples. It will then add a new factor variable "samples_clustered" to the samples tibble of a tidyamplicons object. This function is extremely useful if one wants to plot similar samples together.
# 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
)
# Add total abundance
data <- data %>%
add_sample_clustered()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.