plotDensity in a multiple-figure enviroment
2
0
Entering edit mode
zhihua li ▴ 120
@zhihua-li-1129
Last seen 10.2 years ago
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!
• 1.2k views
ADD COMMENT
0
Entering edit mode
@adaikalavan-ramasamy-675
Last seen 10.2 years ago
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@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor >
ADD COMMENT
0
Entering edit mode
Liaw, Andy ▴ 360
@liaw-andy-125
Last seen 10.2 years ago
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@stat.math.ethz.ch > > https://stat.ethz.ch/mailman/listinfo/bioconductor > > > > _______________________________________________ > Bioconductor mailing list > Bioconductor@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > > >
ADD COMMENT

Login before adding your answer.

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