r - Color scale ignored by ggplot2 geom_point -
ggplot() + geom_point(data=as.data.frame(res), aes_string(x=res$log2foldchange, y=-log10(res$padj)), colour="darkgrey", alpha=6/10, size=2) + geom_point(data=sig_data, aes_string(x=sig_data$log2foldchange, y=-log10(sig_data$padj)), shape = 21, colour=sig_data$basemean, alpha=5/10, fill = na, size=2,stroke=0.75)+ scale_color_brewer(palette="blues")
no matter specify color scale, silly rainbow scale used without legend indicating colors mean.
my guess syntax wrong. should either
aes(x = log2foldchange, y = -log10(padj), color = basemean)
or if you're hellbent on using aes_string
aes_string(x = "log2foldchange", y = "-log10(padj)", color = "basemean"))
here's example
library(ggplot2) ggplot(mtcars, aes(x = mpg, y = -log10(wt), color = as.factor(cyl))) + geom_point() ggplot(mtcars, aes_string(x = "mpg", y = "-log10(wt)", color = "as.factor(cyl)")) + geom_point()
Comments
Post a Comment