Question: RNAseq TPM heatmap
gravatar for tanyabioinfo
19 months ago by
tanyabioinfo0 wrote:


I have a count matrix (TPM) for my samples. My samples are as follows :

wt0hr wt6hr wt24hr kd0hr kd6hr kd24hr

I have a TPM matrix with geneids as rows and the columns as the 6 samples above. I am using follwoing R code to generate the heatmap: cols <- c("","wt0","wt6","wt24","kd0", "kd6","kd24") dat <- read.csv("TPM.csv", row.names = 1,stringsAsFactors = FALSE, col.names = cols, header = TRUE)

counts_filtered_df <- dat[apply(dat, MARGIN = 1, FUN = function(x) sd(x) != 0),]

z.mat <- t(scale(t(counts_filtered_df), scale=TRUE, center=TRUE))

heatmap.2(z.mat, dendrogram="both", scale="none", trace="none")

Can anyone suggest me if this is the correct way to generate the heatmaps from TPM .


rna-seq heatmap2 • 1.7k views
ADD COMMENTlink modified 19 months ago by Kevin Blighe42k • written 19 months ago by tanyabioinfo0

what makes you think that this was not the correct way?

You don't really need to scale the matrix manually as heatmap.2 can do that for you (by choosing a different value than scale = "none") and my personal preference is to look at the unscaled values, too.

ADD REPLYlink written 19 months ago by Friederike4.2k
gravatar for Kevin Blighe
19 months ago by
Kevin Blighe42k
Republic of Ireland
Kevin Blighe42k wrote:

If you are going to scale manually outside of the heatmap.2 function, be sure to also set your own breaks:

myCol <- colorRampPalette(c("dodgerblue", "black", "yellow"))(100)
myBreaks <- seq(-3, 3, length.out=101)


heat.scaled <- t(scale(t(heat)))

heatmap.2(heat.scaled, col=myCol, breaks=myBreaks, scale="none", ...)

However, as Friederike says, heatmap.2 will automatically scale your data with scale="row", thus de-necessitating the manual scaling to Z-scores as you have done with z.mat <- t(scale(t(counts_filtered_df), scale=TRUE, center=TRUE))

At the end of the day, your statistical tests will have been performed on the unscaled TPM data, and thus the scaling to Z-scores (or logging or something else) is purely for visualisation purposes.

ADD COMMENTlink modified 19 months ago • written 19 months ago by Kevin Blighe42k
Please log in to add an answer.


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