Skip to contents

add_sample_clustered() adds a new variable defining a sample order based on a hierarchical clustering of the samples.

Usage

add_sample_clustered(ta)

Arguments

ta

A tidytacos object.

Value

A tidytacos object with a new variable sample_clustered added to the sample table.

Details

This function calculates the Bray-Curtis distances between samples followed by hierarchical average linkage clustering of samples. It will then add a new factor variable "sample_clustered" to the sample tibble of a tidytacos object. This function is useful if one wants to plot similar samples together.

Examples

urtc <- urt %>% add_sample_clustered()
urtc$samples %>% dplyr::select(sample_id, sample_clustered)
#> # A tibble: 217 × 2
#>    sample_id sample_clustered
#>    <chr>     <fct>           
#>  1 s1        s1              
#>  2 s2        s2              
#>  3 s3        s3              
#>  4 s4        s4              
#>  5 s5        s5              
#>  6 s6        s6              
#>  7 s7        s7              
#>  8 s8        s8              
#>  9 s9        s9              
#> 10 s10       s10             
#> # ℹ 207 more rows