PGreen February 2016

Apply scale_colour_gradient in multiple histogram

For a set of 8 genes I have performance and coverage data for three different methods, I would like to represent at the same time both measurements. I was thinking about plotting performance in y-axis and coverage as scale_colour_gradient, something like:

enter image description here

And the data:

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

Could anybody give me some guidelines on how to do that? I've seen examples of a single scale gradient per plot, but couldn't find like this. Do you know other ideas to represent this two dimensions of information at the same time?

Thanks.

EDIT: @Jimbou I've tried something similar but it didn't do what I expected: I formatted the data using melt, then I changed colnames to avoid confusion and plot it:

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

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

enter image description here

But this isn't the same

Answers


Jimbou February 2016

You can simply specify the color and alpha parameters within the ggplot function. Read your data using copy & paste. Transform it to a data format appropriate for ggplot and plot the bars.

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")

Post Status

Asked in February 2016
Viewed 1,270 times
Voted 14
Answered 1 times

Search




Leave an answer