# Two-way clustering in R

I'm wondering how to implement two-way clustering, as explained in Statistica documentation in R. Any help in this regard will be highly appreciated. Thanks

Generally speaking, you should always find useful pointers by looking at the relevant CRAN TAsk Views, in this case the one that deals with Cluster packages, or maybe Quick-R.

It's not clear to me whether the link you gave referenced standard clustering techniques for $n$ (individuals) by $k$ (variables) matrix of measures where we impose constraints on the resulting heatmap displays, or two-mode clustering or biclustering.

In the first approach, we could, for example,

1. compute a measure of (dis)similarity between individuals, or correlation between variables, and show the resulting $n\times n$ or $k\times k$ matrix where rows and columns are rearranged by some kind of partitioning or ordering technique -- this help highlighting possible substructures in the association matrix, and you will find more information in this related question;
2. compute the correlation between two blocks of data observed on the same individuals, and reorder the pattern of correlations following an external ordination technique (e.g., hierarchical clustering) -- it amounts to show a heatmap of the observed statistics reordered by rows and columns.

As proposed in an earlier response, the latter is readily available in the cim() function from the mixOmics package. From the on-line help, we can end up with something like that:

Please, note that this is just a two-step process to conveniently display summary measures of association: clustering of rows (individuals or variables) and columns (individuals or variables) is done separately.

In the second approach (biclustering), that I'm inclined to favour, I only know one R package, biclust, that is greatly inspired for research in bioinformatics. Some pointers were also given in an earlier thread. (But there's even some papers in the psychometrics literature.) In this case, we need to put some constraints during clustering because we want to cluster both individuals and variables at the same time.

Again, you can display the resulting structure as heatmaps (see help(heatmapBC)), as shown below

• Thanks chl for thorough explanation. I was aware of biclust but mixOmics is new to me. I tried both R packages. As mixOmics do clustering for rows and rows independently so I guess it is not as technical as biclust. I'm wondering if is it possible to get the two-sided dendrograms in biclust as in mixOmics with cim() function. Thanks again for nice answer. – MYaseen208 Apr 2 '11 at 16:55
• @MYaseen208 Sure, look here: stats.stackexchange.com/questions/6890/…. You'll need to get the raw result from biclust and then plug it into a lattice heatmap with added dendrograms. – chl Apr 30 '11 at 8:25