在每个方面更改选项
我使用 ggplot2 中的构面来绘制大量基因的表达分布。我的绘图命令非常通用:
p <- ggplot(top_n,aes(x=value,fill=ptype))
p <- p + geom_density(alpha = 0.2)
p <- p + facet_wrap(~probe,...)
它们只是将 top_n 中的数据绘制为根据 ptype 变量着色的分布。看起来很棒。
然而,其中一些基因比其他基因更重要。例如,突出显示转录因子 (TF) 等基因会非常酷。一种方法是更改与 TF 相对应的每个方面的颜色标题框、背景颜色或类似颜色。
有没有办法让我在每个方面设置图的选项?
在 p
对象中进行挖掘并没有发现任何我可以使用的东西,尽管我可能遗漏了一些东西!
I'm using facets in ggplot2 to plot the distribution of expression in a large number of genes. My plotting commands are pretty generic:
p <- ggplot(top_n,aes(x=value,fill=ptype))
p <- p + geom_density(alpha = 0.2)
p <- p + facet_wrap(~probe,...)
they just plot the data in top_n as distributions coloured according to the ptype
variable. It looks great.
Some of these genes, however, are more important than others. It would be really cool to highlight those genes which are transcription factors (TFs), for example. One way would be for me to change the colour title box over each facet corresponding to a TF, or the background colour, or something like that.
Is there a way for me to set options of the plots on a per-facet basis?
Digging around in the p
object hasn't turned up anything I can use, though I'm probably missing something!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用具有无限范围和不同面的填充颜色的
geom_rect
。这已在此处的解决方案中完成:有条件地使用facet_grid更改面板背景?
You could use
geom_rect
with infinite extents and a fill colour that varies from facet to facet.This has been done in a solution here: Conditionally change panel background with facet_grid?