你应该能够加入这一行设定的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"))
原创情节:
新地块:
这是你想要的吗?
关闭,我希望能在他们偷看的地方点餐。如果表达式在0时最高,则它将与其他在0处具有最高表达式的其他人组合在一起,依此类推。我不相信我的安排功能能够完成这个任何建议? – Lindsley
你把所有那些最高的零组合在一起,所以我不太明白你想要什么。你不能将最高为零的那些分组在一起,并且同时将最高为30的那些分组在一起。 – Mist