# [R] 2D cluster of 2D matrix in R?

Huntsinger, Reid reid_huntsinger at merck.com
Fri Apr 19 23:32:57 CEST 2002

```The "image" function displays a matrix as an image. You have full control
over the color map. You might also want to look at the "pixmap" package. R
certainly also has packages available to do clustering of many kinds
(mclust, mva, e1071, multiv, cluster, cclust, ...?) but I'm afraid I don't
quite understand what your procedure is. Perhaps you could elaborate a
little? It sounds like you do hierarchical clustering of some type twice,
once for rows and again for columns. The fact that your example has the
column labels permuted also suggests this to me. ???

Reid Huntsinger

-----Original Message-----
From: Mark Wall [mailto:wall at chop.swmed.edu]
Sent: Friday, April 19, 2002 4:26 PM
To: r-help at stat.math.ethz.ch
Subject: [R] 2D cluster of 2D matrix in R?

Hello!

I would love to use R for the following 2 tasks, but am unable to
determine if R is well suited for this.  My primary question- is this
possible in R?  Secondary- if yes, how?

We routinely use MatLab with the Statistics Tool Box to manipulate
and plot a 2 dimensional matrix (m x n) of real numbers.  If you
think of each dimension as an array of vectors (e.g. a collection of
m vectors (each n-dimensions), we 1) cluster these (and generate a
dendrogram) for both dimensions as below using a city-block distance
measure:

original matrix with labels
----------------
W X Y Z
A  0 1 0 0
B  0 1 0 1
C  5 0 0 0
D  0 0 0 2
E  5 0 0 0

Clustered matrix
----------------
W Y X Z
E  5 0 0 0
C  5 0 0 0
A  0 0 1 0
B  0 0 1 1
D  0 0 0 2

In reality, m and n are between 50 and 1000 so we 2) display these
matrices as an x-y-color plot for easy visualization.  Think of this
as a square frame with each pixel representing a matrix element.  The
values are represented by a continuous color scale (dark blue = low
values, through yellow to red = high values).  I can provide a JPEG
if necessary.

With large matrices, we isolate sub-clusters by creating new matrices
that are the appropriate slices of the original matrix and then
repeat steps 1 and 2 for each sub-cluster.

Thank you,

Mark Wall
---------
HHMI/UT Southwestern Medical Center
5323 Harry Hines Blvd.
Dallas, Texas  75390-9050
USA
214.648.5050
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._

------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, contains information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, proprietary copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named on this message.  If you are not the intended recipient, and have received this message in error, please immediately return this by e-mail and then delete it.

==============================================================================

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```