3

The data below shows a subset of my differential expressed genes in my dataset. These genes are changing alot throughout the time course. What is the best way to dispay these changes in a heatmap? For the moment I used a clustering on time, but that does not make sense, because the order of the time points changes.

data <- scale(t(data))
ord <- hclust( dist(data, method = "euclidean"), method = "ward.D" )$order
ord
pd <- as.data.frame( data )
pd$Time <- sub("_.*", "", rownames(pd))
pd.m <- melt( pd, id.vars = "Time", variable.name = "Gene" )
pd.m$Gene <- factor( pd.m$Gene, levels = colnames(data), labels = seq_along(      colnames(data)))
pd.m$Time <- factor( pd.m$Time, levels = rownames(data)[ord],  labels = c("0h", "0.25h", "0.5h","1h","2h","3h","6h","12h","24h","48h") )
ggplot( pd.m, aes(Time, Gene) ) +
geom_tile(aes(fill = value)) +
scale_fill_gradient2(low=muted("blue"), high=muted("red"))+
theme_bw(base_size=35)


>data


         T0h            T0.25h          T0.5h           T1h             T2h           T3h              T6h            T12h             T24h            T48h
Zfp36   1.4865812288    2.6043878378    4.8689927391    4.1300412283    0.7450087968    0.7713905325    0.8124991048    0.8125375813    0.8485126972    1.1435088656
Zfp280b 0.9944961671    1.0700016622    1.0103583427    1.1964824049    1.7168366859    2.0090685521    3.032261758 3.1992004436    2.8816123816    2.9532484654
Wnt10a  0.9666023491    1.0162380083    0.9614756075    0.9030372853    0.7296350831    0.5100091305    0.3281906511    0.1929538685    0.3161538323    0.4472075971
Tubb6   0.773026973 0.6863716312    1.0567880048    1.2530635772    1.8387545499    1.798876894 1.9228454894    2.1432050761    3.3566166185    4.4095121951
Traf1   0.9176444999    1.021628435 1.0986947079    1.7444983776    3.438084831 3.224964476 3.995648176 2.3820049673    3.9615498278    3.8126049821
Tnnt2   1.0469740386    1.0943645555    1.1985950576    1.1656448198    1.3443223506    1.4115769544    2.5978415439    5.1319084185    9.8189312038    9.457881731
Tnni1   0.9864693701    1.0785384292    1.1476357238    1.0349459833    1.567381317 2.2025710419    3.4358495267    5.103047655 9.985488919 20.0192136587
Tnfrsf4 1.2492930798    1.0162603212    0.9605667001    0.9468147908    1.6461500799    1.594368932 2.0316281031    2.4524863296    9.2491614825    28.3656565537
Tnfaip3 1.2442369707    1.3314047193    3.6147375395    7.7354847705    2.6055600198    1.921362861 1.6675192174    1.6919707466    2.9086955296    1.8126504397
Tmsb15l 1.0437754712    1.5097793496    0.9964473482    0.9451662922    0.9946716693    1.0881863157    2.5481610656    4.578915281 9.6648576979    7.7858353113
Tmsb15b1    1.4689646936    1.0970619838    1.0543473567    0.9996272565    0.7878169695    1.1232652928    1.5810437179    3.5429329874    5.3806633953    4.7922381632
Tgfbr1  1.0575736219    1.0762901809    1.050321571 1.0055099796    1.3902478839    2.1355628325    1.9951348253    2.2676079884    2.3157728453    1.589314888
Tcf7    0.9186328927    1.3113061292    1.1304477795    0.9620289023    1.2755503226    1.6071567601    3.9608176211    7.5981324706    16.8025400932   11.8166138542
Tbc1d4  1.0514882242    1.1565754337    1.0985017304    1.3477676003    1.8445440671    2.3163671771    4.1501027841    7.7829729056    15.9883991423   9.8701882178
Stx7    1.0583686828    1.1959983862    1.0899016216    0.9756041294    1.0718347332    1.2894210564    2.0716932521    2.8584645772    2.9309124833    1.9368737651
Stat5a  0.622421436 1.2521011743    1.0890858469    1.1310147162    3.2359526598    6.261309674 4.7429003302    6.5539420691    4.030914972 3.2573424026
Stat1   1.0515240236    1.061443807 1.0102023121    1.294762475 1.7174431097    1.9247333419    2.5372727928    2.8181673501    4.1226857746    3.9881069864
Snora43 1.0456584952    0.637303406 0.4244687671    0.534207782 1.1080780771    0.4979388136    0.7182666819    0.8479585974    0.527605895 0.4454108518
Snora17 1.3668421991    0.4191899548    1.3344891971    0.7605709565    0.524177884 0.0685795565    0.4258424626    0.9716807859    1.0057806377    0.3370142736
Smim3   1.1147162   1.1074677495    1.0727113328    2.0634746855    2.3686930467    2.6375777601    3.4050944877    3.2762517395    3.117333758 2.1349005833
Slfn2   0.9734016936    0.8843688943    1.2054198469    2.2124164999    3.5752356576    3.166019186 1.8238585775    1.1366382465    1.2227102787    1.2364190381
Slc31a2 1.0410994382    1.0986653942    1.0315848391    1.0187033707    1.9513304164    2.3268717859    3.3292186817    2.9822086017    4.4204752548    5.2098934767
Slc2a6  0.983239298 0.9374693065    1.0584895405    0.8965611911    1.414544752 1.7199248254    3.7959318834    5.0964959369    6.4818150501    3.9822057745
Sik1    0.9325762509    1.1444413482    1.4482955438    2.9840642789    1.9395469378    1.8732216597    1.8568949551    1.3288510767    2.5299688789    1.9844465836
Samsn1  1.1025210084    1.2018873338    1.1709091433    1.4264952662    3.4340577537    3.2225597653    3.4763743131    2.9845601436    3.9763520761    4.3593453909
Rpl35a  1.3612486578    1.3138228005    1.4851049083    1.365775112 1.0658495107    1.1957021314    1.0383633938    1.1635873539    1.2068327983    1.1114226948
Rnf24   1.0481455978    0.9843012465    0.9766833202    2.8101081895    4.3449285295    3.4819045146    2.9533494556    3.2399315529    4.8043257117    4.6027138104
Rnf19b  0.9825699431    1.1572674659    1.6142324793    4.4559780259    6.2028815276    5.2901600077    7.1300136799    9.8172970292    11.2631004948   7.9485767529
Rhof    0.9617198024    0.8346538473    1.082632788 1.5272740126    2.2429413199    2.2529688429    2.0781265694    1.5635142555    1.5837230158    1.8384527521
Rhob    1.0503455128    1.3516933203    1.5627471133    1.6921539751    1.3248423504    1.1680815599    1.1715931918    1.1635789649    1.7950699546    2.0622614847
Rab27a  1.06700291  1.166797397 1.0183202477    1.0608133391    1.070299815 1.1137665866    2.1832486646    2.5072311162    3.3523224479    4.2658624198
Rab21   1.089920477 1.0830468487    1.0365556777    1.1241175934    1.125720552 1.0408736284    1.672449883 1.856593373 2.319063034 2.2512076227

I would like something like this:

enter image description here

user3741035
  • 2,455
  • 4
  • 15
  • 20
  • 1
    Please edit your question to a **specific programming question**. "What is the best way to dispay these changes in a heatmap?" is far too vague and subjective. – Henrik Sep 02 '14 at 08:44
  • How about clustering just the genes, but not the time points? For example: `heatmap(as.matrix(data), Colv=NA)`. Or with a color gradient from red to blue: `library(RColorBrewer); heatmap(as.matrix(data), Colv=NA, col=colorRampPalette(brewer.pal(11, "RdBu"))(50))`. –  Sep 02 '14 at 12:11
  • 1
    @JTT we had this question already forth and back: http://stackoverflow.com/questions/25528059/cluster-data-in-heat-map-in-r-ggplot – Beasterfield Sep 02 '14 at 14:21

0 Answers0