SCM

SCM Repository

[latticeextra] View of /www/man/dendrogramGrob.html
ViewVC logotype

View of /www/man/dendrogramGrob.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 143 - (download) (as text) (annotate)
Tue May 25 06:54:57 2010 UTC (9 years ago) by felix
File size: 4871 byte(s)
get rid of ".featured_example", just use example number
<html><head><title>R: Create a Grob Representing a Dendrogram</title>


</head><body>

<table width="100%" summary="page for dendrogramGrob {latticeExtra}"><tr><td>dendrogramGrob {latticeExtra}</td><td align="right">R Documentation</td></tr></table>

<h2>Create a Grob Representing a Dendrogram</h2>


<h3>Description</h3>

<p>
</p>
<p>
This function creates a grob (a grid graphics object) that can be
manipulated as such.  In particular, it can be used as a legend in a
lattice display like <code>levelplot</code> to form heatmaps.
</p>
<p>
</p>


<h3>Usage</h3>

<pre>
dendrogramGrob(x, ord = order.dendrogram(x),
               side = c("right", "top"),
               add = list(), size = 5, size.add = 1,
               type = c("rectangle", "triangle"),
               ...)
</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>x</code></td>
<td>
 An object of class <code>"dendrogram"</code>.  See
<code>dendrogram</code> for details </td></tr>
</p>
<p>
<tr valign="top"><td><code>ord</code></td>
<td>
 A vector of integer indices giving the order in which the
terminal leaves are to be plotted.  If this is not the same as
<code>order.dendrogram(x)</code>, then the leaves may not cluster together
and branches of the dendrogram may intersect.  </td></tr>
</p>
<p>
<tr valign="top"><td><code>side</code></td>
<td>
 Intended position of the dendrogram when added in a
heatmap.  Currently allowed positions are <code>"right"</code> and
<code>"top"</code>. </td></tr>
</p>
<p>
<tr valign="top"><td><code>add</code></td>
<td>
 Additional annotation.  Currently, it is only possible to
add one or more rows of rectangles at the base of the dendrogram.
See details below.  </td></tr>
<tr valign="top"><td><code>size</code></td>
<td>
 Total height of the dendrogram in <code>"lines"</code> (see
<code>unit</code>)
</td></tr>
<tr valign="top"><td><code>size.add</code></td>
<td>
 Size of each additional row, also in <code>"lines"</code> </td></tr>
<tr valign="top"><td><code>type</code></td>
<td>
 Whether a child node is joined to its parent  directly
with a straight line (<code>"triangle"</code>) or as a &ldquo;stair&rdquo; with
two lines (<code>"rectangle"</code>)
</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
 Extra arguments.  Currently ignored. </td></tr>
</table>


<h3>Details</h3>

<p>
The <code>add</code> argument can be used for additional annotation at the
base of the dendrogram.  It should be a list with one component for
each row, with names specifying the type of annotation and components
specifying the contents.  Currently, the only supported name is
<code>"rect"</code> (which can be repeated), producing rectangles.  The
components in such a case is a list of graphical parameters, possibly
vectorized, that are passed on to <code>gpar</code>.
</p>


<h3>Value</h3>

<p>
An object of class <code>"grob"</code>
</p>


<h3>Author(s)</h3>

<p> Deepayan Sarkar <a href="mailto:deepayan.sarkar@r-project.org">deepayan.sarkar@r-project.org</a> </p>


<h3>See Also</h3>

<p>
<code>heatmap</code>, <code>levelplot</code>
</p>


<h3>Examples</h3>

<pre>

data(mtcars)
x  &lt;- t(as.matrix(scale(mtcars)))
dd.row &lt;- as.dendrogram(hclust(dist(x)))
row.ord &lt;- order.dendrogram(dd.row)

dd.col &lt;- as.dendrogram(hclust(dist(t(x))))
col.ord &lt;- order.dendrogram(dd.col)

library(lattice)

levelplot(x[row.ord, col.ord],
          aspect = "fill",
          scales = list(x = list(rot = 90)),
          colorkey = list(space = "left"),
          legend =
          list(right =
               list(fun = dendrogramGrob,
                    args =
                    list(x = dd.col, ord = col.ord,
                         side = "right",
                         size = 10)),
               top =
               list(fun = dendrogramGrob,
                    args =
                    list(x = dd.row, 
                         side = "top",
                         type = "triangle"))))

levelplot(x[, col.ord],
          aspect = "iso",
          scales = list(x = list(rot = 90)),
          colorkey = FALSE,
          legend =
          list(right =
               list(fun = dendrogramGrob,
                    args =
                    list(x = dd.col, ord = col.ord,
                         side = "right",
                         size = 10)),
               top =
               list(fun = dendrogramGrob,
                    args =
                    list(x = dd.row, ord = sort(row.ord),
                         side = "top", size = 10,
                         type = "triangle"))))

</pre>

<div align="center">[Package <em>latticeExtra</em> version 0.6-12 <a href="00Index.html">Index</a>]</div>
</body></html>

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge