[R-gregmisc-users] SF.net SVN: r-gregmisc: [1252] trunk/gplots
Brought to you by:
warnes
|
From: <wa...@us...> - 2008-04-07 16:47:38
|
Revision: 1252
http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1252&view=rev
Author: warnes
Date: 2008-04-07 09:47:30 -0700 (Mon, 07 Apr 2008)
Log Message:
-----------
Add ability to control location of individual heatmap.2 components
Modified Paths:
--------------
trunk/gplots/R/heatmap.2.R
trunk/gplots/man/heatmap.2.Rd
Modified: trunk/gplots/R/heatmap.2.R
===================================================================
--- trunk/gplots/R/heatmap.2.R 2008-03-27 22:36:13 UTC (rev 1251)
+++ trunk/gplots/R/heatmap.2.R 2008-04-07 16:47:30 UTC (rev 1252)
@@ -62,6 +62,11 @@
xlab = NULL,
ylab = NULL,
+ # plot layout
+ lmat = NULL,
+ lhei = NULL,
+ lwid = NULL,
+
# extras
...
)
@@ -270,23 +275,45 @@
x[] <- ifelse(x<min.breaks, min.breaks, x)
x[] <- ifelse(x>max.breaks, max.breaks, x)
+
+
+
+
+
## Calculate the plot layout
- lmat <- rbind(4:3, 2:1)
- lhei <- lwid <- c(keysize, 4)
- if(!missing(ColSideColors)) { ## add middle row to layout
- if(!is.character(ColSideColors) || length(ColSideColors) != nc)
- stop("'ColSideColors' must be a character vector of length ncol(x)")
- lmat <- rbind(lmat[1,]+1, c(NA,1), lmat[2,]+1)
- lhei <- c(lhei[1], 0.2, lhei[2])
- }
- if(!missing(RowSideColors)) { ## add middle column to layout
- if(!is.character(RowSideColors) || length(RowSideColors) != nr)
- stop("'RowSideColors' must be a character vector of length nrow(x)")
- lmat <- cbind(lmat[,1]+1, c(rep(NA, nrow(lmat)-1), 1), lmat[,2]+1)
- lwid <- c(lwid[1], 0.2, lwid[2])
- }
- lmat[is.na(lmat)] <- 0
+ if( missing(lhei) || is.null(lhei) )
+ lhei <- c(keysize, 4)
+ if( missing(lwid) || is.null(lwid) )
+ lwid <- c(keysize, 4)
+
+ if( missing(lmat) || is.null(lmat) )
+ {
+ lmat <- rbind(4:3, 2:1)
+
+ if(!missing(ColSideColors)) { ## add middle row to layout
+ if(!is.character(ColSideColors) || length(ColSideColors) != nc)
+ stop("'ColSideColors' must be a character vector of length ncol(x)")
+ lmat <- rbind(lmat[1,]+1, c(NA,1), lmat[2,]+1)
+ lhei <- c(lhei[1], 0.2, lhei[2])
+ }
+
+ if(!missing(RowSideColors)) { ## add middle column to layout
+ if(!is.character(RowSideColors) || length(RowSideColors) != nr)
+ stop("'RowSideColors' must be a character vector of length nrow(x)")
+ lmat <- cbind(lmat[,1]+1, c(rep(NA, nrow(lmat)-1), 1), lmat[,2]+1)
+ lwid <- c(lwid[1], 0.2, lwid[2])
+ }
+
+ lmat[is.na(lmat)] <- 0
+ }
+
+ if(length(lhei) != nrow(lmat))
+ stop("lhei must have length = nrow(lmat) = ", nrow(lmat))
+
+ if(length(lwid) != ncol(lmat))
+ stop("lwid must have length = ncol(lmat) =", ncol(lmat))
+
## Graphics `output' -----------------------
op <- par(no.readonly = TRUE)
Modified: trunk/gplots/man/heatmap.2.Rd
===================================================================
--- trunk/gplots/man/heatmap.2.Rd 2008-03-27 22:36:13 UTC (rev 1251)
+++ trunk/gplots/man/heatmap.2.Rd 2008-04-07 16:47:30 UTC (rev 1252)
@@ -71,6 +71,11 @@
xlab = NULL,
ylab = NULL,
+ # plot layout
+ lmat = NULL,
+ lhei = NULL,
+ lwid = NULL,
+
# extras
...
)
@@ -180,6 +185,9 @@
0.25.}
% plot labels
\item{main, xlab, ylab}{main, x- and y-axis titles; defaults to none.}
+ % figure layout
+ \item{lmat, lhei, lwid}{visual layout: position matrix, column height,
+ column width. See below for details}
\item{...}{additional arguments passed on to \code{\link{image}} } %
}
\details{
@@ -209,7 +217,18 @@
as the \pkg{RColorBrewer} package,
\url{http://cran.r-project.org/src/contrib/PACKAGES.html#RColorBrewer}
to select better colors.
-
+
+ By default four components will be displayed in the plot. At the top
+ left is the color key, top right is the column dendogram, bottom left
+ is the row dendogram, bottom right is the image plot. When
+ RowSideColor or ColSideColor are provided, an additional row or column
+ is inserted in the appropriate location. This layout can be
+ overriden by specifiying appropriate values for \code{lmat},
+ \code{lwid}, and \code{lhei}. \code{lmat} controls the relative
+ postition of each element, while \code{lwid} controls the column
+ width, and \code{lhei} controls the row height. See the help page for
+ \code{\link[graphics]{layout}} for details on how to use these
+ arguments.
}
\note{
The original rows and columns are reordered \emph{in any case} to
@@ -276,7 +295,12 @@
# without reorder
heatmap.2(Ca, Rowv=FALSE, symm=TRUE, margin=c(6, 6), trace="none" )
+ ## Place the color key below the image plot
+ heatmap.2(x, lmat=rbind( c(0, 3), c(2,1), c(0,4) ), lhei=c(1.5, 4, 2 ) )
+ ## Place the color key to the top right of the image plot
+ heatmap.2(x, lmat=rbind( c(0, 3, 4), c(2,1,0 ) ), lwid=c(1.5, 4, 2 ) )
+
## For variable clustering, rather use distance based on cor():
data(USJudgeRatings)
symnum( cU <- cor(USJudgeRatings) )
@@ -312,5 +336,6 @@
main="SpikeIn@pm Fold Changes\nrelative to 12.50 sample",
xlab="Relative Concentration", ylab="Probeset")
}
+
}
\keyword{hplot}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|