plot.CBASS provides a range of ways to visualize the results of convex clustering, including:

  • Dendrograms, illustrating the nested cluster hierarchy inferred from the convex clustering solution path (type = "row.dendrogram" and type = "col.dendrogram" for the row (observation) and column (feature / variable) clusterings, respectively);

  • Path plots, showing the coalescence of the estimated cluster centroids as the regularization parameter is increased (type = "row.dendrogram" and type = "col.dendrogram" for the row (observation) and column (feature / variable) clusterings, respectively);

  • A cluster heatmap, displaying row and column histograms, as well as the clustered data matrix in a single graphic (type = "heatmap");

  • An interactive Javascript cluster (interactive = TRUE)

# S3 method for CBASS
plot(
  x,
  ...,
  type = c("heatmap", "row.dendrogram", "col.dendrogram", "row.path", "col.path"),
  dynamic = FALSE,
  interactive = FALSE,
  percent,
  k.row,
  k.col,
  percent.seq = seq(0, 1, 0.01),
  axis = c("PC1", "PC2"),
  slider_y = -0.3,
  refit = FALSE
)

Arguments

x

An object of class CBASS as returned by CBASS

...

Additional arguments, which are handled differently for different values of type.

  • When type is "heatmap", "row.path" or "col.path", the presence of unknown arguments triggers an error;

  • when type == "row.dendrogram" or type == "col.dendrogram", ... is forwarded to dendrogram;

  • when type == "heatmap" and interactive == TRUE, ... is forwarded to heatmaply.

See the documentation of ggplot (for interactive == FALSE) or plotly (for interactive == TRUE) for details about additional supported arguments to the corresponding plot type.

type

A string indicating the type of visualization to show (see details above).

dynamic

A logical scalar.Should the resulting animation be dynamic (animated) or not? If TRUE, a dynamic visualization which varies along the CARP solution path at a grid given by percent.seq is produced. If FALSE, a fixed visualization at a single solution (determined by either percent or k if supplied) is produced.

interactive

A logical scalar. Should the resulting animation be interactive or not? If TRUE, an interactive visualization is produced by javascript(plotly). If FALSE, a non-interactive visualization is produced by ggplot.

percent

A number between 0 and 1, giving the regularization level (as a fraction of the final regularization level used) at which to assign clusters in the static (type = "dendrogram" or type = "path") plots.

k.row

An integer indicating the desired number of row clusters to be displayed in the static plots. (If plotting columns, the regularization level giving k.row rows clusters is used.)

k.col

An integer indicating the desired number of column clusters to be displayed in the static plots. (If plotting rows, the regularization level giving k.col column clusters is used.)

percent.seq

A grid of values of percent along which to generate dynamic visualizations (if dynamic == TRUE)

axis

A character vector of length two indicating which features or principal components to use as the axes in the path visualizations. Currently only features like "PC1" or "PC2" (indicating the first principal component projections) are supported.

slider_y

A number to adjust the slider's vertical position for interactive dendrogram plots (ignored for other plot types).

refit

A logical scalar. Should "naive" centroids (TRUE) or the actual centroids estimated by convex clustering be used? When the default refit = FALSE, the estimated U from the convex clustering problem is used. The refit = TRUE returns actual centroids (mean) of all elements assigned to that cluster; Due to the global shrinkage imposed, these clusters are more "shrunk together" than the naive clusters. Only for the heatmap plots. (ignored for other plot types).

Value

The value of the return type depends on the interactive and dynamic:

  • if interactive = FALSE and dynamic = FALSE, an object of class ggplot is returned;

  • if interactive = FALSE and dynamic = TRUE, an object of class gganim is returned;

  • if interactive = TRUE, an object of class plotly is returned.

All the plots can be plotted directly (by invoking its print method) or further manipulated by the user.

Examples

cbass_fit <- CBASS(presidential_speech)
#> Pre-computing column weights and edge sets
#> Pre-computing row weights and edge sets
#> Computing Convex Bi-Clustering [CBASS] Path
#> Post-processing rows
#> Post-processing columns
plot(cbass_fit)
plot(cbass_fit, type = "col.path")
plot(cbass_fit, type = "col.dendrogram")
plot(cbass_fit, type = "heatmap")
plot(cbass_fit, type = "heatmap", dynamic = TRUE) if (FALSE) { plot(cbass_fit, type='heatmap', interactive=TRUE) }