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

Mark Wall wall at chop.swmed.edu
Fri Apr 19 22:26:06 CEST 2002

```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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```