Saturday, April 6, 2013

Plot#17: heatmap plot with dendograms at margin


# data 
set.seed(1234)
 P <- vector()
DF <- as.data.frame(matrix(rep(NA, 100), nrow=10))
names(DF) <- c(paste("M",1:10, sep=""))
for(i in 1:10) {
                    DF[,i] <- rnorm(10, 10, 3)
                    }
rownames (DF) <- paste("O", 1:10, sep = "")
DFmat <- as.matrix (t(DF))


# plot, installation of the following package needed 
require(graphics); 
require(grDevices)

 rcol <- rainbow(nrow(DFmat), start=0, end=.3)
 ccol <- rainbow(ncol(DFmat), start=0, end=.3)
# using heat.colors (10)
heatv <- heatmap(DFmat, col = heat.colors(10), scale="column", RowSideColors = rcol, ColSideColors = ccol, margins=c(5,10), xlab = "Observations", ylab= "Variables", main = " Heat map plot of DF data")




# using cm.colors (10)
cmtv <- heatmap(DFmat, col = cm.colors(10), scale="column", RowSideColors = rcol, ColSideColors = ccol, margins=c(5,10), xlab = "Observations", ylab= "Variables", main = " Heat map plot of DF data")

# defining won color, using color brewer  
require(RColorBrewer)
plotclr <- brewer.pal(6,"Greens")

greencol <- heatmap(DFmat, col = plotclr, scale="column", RowSideColors = rcol, ColSideColors = ccol, margins=c(5,10), xlab = "Observations", ylab= "Variables", main = " Heat map plot of DF data")


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.