[BioC] Boxplot from dataframe...

James W. MacDonald jmacdon at med.umich.edu
Mon Jan 9 15:49:02 CET 2006


David Ruau wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi,
> I wrote a little function to do a boxplot for a row element of a 
> numeric matrix. Indeed for a specific probeset of a expression value 
> matrix but the problem is not with bioconductor functions but on the 
> right use of R.
> 
> Is there a simpler way to do a boxplot for a specific probeset from 
> either a AffyBatch or an expression matrix?
> - ---- code ----
> myboxplot <- function(id,e.mat){
> 
> 	require(mgu74av2)
> 	# grab the expression values
> 	x <- e.mat[rownames(e.mat)==id]
> 
> 	# make column of those expression value
> 	c1 <- as.list(t(x[1:3])) # Exp1
> 	c2 <- as.list(t(x[4:6])) # Exp2
> 	c3 <- as.list(t(x[7:9])) # Exp3
> 	c4 <- as.list(t(x[10:12])) # Exp4
> 	c5 <- as.list(t(x[13:14])) # Exp5
> 	c6 <- as.list(t(x[15:17])) # Exp6
> 
> 	# Little transformation for c5 as there is only 2 value for it and 3 
> for the others.
> 	c5 <- c(c5, NA) # because only 2 values
> 	
> 	# combinaison of the column
> 	x <- cbind(c1,c2,c3,c4,c5,c6)
> 	
> 	# Convert to a dataframe
> 	x <- as.data.frame(x)
> 
> 	# Add name to the column
> 	colnames(x) <- c("Exp1", "Exp2", "Exp3", "Exp4", "Exp5", "Exp6")
> 	
> 	# Grab gene name for plot's title
> 	y <- mget (id, env= mgu74av2GENENAME)	
> 	names(y) <- NULL
> 
> 	boxplot(x)
> 	title(main=y, sub=id)
> }

That is a lot of work to get a boxplot. You should be able to get the 
same thing with much less work.

y <- get(id, mgu74av2GENENAME)
expt <- as.factor(rep(1:6, each=3)[-13])
boxplot(exprs(e.mat)[id,]~expt, main = y, sub = id, names = paste("Exp", 
1:6, sep=""))
> - ----
> Thanks,
> David
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (Darwin)
> 
> iD8DBQFDwmHB7EoGVUIQyhERAuRiAJ491zrSB/zD7P8aRMkc7nKPu496rwCggnsi
> gi2RwP7t2CQcC0pTsTVFsos=
> =6H0E
> -----END PGP SIGNATURE-----
> 
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor


-- 
James W. MacDonald
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623



More information about the Bioconductor mailing list