[BioC] Gene density plot with points underneath (bug injitter)

Marcus Davy mdavy at hortresearch.co.nz
Mon Feb 26 21:00:26 CET 2007


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}}



More information about the Bioconductor mailing list