add_sample_clustered()
adds a new variable defining a sample order based
on a hierarchical clustering of the samples.
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.
See also
Other sample-modifiers:
add_alpha()
,
add_alphas()
,
add_metadata()
,
add_ord()
,
add_spike_ratio()
,
add_total_absolute_abundance()
,
add_total_count()
,
add_total_density()
,
cluster_samples()
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