Skip to contents

Generate a silhouette plot for a specified clustering partition within a muscadet object.

Usage

plotSil(x, partition, colors = NULL, title = NULL, annotations = TRUE)

Arguments

x

A muscadet object containing clustering data (using clusterMuscadet()).

partition

Value specifying the clustering partition to plot (numeric or character). It should be either the resolution or the k number of cluster (k) used for clustering depending on the clustering method (res_range or k_range with clusterMuscadet()).

colors

Vector of colors for the cluster annotation (character vector). Default is NULL, which uses predefined colors.

title

Character string for the title of the plot (character string). If NULL, a default title is generated.

annotations

TRUE or FALSE (logical). Whether to add annotations per clusters. By default: TRUE.

Value

A ggplot object representing the silhouette plot.

Examples

if (FALSE) { # \dontrun{
library("ggplot2")

# Load example muscadet object
data(muscadet_obj)
plotSil(muscadet_obj, partition = 0.6)

# Loop over partitions
for (p in names(muscadet_obj$clustering$clusters)) {
    plot <- plotSil(muscadet_obj, p)
    ggsave(paste0("plot_silhouette_", p, ".png"), plot)
}
} # }