Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
按列中的峰值时间对timeseries热图中的行进行分组_R_Ggplot2 - Fatal编程技术网

按列中的峰值时间对timeseries热图中的行进行分组

按列中的峰值时间对timeseries热图中的行进行分组,r,ggplot2,R,Ggplot2,我正在设计一个细胞周期时间序列中最受高度调控的基因的热图 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", h

我正在设计一个细胞周期时间序列中最受高度调控的基因的热图

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您应该可以添加这一行来设置Y轴的顺序
example.m$Gene\u ID Close,我希望按它们的窥视位置来排序。如果表达式在0处是最高的,它将与在0处有最高表达式的其他表达式一起分组,依此类推。我不相信我的排列函数能做到这一点,有什么建议吗?你正在把所有最高的零分组合在一起,所以我真的不明白你想要什么。您不能将最高值为0的数据分组在一起,也不能同时将最高值为30的数据分组在一起。
order <- arrange(example, X0, X30, X60, X90, X120, X150, X180, X210, X240)
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"))