Question: Gene density plot with points underneath
0
gravatar for Daniel Brewer
12.4 years ago by
Daniel Brewer1.9k
Daniel Brewer1.9k 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 -- ************************************************************** 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 • 533 views
ADD COMMENTlink modified 12.4 years ago by Marcus Davy680 • written 12.4 years ago by Daniel Brewer1.9k
Answer: Gene density plot with points underneath
0
gravatar for Marcus Davy
12.4 years ago by
Marcus Davy680
Marcus Davy680 wrote:
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 COMMENTlink written 12.4 years ago by Marcus Davy680
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 16.09
Traffic: 671 users visited in the last hour