plot_ulrb_silhouette {ulrb}R Documentation

Plot silhouette scores from clustering results

Description

Plots the Silhouette scores from the clustering results of define_rb().

Usage

plot_ulrb_silhouette(
  data,
  sample_id = NULL,
  taxa_col,
  samples_col = "Sample",
  plot_all = FALSE,
  classification_col = "Classification",
  silhouette_score = "Silhouette_scores",
  colors = c("#009E73", "#F0E442", "#CC79A7"),
  log_scaled = FALSE,
  ...
)

Arguments

data

...

sample_id

string with name of selected sample.

taxa_col

string with name of column with phylogenetic units. Usually OTU or ASV.

samples_col

name of column with sample ID's.

plot_all

If TRUE, will make a plot for all samples with mean and standard deviation. If FALSE (default), then the plot will illustrate a single sample, that you have to specifiy in sample_id argument.

classification_col

string with name of column with classification for each row. Default value is "Classification".

silhouette_score

string with column name with silhouette score values. Default is "Silhouette_scores"

colors

vector with colors. Should have the same lenght as the number of classifications.

log_scaled

if TRUE then abundance scores will be shown in Log10 scale. Default to FALSE.

...

other arguments.

Details

This works as a sanity check of the results obtained by the unsupervised learning method used to classify species. This is specially important if you used an automatic number of clusters.

The function works for either a single sample (that you specify with sample_id argument), or it can apply a centrality metric for species across all your samples (plot_all = TRUE).

For more details on Silhouette score, see check_avgSil() and cluster::silhouette().

Interpretation of Silhouette plot

Based on chapter 2 of "Finding Groups in Data: An Introduction to Cluster Analysis." (Kaufman and Rousseeuw, 1991); a possible (subjective) interpretation of the clustering structure based on the Silhouette plot is:

Value

A ggplot object of Silhouette plot obtained from the selected sample.

See Also

define_rb(), check_avgSil(), plot_ulrb_clustering(), plot_ulrb(), cluster::silhouette(), cluster::pam()

Examples


classified_species <- define_rb(nice_tidy)

# Standard plot for a single sample
plot_ulrb_silhouette(classified_species,
                       sample_id = "ERR2044669",
                       taxa_col = "OTU",
                       abundance_col = "Abundance")
# All samples in a dataset
plot_ulrb_silhouette(classified_species,
          taxa_col = "OTU",
          abundance_col = "Abundance",
          plot_all = TRUE)

# All samples with a log scale
plot_ulrb_silhouette(classified_species,
          taxa_col = "OTU",
          abundance_col = "Abundance",
          plot_all = TRUE,
          log_scaled = TRUE)


[Package ulrb version 0.1.3 Index]