Gene density plot with points underneath
1
0
Entering edit mode
Daniel Brewer ★ 1.9k
@daniel-brewer-1791
Last seen 10.3 years ago
Hi, Just a quick question. I have a dataset that has been divided into three groups. I would like to plot a density plot of the expression levels for a particular gene for each group. Also I would like to plot the actual expression levels on a horizontal line under the density line. I think this is a reasonably standard thing to do. How would I go about doing this? Is there a function that simplifies this? Many thanks -- ************************************************************** Daniel Brewer, Ph.D. Institute of Cancer Research Email: daniel.brewer at icr.ac.uk ************************************************************** The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP. This e-mail message is confidential and for use by the addre...{{dropped}}
Cancer Cancer • 991 views
ADD COMMENT
0
Entering edit mode
Marcus Davy ▴ 680
@marcus-davy-374
Last seen 10.3 years ago
Daniel, You can use the lattice package to create conditioned density plots with a dataframe as input and a model formula, e.g. library(lattice) densityplot(~height, data=singer) A first principles approach would be to create a density plot with enough room to be able to add the expression points using the points 'function' e.g. n <- 1000 x <- rnorm(n) plot(density(x), ylim=c(-0.05, 0.4)) points(x, jitter(rep(0, n)) + par()$usr[3]/2) The jitter function is adding random noise and appears to have a BUG in it, if the input vector is a negative scalar or vector of the same negative value. It returns NaN e.g. > jitter(-1) [1] NaN > jitter(-(1:2)) [1] -0.811903 -1.806600 > jitter(rep(0,5)) [1] 0.006074348 0.002293362 -0.019214007 0.010290299 -0.013055610 > jitter(rep(-1,5)) [1] NaN NaN NaN NaN NaN > This is caused by the last line inputting a negative number into runif for the maximum, and a positive number for the minimum and easily fixed with abs. > runif(1,1,-1) [1] NaN Marcus Version _ platform powerpc-apple-darwin8.8.0 arch powerpc os darwin8.8.0 system powerpc, darwin8.8.0 status major 2 minor 4.1 year 2006 month 12 day 18 svn rev 40228 language R version.string R version 2.4.1 (2006-12-18) On 27/2/07 12:26 AM, "Daniel Brewer" <daniel.brewer at="" icr.ac.uk=""> wrote: > Hi, > > Just a quick question. I have a dataset that has been divided into > three groups. I would like to plot a density plot of the expression > levels for a particular gene for each group. Also I would like to plot > the actual expression levels on a horizontal line under the density > line. I think this is a reasonably standard thing to do. How would I > go about doing this? Is there a function that simplifies this? > > Many thanks ______________________________________________________ The contents of this e-mail are privileged and/or confidenti...{{dropped}}
ADD COMMENT

Login before adding your answer.

Traffic: 940 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