ggplot density plot across bed file
2
0
Entering edit mode
4.6 years ago
rbronste ▴ 420

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!

R ggplot density plot bed bedops • 2.0k views
ADD COMMENT
2
Entering edit mode
4.6 years ago
Chirag Parsania ★ 2.0k

Replace mpg to your data.frame and cty to V4

library(tidyverse)

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

ADD COMMENT
1
Entering edit mode

No need to load the whole universe:

library(ggplot2)

ggplot(mpg, aes(cty)) + geom_density()
ADD REPLY
1
Entering edit mode
4.6 years ago

In base R :

plot(density(df$V4))

if df is your dataframe

ADD COMMENT

Login before adding your answer.

Traffic: 1940 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6