plot_consensus: Consensus Matrix Heatmap

View source: R/plot_consensus.R

plot_consensusR Documentation

Consensus Matrix Heatmap

Description

This function displays pairwise consensus cluster distances as a heatmap.

Usage

plot_consensus(
  cc,
  k,
  group = NULL,
  covar = NULL,
  hclustfun = "complete",
  pal_clust = "d3",
  pal_group = "npg",
  pal_covar = "Blues",
  pal_tiles = "RdBu",
  title = "Consensus Matrix"
)

Arguments

cc

A list created by a call to ConsensusClusterPlus.

k

Integer specifying number of clusters to visualize.

group

Optional character or factor vector of length equal to sample size. Alternatively, a data frame or list of such vectors, optionally named.

covar

Optional continuous covariate of length equal to sample size. Alternatively, a data frame or list of such vectors, optionally named.

hclustfun

The agglomeration method to be used for hierarchical clustering. Supports any method available in hclust.

pal_clust

String specifying the color palette to use for cluster assignments. Options include "ggplot", all qualitative color schemes available in RColorBrewer, and the complete collection of ggsci palettes.

pal_group

String specifying the color palette to use if group is non-NULL, or a vector of such strings with length equal to the number of vectors passed to group. Options are the same as those for pal_clust. Alternatively, a character vector of colors with length equal to the cumulative number of levels in group.

pal_covar

String specifying the color palette to use if covar is non-NULL, or a vector of such strings with length equal to the number of vectors passed to covar. Options include the complete collection of viridis palettes, as well as all sequential color schemes available in RColorBrewer. Alternatively, a character vector of colors representing a smooth gradient, or a list of such vectors with length equal to the number of continuous variables to visualize.

pal_tiles

String specifying the color palette to use for heatmap tiles. Options include the complete collection of viridis palettes, as well all diverging color schemes available in RColorBrewer. Alternatively, a character vector of at least two colors.

title

Optional plot title.

Details

Consensus clustering is a resampling procedure to evaluate cluster stability. A user-specified proportion of samples are held out on each run of the algorithm to test how often the remaining samples do or do not cluster together. The result is a square consensus matrix for each value of cluster numbers k. Each cell of the matrix mat[i, j] represents the proportion of all runs including samples i and j in which the two were clustered together.

plot_consensus converts a consensus matrix into a distance matrix by taking the complement of all values and visualising the result as a heatmap. These figures are similar to those presented in the original consensus cluster paper by Monti et al.

References

Monti, S., Tamayo, P., Mesirov, J., & Golub, T. (2003). Consensus Clustering: A Resampling-Based Method for Class Discovery and Visualization of Gene Expression Microarray Data. Machine Learning, 52: 91-118.

Examples

# Load libraries
library(ConsensusClusterPlus)

# Import, filter, transform data
data(airway)
mat <- assay(airway)
mads <- apply(mat, 1, mad)
keep <- order(mads, decreasing = TRUE)[seq_len(1000)]
mat <- mat[keep, ]
mat <- log2((mat + 1L) / 1e6L)

# Run consensus clustering, plot results
cc <- ConsensusClusterPlus(mat)
plot_consensus(cc, k = 2)


dswatson/bioplotr documentation built on March 3, 2023, 9:43 p.m.