Diff of /R/getSilhouette.R [000000] .. [494cbf]

Switch to unified view

a b/R/getSilhouette.R
1
#' @name getSilhouette
2
#' @title Get silhoutte plot from consensus clustering
3
#' @description This function visualizes the silhoutte information.
4
#' @param sil A sil object returned from `getConsensusMOIC()`.
5
#' @param clust.col A string vector storing colors for annotating each cluster.
6
#' @param fig.path A string value to indicate the output path for storing the consensus heatmap.
7
#' @param fig.name A string value to indicate the name of the consensus heatmap.
8
#' @param width A numeric value to indicate the width of output figure.
9
#' @param height A numeric value to indicate the height of output figure.
10
#' @return A silhoutte barplot.
11
#' @export
12
#' @import cluster
13
#' @importFrom grDevices dev.copy2pdf
14
#' @examples # There is no example and please refer to vignette.
15
getSilhouette <- function(sil       = NULL,
16
                          clust.col = c("#2EC4B6", "#E71D36", "#FF9F1C", "#BDD5EA", "#FFA5AB", "#011627","#023E8A","#9D4EDD"),
17
                          fig.path  = getwd(),
18
                          fig.name  = "silhoutte",
19
                          width     = 5.5,
20
                          height    = 5) {
21
22
  N.clust <- length(unique(sil[,1]))
23
  colvec <- clust.col[1:N.clust]
24
25
  outFig <- paste0(fig.name,".pdf")
26
  par(bty="o", mgp = c(2.5,0.33,0), mar=c(5.1,2.1,3.1,2.1)+.1, las=1, tcl=-.25)
27
  plot(sil,
28
       border = NA,
29
       col = colvec)
30
  dev.copy2pdf(file = file.path(fig.path, outFig), width = width, height = height)
31
}