2016-03-01 105 views
0

我正在设计细胞周期时间序列中调控最强的基因的热图。按时间序列排列的时间序列在列中出现峰值时

example <- read.csv("example.csv", header = T) 

example.m <- melt(example) 

(e <- ggplot(example.m, aes(variable, Gene_ID)) + geom_tile(aes(fill = 
value), colour = "white") + scale_fill_gradient(low = "white", high = 
"steelblue")) 

而结果是这样的,

example heat map

我的价值观是对数变换,我想知道是否有一种方法可以为了我的行,以便他们组一起在那里高峰时间序列(即,在0处具有其最高表达的所有基因被组合在一起,具有在30处最高表达的基因被编组在一起,等等。)
我试图完成这个像这样

order <- arrange(example, X0, X30, X60, X90, X120, X150, X180, X210, X240) 

然后经过了用有序数据框绘制热图的过程,但没有改变。
感谢您提供任何帮助或建议。我非常感谢你的时间。

回答

0

你应该能够加入这一行设定的Y轴的顺序example.m$Gene_ID <- factor(example.m$Gene_ID, levels = order$Gene_ID, labels = order$Gene_ID)

下面是完整的代码示例数据:

example <- data.frame(Gene_ID = paste0("TTHERM_", 1:9), 
         X0 = round(runif(9, min =0, max = 4.4999),0), 
         X30 = round(runif(9, min =0, max = 4.4999),0), 
         X60 = round(runif(9, min =0, max = 4.4999),0), 
         X90 = round(runif(9, min =0, max = 4.4999),0), 
         X120 = round(runif(9, min =0, max = 4.4999),0), 
         X150 = round(runif(9, min =0, max = 4.4999),0), 
         X180 = round(runif(9, min =0, max = 4.4999),0), 
         X210 = round(runif(9, min =0, max = 4.4999),0), 
         X240 = round(runif(9, min =0, max = 4.4999),0)) 

library(dplyr) 
library(reshape2) 
library(ggplot2) 
example.m <- melt(example) 

# This is your original plot 
(e <- ggplot(example.m, aes(variable, Gene_ID)) + geom_tile(aes(fill = 
                    value), colour = "white") + scale_fill_gradient(low = "white", high = 
                                "steelblue")) 
# Your order command gives us the right order 
order <- arrange(example, X0, X30, X60, X90, X120, X150, X180, X210, X240) 

# This changes the order of the Y axis based on the sort order 
example.m$Gene_ID <- factor(example.m$Gene_ID, levels = order$Gene_ID, labels = order$Gene_ID) 

# This is the new plot 
(e <- ggplot(example.m, aes(variable, Gene_ID)) + geom_tile(aes(fill = 
                    value), colour = "white") + scale_fill_gradient(low = "white", high = 
                                "steelblue")) 

原创情节:

enter image description here

新地块:

enter image description here

这是你想要的吗?

+0

关闭,我希望能在他们偷看的地方点餐。如果表达式在0时最高,则它将与其他在0处具有最高表达式的其他人组合在一起,依此类推。我不相信我的安排功能能够完成这个任何建议? – Lindsley

+0

你把所有那些最高的零组合在一起,所以我不太明白你想要什么。你不能将最高为零的那些分组在一起,并且同时将最高为30的那些分组在一起。 – Mist