[R] One question on heatmap
Peter Langfelder
peter.langfelder at gmail.com
Tue Nov 2 18:59:44 CET 2010
Before plotting a heatmap we usually standardize all genes to mean
zero and variance 1. That way the green/red represent under/over
expression with respect to the mean expression, which is roughly what
the original 2-color arrays (that literally produced such heatmaps)
were measuring. Of course, standardization assumes you have more than
2 samples.
If your expression matrix is stored in the variable expr, with columns
corresponding to samples and rows to genes, you can obtain a
standardized expression matrix as
stdExpr = t(scale(t(expr)))
Peter
On Tue, Nov 2, 2010 at 8:50 AM, Hua <kaixinsjtu at gmail.com> wrote:
> Dear R-helper:
>
> Suppose we have a matrix:
>
> Gene sample1 sample2
>
> Gcnt1 12.0000 52.80000
> Max 8.8000 39.10000
> Tmem176b 67.9000 304.70000
> Shmt2 8.6000 42.40000
> Rtn4 11.5000 57.70000
> Il17re 7.6000 38.80000
> Bclp2 6.2000 32.10000
> Mobkl3 4.4000 32.20000
> Akr1b10 3.4000 30.10000
> Atp6ap2 5.4000 48.20000
> Snx2 5.7000 63.10000
> Tmem176a 7.6000 91.40000
> Klhl9 1.7000 30.30000
> Fbxo27 1.0000 28.90000
> Scd1 34.6000 0.70000
> Tspan9 35.8000 4.20000
> 2210016L21Rik 39.1000 4.90000
> Ctnnb1 212.1000 33.10000
> Apoe 397.2000 74.20000
> H2-DMb1 72.3000 14.10000
> Ryk 31.7000 6.40000
> Dapk2 85.4000 17.30000
> Gzmm 179.4000 36.80000
> Actb 12993.4000 2678.10000
> Faim3 758.0000 157.60000
> Aktip 209.4000 46.00000
> Tbrg1 93.3000 21.30000
>
> When I try to make heatmap based on this gene expression value table, I found that, when I set 'scale' to 'column', the heatmap will be always be red. I think this is because, there's very large values in the matrix (gene Actb), while the most are just very small. Thus, the color will be very ugly. I just wonder, how to set the color to make the heatmap look better? I have tried log-tranformation on the matrix and it's better now. But I do want to know if you have better ways to set the color span manually and make the heatmap look better without any log-transformation?
>
> Thanks in advance!
>
> Best, Hua
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list