add_sample_clustered: Add clustered sample order

View source: R/adders_samples.R

add_sample_clusteredR Documentation

Add clustered sample order

Description

add_sample_clustered adds a new variable defining a sample order based on similarity after clustering to the samples tibble of a tidyamplicons object.

Usage

add_sample_clustered(ta)

Arguments

ta

Tidyamplicons object.

Details

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.

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
                     )

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


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