Question: How to make a heatmap like this in R
0
gravatar for ishackm
16 months ago by
ishackm100
ishackm100 wrote:

Hi all,

I would like some help modifying a heatmap please.

Right now I have this heatmap:

enter image description here

The code to produce this heatmap:

datafinal = scale(data)

require(pheatmap)

out <- pheatmap(datafinal, 
                show_rownames=F, color = c("#2c7fb8", "#fee6ce", "#e6550d"),breaks = c(-4,0,2,4),main = "Malignant vs Fibroblast Samples",fontsize = 7, cluster_cols=T, cluster_rows=T, scale="row",cex=1,  clustering_distance_rows="maximum", cex=1, clustering_distance_cols="euclidean", clustering_method="complete", border_color=FALSE, annotation_col=metadata, xlim=c(-7.7,7))

I would like to heatmap that looks like this please:

enter image description here

I would like the Z scale and have the little square blocks instead of the big blocks of solid colours I currently have. I also do not want the row names displayed.

I find heatmaps very hard to make so any help would be greatly appreciated.

Many Thanks,

Ishack

heatmap rna-seq • 2.0k views
ADD COMMENTlink written 16 months ago by ishackm100
1
gravatar for SMK
16 months ago by
SMK1.9k
SMK1.9k wrote:

One way is to use gplots::heatmap.2:

library(gplots)
data(mtcars)
x <- as.matrix(mtcars)

heatmap.2(
  x,
  col = bluered,
  labCol = "",
  labRow = "",
  scale = "column",
  dendrogram = "none",
  trace = "none",
  key.title = "",
  lmat = rbind(c(0, 3, 4), c(2, 1, 0)),
  lhei = c(1, 3),
  lwid = c(0.5, 7, 3)
)

The one without row names:

heatmap_by_gplot

ADD COMMENTlink modified 16 months ago • written 16 months ago by SMK1.9k

Thank you but how do I label the samples into two categories, fibroblast and malignant and also do the clustering for both rows and columns please?

ADD REPLYlink modified 16 months ago • written 16 months ago by ishackm100
1

Read the docs and/or some tutorials.

ADD REPLYlink written 16 months ago by Jean-Karim Heriche23k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1943 users visited in the last hour