Showing posts with label heatmap. Show all posts
Showing posts with label heatmap. Show all posts

Wednesday, August 25, 2021

R heatmap references

 

https://jokergoo.github.io/ComplexHeatmap-reference/book/index.html 

https://jokergoo.github.io/ComplexHeatmap-reference/book/a-single-heatmap.html#colors



Thursday, March 11, 2021

R plot grid, heatmapply

 


library(heatmaply)
library(orca)
library(RColorBrewer)
library(colorspace)

n = 256
data = c(rep(1, n/4), rep(2, n/4), rep(3, n/4), rep(4, n/4))
dim(data) = c( 16, 16)
data = t(data)

heatmaply(as.matrix(data), file = "test.png", grid_gap=1, grid_color = "black",
           dendrogram = "none", showticklabels = c(FALSE, FALSE), 
           hide_colorbar = TRUE, width=300, height=350, 
#           colors= colorRampPalette(brewer.pal(3, "RdBu"))(256) 
      colors = rainbow_hcl(4)
)





data = c(rep(1, n/4), rep(2, n/4), rep(3, n/4), rep(4, n/4))

data = c(rep(1, 256) , rep(2,16*5))
data = matrix( data, nrow=16, ncol=21)
data = t(data)
 heatmaply(as.matrix(data), file = "test.png", grid_gap=1, grid_color = "black",
           dendrogram = "none", showticklabels = c(FALSE, FALSE), 
           hide_colorbar = TRUE, 
    #    colors= colorRampPalette(brewer.pal(3, "RdBu"))(256) 
      colors = c("lightyellow", "lightgoldenrod3")
)






Saturday, February 9, 2013

Customerize a heatmap with clustering panel in R

pdf("_20130209.average.hclust.2.coat.pdf", height=5, width=5);
 mymethod = "average";
 hd =  hclust( dist(ctb2), mymethod);
 coat.cat = cutree(hd, numclus )
 #col.palette = c("red","brown","blue","green");
 col.palette = c("blue","red"); #2013 Feb 9 change
 coat.color = col.palette[coat.cat]

 hcol =  hclust(dist( t(ctb2)), method=mymethod )
 #hcol =  as.dendrogram( hclust(dist( t(ctb2)), method=mymethod ) )

 #library(RColorBrewer);
 #hmcol = colorRampPalette(brewer.pal(5,"RdBu"))(16);

 #using the default heatmap function
 heatmap( ctb2, col=c("red","blue"), scale="none", margins = c(5,22),
 #Colv = NA,  ## no dedrogram
 #Colv = FALSE, ## use the input column order, 
 #Colv = as.dendrogram( hclust(dist( t(ctb2)), method=mymethod ) ),
 RowSideColors=coat.color, # ColSideColors = spec.colors, #20130209
 hclustfun = function(c) hclust( c, method=mymethod),
 cexRow=0.4, cexCol=0.6 );

dev.off();