[BioC] mean of individual rows for subsets of columns in an
ExprSet
Claire Wilson
ClaireWilson at PICR.man.ac.uk
Wed Aug 20 16:59:18 MEST 2003
HI Anna,
I had a similar problem myself and didn't come up with an easy way to solve it, so my approach was
res <- matrix(nrow=length(rownames(x)),ncol=2, byrow=T)
for (i in 1:length(rownames(x))){
res[i,1] <- ((x[i,4]+x[i,5]+x[i,6])+x[i,7])/4)
res[i,2] <- #calculate the SD here
}
you could probably set this up as a function allowing you to select different columns each time or if can assign your different columns to groups (maybe assign those you want mean and SD for as 1 and those you don't as 0) you could do something like
groups <- c(0,0,0,1,1,1,1)
calc.means <-function(x, y){
by(x, y, mean)
}
apply(eset at exprs,1 calc.means, y=groups)
if you have a phenoData variable that distinguishes those columns you want from those you don't then even better, as you can use esApply, this can split your data according to a particular phenoData variable
calc.means <-function(x){
by(x, <phenoData variable>, mean)
}
esApply(eset at exprs,1 calc.means)
hope this helps
claire
> -----Original Message-----
> From: Anna Gustafsson [mailto:annag at biotech.kth.se]
> Sent: 20 August 2003 15:39
> To: bioconductor at stat.math.ethz.ch
> Subject: [BioC] mean of individual rows for subsets of columns in an
> ExprSet
>
>
> Dear all,
>
> 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)
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://www.stat.math.ethz.ch/mailman/listinfo/bioconductor
>
--------------------------------------------------------
This email is confidential and intended solely for the use o...{{dropped}}
More information about the Bioconductor
mailing list