plotSilhouette | R Documentation |
This function creates a violin scatter plot to show the distribution of the approximate silhouette width across cells in each cluster.
plotSilhouette(
object,
clusters,
printDiff = TRUE,
plot = TRUE,
cluster_color = NULL,
point_size = 2,
point_alpha = 0.8,
point_shape = 16,
swarm_method = "quasirandom",
add_mean = TRUE,
mean_color = "firebrick",
mean_size = 1,
theme_size = 18
)
object |
A numeric matrix-like object containing observations in rows and variables in columns. |
clusters |
A vector of length equal to |
printDiff |
Logical scalar indicating whether to print the precentage
of cells assigned to different cluster(s). Default is |
plot |
Logical scalar indicating whether to draw the plot. Default is
|
cluster_color |
A character vector of color codes indicating the
colour of the clusters. Default is |
point_size |
A numeric scalar indicating the size of the points. Default is 2. |
point_alpha |
A numeric scalar (between 0 and 1) indicating the transparency. Default is 0.8. |
point_shape |
An integer scalar (between 0 and 25) indicating the shape aesthetics. Default is 16. |
swarm_method |
A string indicating the method for arranging points. Method recongised by ggbeeswarm are "quasirandom", "pseudorandom", "smiley" and "frowney". Default is "quasirandom". |
add_mean |
Logical scalar indicating whether add a horizontal
reference line at mean silhouette width. Default is |
mean_color |
A string indicating the colour of the reference line. Default is "firebrick". |
mean_size |
A numeric scalar indicating the size of the reference line. Default is 1. |
theme_size |
A numeric scalar indicating the base font size. Default is 18. |
The function uses approxSilhouette()
from the bluster package' to
calculate the silhouette widths using an approximate approach. Using the
information stored in the returned DataFrame, it:
prints the descriptive statistics of approximate silhouette widths.
calculates the percentage of cells assigned to the closest cluster and
prints the result when printDiff = TRUE
.
creates a violin scatter plot to show thedistribution of the approximate
silhouette width when plot = TRUE
.
These information can allow users to identify poorly separate clusters quickly.
A ggplot
object when plot = TRUE
I-Hsuan Lin
bluster::approxSilhouette()
# Load demo dataset
data(sce)
mat <- SingleCellExperiment::reducedDim(sce, "PCA")
plotSilhouette(mat, sce$label)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.