[BioC] mean of individual rows for subsets of columns in an ExprSet

Douglas Bates bates at stat.wisc.edu
Wed Aug 20 17:35:21 MEST 2003

Vincent Carey 525-2265 <stvjc at channing.harvard.edu> writes:

> >
> > I am sorry to disturb with yet a simple question but I have tried my best and have now given up on solving it myself... :(
> >
> > I wonder if somebody knows how I easily can create mean values and their SD from subsets of columns (representing cases) over all rows individually (representing the genes) from an object - eset - (which is an Expression Set with 12625 genes, 7 samples).
> > E.g the mean and SD from all rows individually in columns 4,5,6 and 7 of my data?
> >
> > Grateful for help!
> >
> > // Anna :o)
> mns <- apply(exprs(eset)[,4:7],2,mean)
> sds <- apply(exprs(eset)[,4:7],2,function(x)sqrt(var(x)))


mns <- rowMeans(exprs(eset)[,4:7])

work?  If so, it is likely to be faster.  (I'm not sure if exprs(eset)
can be treated as a matrix.)

Also, the function sd is equivalent to function(x)sqrt(var(x)) so the
second could be written

sds <- apply(exprs(eset)[,4:7],2,sd)

More information about the Bioconductor mailing list