[BioC] plotDensity in a multiple-figure enviroment

Liaw, Andy andy_liaw at merck.com
Mon Mar 7 14:24:22 CET 2005


I'd suggest using densityplot() in `lattice'; e.g.:

> m <- matrix(rnorm(6e3), 1e3, 6)
> colnames(m) <- paste("cond", 1:6)
> library(lattice)
> densityplot(~ m | factor(rep(colnames(m), each=nrow(m))))

HTH,
Andy


> From: Adaikalavan Ramasamy
> 
> There must be more elegant way of doing this but here is my solution
> 
> my.plotDensity <- function (mat, ylab = "density", xlab = "x", type =
> "l", col = 1:6, ...){
> 
>     x.density <- apply(mat, 2, density)
>     all.x <- do.call("cbind", lapply(x.density, function(x) x$x))
>     all.y <- do.call("cbind", lapply(x.density, function(x) x$y))
> 
>     for(i in 1:ncol(mat)){
>          
>          plot( all.x[ ,i], all.y[ ,i], 
>                xlim=range(all.x), ylim=range(all.y),
>                main=colnames(mat)[i],
>                ylab=ylab, xlab=xlab, type=type, col=col, ... )
>     }
> 
>     invisible(list(all.x = all.x, all.y = all.y))
> }
> 
> 
> # Usage 
> 
> m <- matrix( rnorm(1000*6)^2, nc=6 )  # simulate
> m[,5] <- 5 + m[,5]                    # make array 5 an outlier
> colnames(m) <- paste("Array", 1:6)
> 
> par(mfrow=c(2,3))
> my.plotDensity(m)
> 
> 
> Regards, Adai
> 
> 
> On Mon, 2005-03-07 at 07:33 +0000, zhihua li wrote:
> > Hi all.
> > I have a microarry gene expression data in the form of a 
> matrix, where rows 
> > represent genes and columns represent conditions. 
> plotDensity in "affy" 
> > package can draw a density distribution curve for each 
> column and put them 
> > in a single plot. I wanna draw a density distribution curve 
> for each 
> > colomn, put them each in a seperate plot, and put all these 
> plots in a 
> > single page.  What should I do?
> > Thanks to all!
> > 
> > _______________________________________________
> > Bioconductor mailing list
> > Bioconductor at stat.math.ethz.ch
> > https://stat.ethz.ch/mailman/listinfo/bioconductor
> >
> 
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> 
> 
>



More information about the Bioconductor mailing list