Question: ggplot density plot across bed file
0
gravatar for rbronste
6 months ago by
rbronste340
rbronste340 wrote:

Hi I have a bed file that looks like the following:

       V1      V2        V3        V4        V5        V6
1     chr5 114139382 114139383 38.417794 1.417096e-01 0.90
2     chr5 114139397 114139398 38.230517 1.462339e-01 0.90
3    chr12  71048245  71048246 37.166154 1.500587e-01 0.57
4    chr12  71048296  71048297 41.060579 1.216497e-01 0.57

Column V4 is an average fragment size at each genomic position. I would like to create a density plot describing distributions of average fragment size using column V4 but am not sure how to go about it.

Any idea are much appreciated, thanks!

bed density plot ggplot bedops R • 372 views
ADD COMMENTlink modified 6 months ago by Nicolas Rosewick8.7k • written 6 months ago by rbronste340
1
gravatar for Chirag Parsania
6 months ago by
Chirag Parsania1.7k
University of Macau
Chirag Parsania1.7k wrote:

Replace mpg to your data.frame and cty to V4

library(tidyverse)

mpg  %>% ggplot() + geom_density(aes(x = cty))

ADD COMMENTlink modified 6 months ago by zx87549.1k • written 6 months ago by Chirag Parsania1.7k
1

No need to load the whole universe:

library(ggplot2)

ggplot(mpg, aes(cty)) + geom_density()
ADD REPLYlink written 6 months ago by zx87549.1k
1
gravatar for Nicolas Rosewick
6 months ago by
Belgium, Brussels
Nicolas Rosewick8.7k wrote:

In base R :

plot(density(df$V4))

if df is your dataframe

ADD COMMENTlink written 6 months ago by Nicolas Rosewick8.7k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1259 users visited in the last hour