Why can't I reproduce the same heat map
0
0
Entering edit mode
6.4 years ago
Za ▴ 140

Hi,

Long time I am trying to produce figure 1A in this link but I always plot something weird like this

In paper says they just used 8000 genes and clustered those with spearman

I am using Kevin's code

require("RColorBrewer")
myCol <- colorRampPalette(c("dodgerblue", "black", "yellow"))(100)
myBreaks <- seq(-2, 2, length.out=101)
heat <- t(scale(t(sc_DEGG)))
hr <- hclust(as.dist(1-cor(t(y), method="pearson")), method="complete")


hc <- hclust(as.dist(1-cor(y, method="spearman")), method="complete")

require("gplots")

heatmap.2(heat, Rowv=as.dendrogram(hr), Colv=as.dendrogram(hc), col=myCol, breaks=myBreaks, main="Title", key=T, keysize=1.0, scale="none", density.info="none", reorderfun=function(d,w) reorder(d, w, agglo.FUN=mean), trace="none", cexRow=0.2, cexCol=0.8, distfun=function(x) dist(x, method="euclidean"), hclustfun=function(x) hclust(x, method="ward.D2"))

This is link of my raw counts and normalised data

I don't have any idea where I am not right that I plot something nonsense with right data

any help please?

ggplots R RNA-Seq • 3.1k views
ADD COMMENT
1
Entering edit mode

Your normalised data looks sparse, with many transcript values of zero / nil. Did you do any pre-filtering for low count transcripts? I note that it's single cell data, so, low counts are expected. You can either impute these or just filter them out.

ADD REPLY
1
Entering edit mode

Wait, what's "weird" about your heatmap? You are not showing the entire figure (?)

ADD REPLY
0
Entering edit mode

Thank you, it is bulk RNA-seq ,I filtered genes with low read counts and normalised that with deseq2 but the plot looks different

ADD REPLY
1
Entering edit mode

unless you've used exactly the same protocol as in the paper, the plot will be different. Unless the clusters are really well defined, heatmaps can be pretty flaky: adding a bit of noise to each entry will give you a different clustering.

ADD REPLY
0
Entering edit mode

sorry, you know what I should add to the code so that genes in rows can be read? I know the list of genes but after clustering I should know the order of genes

ADD REPLY
1
Entering edit mode

You still haven't defined what it is about the plot that you have generated that you want to fix so that it looks more like the plot in the paper. You have the same time trend but different data.

If it were me, I'd drop the hierarchical stuff and order the genes by the time at which they display maximum z-score (which seems to be what they've done in the paper)

ADD REPLY
0
Entering edit mode

Thank you, this is a different task I should do today, I know the order of genes but they are not visible in rows and I am trying to have a clear gene names in rows rather by manually putting the genes in rows. About your your nice suggestion, if I convert my matrix to z-score, I should figure out how to plot a heat map by ordered z-scores in each time point. Actually my plot should look the plot in the paper data is the same but it is not similar

ADD REPLY
0
Entering edit mode

sorry, I have faced a big confusion, if possible help me please

I have link to r object of the matrix here. I have 0 time point from two very similar experiments. when I am plotting correlation, correlation says that these samples are highly correlated but when I am plot a heat map of them (genes in both heat map are in the same order), heat map says that genes up regulating in one experiment are being down regulated in corresponding experiment. How does it possible ? Please help me to see what is my wrong

library(ComplexHeatmap)
library(circlize)
mycol <- colorRamp2(c(-2,0,2), c("dodgerblue", "black", "yellow"))
> heat <- t(scale(t(norm_h0_t_r)))
> heat <- heat[apply(heat, MARGIN = 1, FUN = function(x) sd(x) != 0),]
> View(heat)
> t=heat[,1:2]
> r=heat[,3:4]
> dim(t)
[1] 8587    2
> dim(r)
[1] 8587    2
> Heatmap(t, col=mycol, cluster_columns = FALSE) + Heatmap(r, col=mycol, cluster_columns = FALSE)
ADD REPLY
0
Entering edit mode

You appear to want it to be exactly as per the figure in the publication, right? Is that because your colleagues asked you to do that? Just be wary of manipulating the data 'too much' just for the purpose of making it resemble more closely the published figure.

I would recommend switching to average linkage, not Ward.D2, and possibly setting the re-order function to max() (not mean().)

Did you try this:

require("RColorBrewer")
myCol <- colorRampPalette(c("dodgerblue", "black", "yellow"))(100)
myBreaks <- seq(-2, 2, length.out=101)
heat <- t(scale(t(sc_DEGG)))
hr <- hclust(as.dist(1-cor(t(y), method="pearson")), method="average")
hc <- hclust(as.dist(1-cor(y, method="spearman")), method="average")

require("gplots")

heatmap.2(heat, Rowv=as.dendrogram(hr), Colv=as.dendrogram(hc), col=myCol, breaks=myBreaks, main="Title", key=T, keysize=1.0, scale="none", density.info="none", reorderfun=function(d,w) reorder(d, w, agglo.FUN=max), trace="none", cexRow=0.2, cexCol=0.8)
ADD REPLY
0
Entering edit mode

Excuse me and thanks a lot for being very helpful. But my question here is not why my figure does not look as the figure in publication. Here question is: I have two heatmaps with same order of genes produced by ComplexHeatmap package. As you are considering the yellow color in right heatmap is lighter than the left on. I don't know how ComplexHeatmap draws these and which is being ordered based on the clustering of another, I just don't know how to make the color more similar. Actually both heatmaps are my data and here Heatmap in publication does not matter.

ADD REPLY
0
Entering edit mode

What we're facing here is the limitation of using an online forum where there exists a major barrier to communication.

You're now referring to the 2 heatmaps that you posted here: C: How to cluster genes in heatmap

The reason why the shading is different is simple: you are plotting different samples in the 2 heatmaps. In the heatmap at left, the samples have higher levels of expression of certain genes; hence, the brighter yellow colour. The samples in the heatmap at right, however, have less expression in these same genes that are highly expressed in the samples in the left heatmap.

ADD REPLY
1
Entering edit mode

To follow from what I said above: if you wanted to 'equalise' the colour shading in those 2 heatmaps, then you would be misleading those who view the heatmaps.

You Z-normalised all samples together and then generated 2 heatmaps from the same Z-normalised data.

ADD REPLY
0
Entering edit mode

Sorry Kevin, do you know what happened? this sort of heat maps gives me opposite blocks of genes expression even for replications inside the same sample what is totally unexpected. Do you know a way to order genes for one samples from max to min (z-score) also the same for another samples. So that I have a block of highly expressed genes in one sample lets say as yellow and a block of lighter yellow for another sample. something opposite of what I produced here. I mean genes with higher expression should come in same block even in one sample they are in lighter yellow. Like this picture that is interactive sample

ADD REPLY
1
Entering edit mode

plot looks fine to me

ADD REPLY
0
Entering edit mode

Maybe your R versions are different. That makes a lot of difference at the most unexpected of times.

ADD REPLY

Login before adding your answer.

Traffic: 2152 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6