在多个直方图中应用 scale_colour_gradient

Apply scale_colour_gradient in multiple histogram

对于一组 8 个基因,我有三种不同方法的性能和覆盖率数据,我想同时表示这两种测量。我正在考虑将 y 轴的性能和覆盖率绘制为 scale_colour_gradient,类似于:

以及数据:

GENES   P1      P2      P3  coverage1   coverage2   coverage3
gene1   0.520   0.43    0.68    0.826   1.000   0.84
gene2   0.410   0.48    0.91    0.911   1.000   0.96
gene3   0.240   0.65    0.82    0.833   1.000   0.95
gene4   0.470   0.535   0.81    0.853   1.000   0.77
gene5   0.590   0.677   0.84    0.813   1.000   0.89
gene6   0.370   0.55    0.54    0.753   1.000   0.82
gene7   0.420   0.56    0.78    0.867   1.000   0.91
gene8   0.550   0.638   0.76    0.830   1.000   0.83

任何人都可以给我一些关于如何做到这一点的指南吗?我见过每个图的单一比例梯度的例子,但找不到这样的。 你知道同时表示这两个维度信息的其他想法吗?

谢谢。

编辑:@Jimbou 我试过类似的东西,但它没有达到我的预期:我使用 melt 格式化数据,然后我更改了 colnames 以避免混淆并绘制它:

colnames(d1) <- c("GENES", "performer", "performances","coverager","coverages")

ggplot(d1,aes(GENES, fill=performer, alpha=coverager)) + geom_bar(aes(weight=performances), position ="dodge")

但这不一样

您可以简单地在 ggplot 函数中指定颜色和 alpha 参数。 使用复制和粘贴读取您的数据。将其转换为适合 ggplot 的数据格式并绘制条形图。

d <- read.table("clipboard",header=T)
library(reshape2)
d1 <- melt(d[,1:4])
d2 <- melt(d[,c(1,5:7)],value.name = "cov")
d1 <- cbind(d1,d2[,-1])
head(d1)
  GENES variable value   var_cov   cov
1 gene1       P1  0.52 coverage1 0.826
2 gene2       P1  0.41 coverage1 0.911
3 gene3       P1  0.24 coverage1 0.833
4 gene4       P1  0.47 coverage1 0.853
5 gene5       P1  0.59 coverage1 0.813
6 gene6       P1  0.37 coverage1 0.753
#Plot
ggplot(d1,aes(GENES,fill=variable,alpha=cov))+
geom_bar(aes(weight=value),position = "dodge")