[BioC] Boxplot from dataframe...
David Ruau
druau at ukaachen.de
Tue Jan 10 14:08:42 CET 2006
Thanks for the hint.
I rewrote the program
Here is how it looks like when apply to AffyBatch which contain a
phenoData vector "population" describing the data structure.
The thing I can't managed to do without going through a matrix to stock
the expression data, is to have the name of the corresponding
experiment below each boxplot (i.e for the moment I have the default
numbering).
the first version of the script (see bottom) is doing that not this new
one. This one is creating a legend inside the graph.
##
# usage: myboxplot("1234_at", abatch)
myboxplot <- function(id,abatch){
require(mgu74av2)
require(gplots)
require(RColorBrewer)
# Grab title
y <- mget (id, env= mgu74av2GENENAME)
names(y) <- NULL
# Colors
colors <- brewer.pal(9, "Set1")
boxplot(exprs(abatch)[rownames(exprs(abatch))==id] ~
abatch$population, col=colors)
title(main=y, sub=id)
smartlegend(x="left",y="top", inset=0, c("1: Exp1", "2: Exp2", "3:
Exp3", "4: Exp4", "5: Exp5", "6: Exp6"), fill=colors)
}
#end
On Jan 9, 2006, at 15:49, James W. MacDonald wrote:
> 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