[R-gregmisc-commits] r2103 - pkg/gplots/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Mar 25 18:11:26 CET 2016
Author: warnes
Date: 2016-03-25 18:11:26 +0100 (Fri, 25 Mar 2016)
New Revision: 2103
Modified:
pkg/gplots/R/heatmap.2.R
Log:
Fix error when Rowv=FALSE or Colv=FALSE
Modified: pkg/gplots/R/heatmap.2.R
===================================================================
--- pkg/gplots/R/heatmap.2.R 2016-03-25 16:39:34 UTC (rev 2102)
+++ pkg/gplots/R/heatmap.2.R 2016-03-25 17:11:26 UTC (rev 2103)
@@ -142,7 +142,7 @@
## Check if Rowv and dendrogram arguments are consistent
if (
(
- ( is.logical(Rowv) && !isTRUE(Rowv) )
+ ( is.logical(Rowv) && !isTRUE(Rowv) )
||
( is.null(Rowv) )
)
@@ -150,14 +150,14 @@
( dendrogram %in% c("both","row") )
)
{
- if (is.logical(Colv) && (Colv))
+ warning("Discrepancy: Rowv is FALSE, while dendrogram is `",
+ dendrogram, "'. Omitting row dendogram.")
+
+ if (dendrogram=="both")
dendrogram <- "column"
else
dendrogram <- "none"
- warning("Discrepancy: Rowv is FALSE, while dendrogram is `",
- dendrogram, "'. Omitting row dendogram.")
-
}
}
@@ -172,13 +172,14 @@
&&
( dendrogram %in% c("both","column")) )
{
- if (is.logical(Rowv) && (Rowv))
+ warning("Discrepancy: Colv is FALSE, while dendrogram is `",
+ dendrogram, "'. Omitting column dendogram.")
+
+ if (dendrogram=="both")
dendrogram <- "row"
else
dendrogram <- "none"
- warning("Discrepancy: Colv is FALSE, while dendrogram is `",
- dendrogram, "'. Omitting column dendogram.")
}
}
@@ -223,13 +224,18 @@
rowInd <- order.dendrogram(ddr)
if(nr != length(rowInd))
stop("row dendrogram ordering gave index of wrong length")
- } else {
+ }
+ else if(!isTRUE(Rowv))
+ {
rowInd <- nr:1
+ ddr <- as.dendrogram(hclust(dist(diag(nr))))
+ }
+ else
+ {
+ rowInd <- nr:1
ddr <- as.dendrogram(Rowv)
}
- ## if( dendrogram %in% c("both","column") )
- ## {
if(inherits(Colv, "dendrogram"))
{
ddc <- Colv ## use Colv 'as-is', when it is dendrogram
@@ -271,6 +277,11 @@
if(nc != length(colInd))
stop("column dendrogram ordering gave index of wrong length")
}
+ else if(!isTRUE(Colv))
+ {
+ colInd <- 1:nc
+ ddc <- as.dendrogram(hclust(dist(diag(nc))))
+ }
else
{
colInd <- 1:nc
More information about the R-gregmisc-commits
mailing list