mean of individual rows for subsets of columns in an ExprSet
1
0
Entering edit mode
@anna-gustafsson-129
Last seen 10.2 years ago
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)
• 1.3k views
ADD COMMENT
0
Entering edit mode
@vincent-j-carey-jr-4
Last seen 10 weeks ago
United States
> > 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)))
ADD COMMENT
0
Entering edit mode
Vincent Carey 525-2265 <stvjc@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))) Would 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)
ADD REPLY
0
Entering edit mode
There are functions to compute row means or column means that are much faster than using apply(): > mns.col <- colMeans(exprs(eset)[,4:7]) > mns.row <- rowMeans(exprs(eset)[,4:7]) In S-Plus similar functions are available for variance (rowVars, colVars) and standard deviation (rowStdevs, colStdevs) but I didn't find them in R. Johannes Quoting Vincent Carey 525-2265 <stvjc@channing.harvard.edu>: > > > > 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))) > > _______________________________________________ > Bioconductor mailing list > Bioconductor@stat.math.ethz.ch > https://www.stat.math.ethz.ch/mailman/listinfo/bioconductor >

Login before adding your answer.

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