在ggplot2中绘制基准图 [英] Plotting a bedgraph in ggplot2

查看:72
本文介绍了在ggplot2中绘制基准图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前一直使用Sushi包中的plotBedgraph函数来生成基准图,但是我目前正在尝试使用ggplot2重新创建它,因为它与我的实验室使用的其他绘图代码不兼容.

I had previously been using the plotBedgraph function from the Sushi package to generate bedgraph plots, however I am currently trying to recreate this using ggplot2 as it was not compatible with other plot code that my lab is using.

密度图似乎适合于该图,但是由于没有经验的R用户来自Python,我无法将正确的参数数据打包到图函数中.是否可以将下面的图像复制到ggplot中,也许作为密度图或其他合适的图函数?

A density plot seems suitable for the plot, but as an inexperienced R user coming from Python, I was unable to data-wrangle the correct arguments into the plot function. Would it be possible to replicate the below image in ggplot, perhaps as a density plot or another suitable plot function?

用于生成图的数据如下所示:

The data used to generate the plot is shown below:

chr13   0   41982   0.00000
chr13   41982   41994   0.10076
chr13   41994   42007   0.90151
chr13   42007   42009   1.73827
chr13   42009   42025   1.74104
chr13   42025   42040   2.55356
chr13   42040   42058   3.49472
chr13   42058   42072   4.29485
chr13   42072   42074   5.19204
chr13   42074   42076   4.29485
chr13   42076   42080   4.29924
chr13   42080   42085   4.30696
chr13   42085   42090   4.31473
chr13   42090   42093   4.32252
chr13   42093   42096   4.33021
chr13   42096   42099   4.33801
chr13   42099   42100   5.24009
chr13   42100   42107   4.33801
chr13   42107   42129   4.34580
chr13   42129   42145   3.54015
chr13   42145   42149   2.60059
chr13   42149   42164   2.57264
chr13   42164   42167   2.29211
chr13   42167   42190   2.57264
chr13   42190   42191   1.74104
chr13   42191   42193   2.57264
chr13   42193   42203   1.44231
chr13   42203   42212   1.74104
chr13   42212   42220   0.91309
chr13   42220   42221   0.96337
chr13   42221   42222   0.11592
chr13   42222   42225   0.16794
chr13   42225   42235   0.17174
chr13   42235   42242   0.17557
chr13   42242   42249   0.17939
chr13   42249   43000   0.00000

推荐答案

如何?

ggplot(data) + geom_rect(aes(xmin=start,xmax=end,ymin=0,ymax=value))

它只是将您的每个间隔绘制为一个填充的矩形,而无需进行纠缠.

It just draws each of your intervals as a filled rectangle, no wrangling required.

这篇关于在ggplot2中绘制基准图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆