Consensus Cluster Plus
Consensus Cluster Plus
Matthew D. Wilkerson
1 Summary
ConsensusClusterPlus is a tool for unsupervised class discovery. This docu-
ment provides a tutorial of how to use ConsensusClusterPlus.
3 Tutorial
There are three main steps to use ConsensusClusterPlus: preparing input
data, running the program, and generating cluster-consensus and item-consensus.
1
3.1 Preparing input data
The rst step is to gather some data for cluster analysis. These data could be
the result of an experiment such as a mRNA expression microarray or immuno-
histochemical staining intensities. The input data format is a matrix where
columns are samples (items), rows are features and cells are numerical values.
For this tutorial, we use the ALL gene expression data from the ALL library.
You can see the matrix d is already in the proper format. The column and row
names, which correspond to the sample and gene names, will be maintained in
the output.
> library(ALL)
> data(ALL)
> d=exprs(ALL)
> d[1:5,1:5]
For the purpose of selecting the most informative genes for class detection,
we reduce the dataset to the top 5,000 most variable genes, measured by median
absolute deviation. The choice of 5,000 genes and MAD can be substituted with
other statistical variability lters. Users can decide what type of ltering to use
or to skip ltering. Another choice would be to supply weights for sampling
genes see weightsFeatures in Additional Options.
> mads=apply(d,1,mad)
> d=d[rev(order(mads))[1:5000],]
If one wants to transform or normalize their data, they can easily do so using
other Bioconductor methods or a simple statement. We chose to use the default
settings of the agglomerative hierarchical clustering algorithm using Pearson
correlation distance, so it is appropriate to gene median center d using this
simple statement:
> d = sweep(d,1, apply(d,1,median,na.rm=T))
2
algorithm (clusterAlg) upon 1- Pearson correlation distances (distance), gave
our output a title (title), and opted to have graphical results written to png
les. We also used a specic random seed so that this example is repeatable
(seed).
3
3.3 Generating cluster and item consensus
After executing ConsensusClusterPlus, one can optionally calculate cluster-
consensus and item-consensus results by:
> icl = calcICL(results,title=title,plot="png")
k cluster clusterConsensus
[1,] 2 1 0.7681668
[2,] 2 2 0.9788274
[3,] 3 1 0.6176820
[4,] 3 2 0.9190744
[5,] 3 3 1.0000000
[6,] 4 1 0.8446083
[7,] 4 2 0.9067267
[8,] 4 3 0.6612850
[9,] 4 4 1.0000000
[10,] 5 1 0.8175802
[11,] 5 2 0.9066489
[12,] 5 3 0.6062040
[13,] 5 4 0.8154580
[14,] 5 5 1.0000000
[15,] 6 1 0.7511726
[16,] 6 2 0.8802040
[17,] 6 3 0.7410730
[18,] 6 4 0.8154580
[19,] 6 5 0.7390864
[20,] 6 6 1.0000000
> icl[["itemConsensus"]][1:5,]
4
option. For large datasets, graphical displays can be quite large and plotting
the consensus dendrogram above the consensus matrices may not be possible.
If your dataset is large, the plot option 'pngBMP' which does not produce the
consensus matrix dendrogram and uses the bitmap function rather png. Bitmap
is often available natively on linux systems but can potentially be installed on
other systems.
5
4.2 Consensus Cumulative Distribution Function (CDF)
Plot
This graphic shows the cumulative distribution functions [1] of the consensus
matrix for each k (indicated by colors), estimated by a histogram of 100 bins.
This gure allows a user to determine at what number of clusters, k, the CDF
reaches an approximate maximum, thus consensus and cluster condence is at
a maximum at this k. See [1] for further details intepretation.
6
4.3 Delta Area Plot
This graphic shows the relative change in area under the CDF curve [1] com-
paring k and k − 1. For k = 2, there is no k -1, so the total area under the
curve rather than the relative increase is plotted. This plot allows a user to
determine the relative increase in consensus and determine k at which there is
no appreciable increase. See [1] for intepretation.
7
to track the history of clusters relative to earlier clusters. Items that change
clusters often (changing colors within a column) are indicative of unstable mem-
bership. Clusters with an abundance of unstable members suggest an unstable
cluster.
8
4.6 Item-Consensus Plot
Item-consensus values are the mean consensus of an item with all items in a
particular cluster. An item has k item-consensus values corresponding to each
cluster at a particular k. These values are depicted in barplots for each k. Sam-
ples are stacked bars. Item-consensus values are indicated by the heights of
the colored portion of the bars, whose color corresponds to the common color
scheme. Bars' rectangles are ordered by increasing value from bottom to top.
The asterisks at the top indicate the consensus cluster for each item.
This plot provides a view of item-consensus across all other clusters at a given
k. This enables a user to see if a sample is a very "pure" member of a cluster or
if it shares high consensus to multiple clusters (large rectangles in a column of
multiple colors), suggesting that it is an unstable or "unpure" member. These
values could be used to select "core" samples similar to [4] that are highly rep-
resentative of a cluster. Further, this plot can aid cluster number decisions. For
instance, if a cluster consists mainly of members with very "unpure" items, then
this evidence could be used to support a maximum cluster number at 1 below
this k or this evidence could support that this cluster is an outlier cluster. De-
cisions such as these are best to be made by the user in conjunction with other
evidence such as consensus matrices, tracking plots, etc.
9
large datasets (1,000's of items) and no feature resampling, this process
can be time consuming and unnecessary. Alternatively, a pre-computed
distance matrix can be provided as d, resulting in faster computation. An
example of using a dist object as input follow below.
> #example of providing a custom distance matrix as input:
> #dt = as.dist(1-cor(d,method="pearson"))
> #ConsensusClusterPlus(dt,maxK=4,reps=100,pItem=0.8,pFeature=1,title="example2",distan
distanceThis option describes the distance metric to be used. A character
value of one of the following metrics is accepted: pearson for (1 - Pearson
correlation), spearman for (1 - Spearman correlation), euclidean, binary,
maximum, canberra, minkowski. Alternatively a custom distance function
cab be supplied for this argument, which accepts a numerical matrix (items
as rows and features as columns) as input and returns a dist object.
> #example of providing a custom distance function:
> #myDistFunc = function(x){ dist(x,method="manhattan")}
> #ConsensusClusterPlus(d,maxK=4,reps=100,pItem=0.8,pFeature=1,title="example3",distanc
clusterAlg This option species the type of clustering algorithm to use:
"hc" for hierarchical clustering, "pam" for partioning around medoids,
"km" for kmeans. Alternatively, one can supply their own clustering func-
tion, which should accept a distance matrix and a cluster number as its
arguments and returns vector of cluster assignments having the same order
as the distance matrix columns. For example, this simple function exe-
cutes divisive clustering using the diana function from the cluster package
and returns the expected object. The last line shows an example of how
this could be used.
> #library(cluster)
> #dianaHook = function(this_dist,k){
> #tmp = diana(this_dist,diss=TRUE)
> #assignment = cutree(tmp,k)
> #return(assignment)
> #}
> #ConsensusClusterPlus(d,clusterAlg="dianaHook",distance="pearson",...)
update on kmeans options "km" option performs kmeans clustering
directly on a data matrix, with items and features resampled.
innerLinkage This option species the linkage method to use in itera-
tive agglomerative hierarchical clustering. Not applicable to other cluster
algorithms.
nalLinkage This option species the linkage method to use in the nal
agglomerative hierarchical clustering.
10
distance This option species the distance metric to use: "pearson" for
1-Pearson correlation coecient, "spearman" for 1-Spearman correlation
coecient, "euclidean" for Euclidean distance.
tmyPal character vector of ordered colors to use for consensus matrix. If
not specied, a series of white to blue colors is used.
writeTable boolean. If TRUE, write consensus matrices, ICL, and log
to le.
weightsFeature numerical vector of weights for sampling features. See
help for further details.
weightsItem numerical vector of weights for sampling items. See help
for further details.
verbose boolean. If TRUE, print messages to the screen to indicate
progress. This is useful for large datasets.
References
[1] 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.
[2] Wilkerson, M.D., Hayes, D.N. (2010). ConsensusClusterPlus: a class discov-
ery tool with condence assessments and item tracking. Bioinformatics, 2010
Jun 15;26(12):1572−3.
[3] Hayes, D.N, Monti, S., Parmigiani, G. et al. (2006) Gene Expression Proling
Reveals Reproducible Human Lung Adenocarcinoma Subtypes in Multiple In-
dependent Patient Cohorts. Journal of Clinical Oncology, 24 (31) 5079−5090.
[4] Verhaak, R., Hoadley, K., et al. (2010) Integrated genomic analysis identies
clinically relevant subtypes of glioblastoma characterized by abnormalities in
PDGFRA, IDH1, EGFR and NF1. Cancer Cell. 17,1-13.
[5] http://www.broadinstitute.org/cancer/software/genepattern/
4.8 Changes
Version 1.0.1. Item-consensus calculation was corrected. Consensus ma-
trix heat maps are now guaranteed to correspond to the scale.
Version 1.5.1. Version 1.0.1 changes were re-incorporated into Bioc 2.9,
2.8. Version 1.0.1 was part of Bioc 2.6, but not part of Bioc 2.7.
11
Version 1.11.1. For large datasets, the input data (d) was modied to also
accept a distance matrix which reduces computation time, and plotBMP
was added a plot type so that large consensus matrices can be plot-
ted. Internal data structures were modied to increase speed. Distance
metric options expanded ("maximum", "manhattan", "canberra", "bi-
nary","minkowski" from dist) and custom distance function option added.
Partitioning Around Mediods clustering (from cluster package) was added
as a clustering algorithm. Kmeans invocation was changed to run on the
data matrix by default. Kmeans invocation on a distance matrix is now
possible by kmdist.
Version Version 1.35.0 Added CITATION le, updated references, and
man pages.
Version 1.51.1 Breif R code update for compatibilty with R 4.0. Depre-
cated kmdist clustering option.
12