The R package klic (Kernel Learning Integrative Clustering) contains a collection of tools for integrative clustering of multiple data types.

The main function in this package is klic. It takes as input a list of datasets and builds one kernel per dataset, using consensus clustering. The kernels are then combined through localised kernel k-means to obtain the final clustering. The function also gives the user the option to try several different values for the number of clusters both at the level of the individual datasets and for the final clustering. This is the simplest way to perform Kernel Learning Integrative Clustering. However, users may want to include other types of kernels (instead of using only those derived from consensus clustering) or try different parameters for consensus clustering and include all the corresponding kernels in the analysis. Therefore, we also make available some of the functions needed to build a customised KLIC pipeline, that are:

  • spectrumShift. This function takes as input any symmetric matrix (including co-clustering matrices) and checks whether it is positive semi-definite. If not, the eigenvalues of matrix are shifted by a (small) constant in order to make sure that it is a valid kernel.

  • lmkkmeans. This is a function implemented by Gonen and Margolin (2014) that performs localised kernel k-means on a set of kernel matrices (such as -appropriately shifted- co-clustering matrices, for example).

The other function needed for this is consensusCluster. This function can be found in the R package coca and is used to perform consensus clustering on one dataset and obtain a co-clustering matrix (Monti et al. 2003).

Other functions included in the package are:

  • plotSimilarityMatrix, to plot a similarity matrix with the option to divide the rows of the matrix according to the clusters and to include a vector of labels for each row;
  • kkmeans, another function implemented by Gonen and Margolin (2004) to perform kernel k-means with only one kernel matrix (Girolami, 2002);
  • copheneticCorrelation, to calculate the cophenetic correlation of a similarity matrix.

How KLIC works

First, we generate four datasets with the same clustering structure (6 clusters of equal size) and different levels of noise.

## Load synthetic data
data1 <- as.matrix(read.csv(system.file("extdata", "dataset1.csv", package = "klic"), row.names = 1))
data2 <- as.matrix(read.csv(system.file("extdata","dataset2.csv", package = "klic"), row.names = 1))
data3 <- as.matrix(read.csv(system.file("extdata", "dataset3.csv", package = "klic"), row.names = 1))
data <- list(data1, data2, data3)
n_datasets <- 3
N <- dim(data[[1]])[1]
trueLab <- as.matrix(read.csv(system.file("extdata", "cluster_labels.csv", 
                                                 package = "klic"), row.names = 1))

Now we can use the consensusClustering function to compute a consensus matrix for each dataset.

Before using kernel methods, we need to make sure that all the consensus matrices are positive semi-definite.

Now we can perform localised kernel k-kmeans on the set of consensus matrices using the function lmkkmeans to find a global clustering. This functions also need to be provided with a list of parameters containing the prespecified number of clusters and the maximum number of iterations for the k-means algorithm.

The output of lmkkmeans contains, among other things, the final cluster labels. To compare two clusterings, such as for example the true clustering (that is known in this case) and the clustering found with KLIC, we suggest to use the adjustedRandIndex function of the R package mclust. An ARI close to 1 indicates a high similarity between the two partitions of the data.

## Compare clustering found with KLIC to the true one
library(mclust, verbose = FALSE)
adjustedRandIndex(trueLab, lmkkm$clustering) 
## [1] 0.8342068

If the global number of clusters is not known, one can find the weights and clusters for different values of K and then find the one that maximises the silhouette.

## NULL

The same can be done simply using the function klic

klic <- klic(data, M = n_datasets, individualK = c(6,6,6))
## [1] "All datasets contain the same number of observations, 300."
## [1] "We assume that the observations are the same in each dataset and that they are in the same order."
## [1] "*** Generating similarity matrices ***"
## 
  |                                                                       
  |                                                                 |   0%
  |                                                                       
  |======================                                           |  33%
  |                                                                       
  |===========================================                      |  67%
  |                                                                       
  |=================================================================| 100%
## [1] "*** Choosing the number of clusters for the global clustering ***"
## 
  |                                                                       
  |                                                                 |   0%
  |                                                                       
  |=============                                                    |  20%
  |                                                                       
  |==========================                                       |  40%
  |                                                                       
  |=======================================                          |  60%
  |                                                                       
  |====================================================             |  80%
  |                                                                       
  |=================================================================| 100%
## [1] "Global K = 4"
## [1] 4

Other useful functions

kkmeans is the analogous of lmkkmeans, for just one dataset at a time.

## [1] 0.8342068

We also included copheneticCorrelation, a function that calculates the cophenetic correlation coefficient of a similarity matrix:

## [1] 0.8696044 0.8746146 0.9372749

The cophenetic correlation coefficient is a measure of how faithfully hierarchical clustering would preserve the pairwise distances between the original data points.

There is also a function that can be used to plot similarity matrices, ordered by cluster label, and with an additional side label for each row and to save the output in different formats. It is called plotSimilarityMatrix.

References

Cabassi, A. and Kirk, P. D. W. (2019). Multiple kernel learning for integrative consensus clustering of genomic datasets. arXiv preprint. arXiv:1904.07701.

Girolami, M. (2002). Mercer kernel-based clustering in feature space. IEEE Transactions on Neural Networks, 13(3), pp.780-784.

Gonen, M. and Margolin, A. A. (2014). Localized Data Fusion for Kernel k-Means Clustering with Application to Cancer Biology. NIPS, (i), 1–9.

Monti, S. et al. (2003). Consensus Clustering: A Resampling-Based Method for Class Discovery and Visualization of Gene. Machine Learning, 52(i), 91–118.

The Cancer Genome Atlas (2012). Comprehensive molecular portraits of human breast tumours. Nature, 487(7407), 61–70.