checkBoard <- function(seed=1887) {
set.seed(seed)
mat <- matrix(rnorm(76, sd=1), ncol=4)
delta <- 3
for(i in seq(1, 16, 2)) {
rowInd <- i:(i+1)
colInd <- (i %/% 2) %% 4 +1
delta <- ifelse(i>8, -6, 6) * c(0.6, 1)
mat[rowInd, colInd] <- mat[rowInd, colInd] + delta
}
mat[17,1:4] <- rep(-1, 4)
mat[18,1] <- NA
mat[18,2] <- mat[18, 2] -6
mat[19,1:4] <- rep(NA,4)
rord <- sample(1:nrow(mat), replace=FALSE)
mat <- mat[rord,]
rownames(mat) <- sprintf("Row%d", 1:nrow(mat))
return(mat)
}
myMat <- checkBoard(1887)
biosHeatmap(myMat, Rowv=FALSE, Colv=FALSE, dendrogram="none",
zlim=c(-4,4), col="royalbluered",
main="Original matrix")
## since dist by default does not accept rows full of NAs, we remove them in the example below
biosHeatmap(myMat[apply(myMat, 1, function(x) !all(is.na(x))),],
Rowv=TRUE, Colv=TRUE, dendrogram="both",
zlim=c(-4,4), col="royalbluered",
main="hclust/dist clustering")
## note that cascadeOrder handles invariant rows and rows full of NA values
biosHeatmap(myMat[cascadeOrder(myMat),], Rowv=FALSE, Colv=FALSE, dendrogram="none",
zlim=c(-4,4), col="royalbluered",
main="Cascade order")
Run the code above in your browser using DataLab