Extracting expressions after a multtest procedure (part 2)
1
0
Entering edit mode
@juan-miguel-marin-diazaraque-2441
Last seen 9.6 years ago
Hello, In previous message I wonder how to extract just the expressions of 102 genes under two conditions after a multtest procedure. At last, I wrote this unelegant code that seems to work: quedan <- resT[res$adjp[,"BH"]<0.05,] busco <- dimnames(quedan)[[1]] cosa <- NULL for (i in 1:length(dimnames(exprs(esetSub))[[1]])) for (j in 1:length(busco)) if (dimnames(exprs(esetSub[i,]))[[1]] == busco[j]) { cosa <- rbind(cosa, as.data.frame(exprs(esetSub))[i,]) } end end But it runs very slowly... Best jm~ _______________________________ Juan Miguel Marin http://www.est.uc3m.es/jmmarin Dep. of Statistics University Carlos III of Madrid Spain (E.U.)
multtest multtest • 1.1k views
ADD COMMENT
0
Entering edit mode
@sean-davis-490
Last seen 3 months ago
United States
On Sun, Mar 16, 2008 at 11:56 AM, JUAN MIGUEL MARIN DIAZARAQUE <jmmarin at="" est-econ.uc3m.es=""> wrote: > Hello, > > In previous message I wonder how to extract just the expressions of 102 > genes under two conditions after a multtest procedure. > > At last, I wrote this unelegant code that seems to work: > > quedan <- resT[res$adjp[,"BH"]<0.05,] > busco <- dimnames(quedan)[[1]] > > cosa <- NULL > for (i in 1:length(dimnames(exprs(esetSub))[[1]])) > for (j in 1:length(busco)) > if (dimnames(exprs(esetSub[i,]))[[1]] == busco[j]) { > cosa <- rbind(cosa, as.data.frame(exprs(esetSub))[i,]) } > end > end Generally, you can subset ExpressionSets just like you do data frames; rows are genes or probes and columns are samples. If esetSub is what you used for your multtest procedure, you should be able to do: exprs(esetSub)[res$adjp[,'BH']<0.05,] In general, for loops are quite useful in R, but for things like subsetting or vectorized operations, it is better to look for other alternatives as they are likely to be faster. Sean
ADD COMMENT
0
Entering edit mode
Hi, Please also note that seq(along=x) is almost always preferable to 1:length(x) and seq_len(n) to 1:n. (But as Sean says, if possible, and certainly in your case, using vectorized idioms is of course even more preferable.) Best wishes Wolfgang Sean Davis scripsit 16/03/2008 16:38: > On Sun, Mar 16, 2008 at 11:56 AM, JUAN MIGUEL MARIN DIAZARAQUE > <jmmarin at="" est-econ.uc3m.es=""> wrote: >> Hello, >> >> In previous message I wonder how to extract just the expressions of 102 >> genes under two conditions after a multtest procedure. >> >> At last, I wrote this unelegant code that seems to work: >> >> quedan <- resT[res$adjp[,"BH"]<0.05,] >> busco <- dimnames(quedan)[[1]] >> >> cosa <- NULL >> for (i in 1:length(dimnames(exprs(esetSub))[[1]])) >> for (j in 1:length(busco)) >> if (dimnames(exprs(esetSub[i,]))[[1]] == busco[j]) { >> cosa <- rbind(cosa, as.data.frame(exprs(esetSub))[i,]) } >> end >> end > > Generally, you can subset ExpressionSets just like you do data frames; > rows are genes or probes and columns are samples. If esetSub is what > you used for your multtest procedure, you should be able to do: > > exprs(esetSub)[res$adjp[,'BH']<0.05,] > > In general, for loops are quite useful in R, but for things like > subsetting or vectorized operations, it is better to look for other > alternatives as they are likely to be faster. > > Sean > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor -- Best wishes Wolfgang ------------------------------------------------------------------ Wolfgang Huber EBI/EMBL Cambridge UK http://www.ebi.ac.uk/huber
ADD REPLY
0
Entering edit mode
Hello Sean, thank you very much, the command works fine. It is, by very far, faster than the for-option... Best > On Sun, Mar 16, 2008 at 11:56 AM, JUAN MIGUEL MARIN DIAZARAQUE > <jmmarin at="" est-econ.uc3m.es=""> wrote: >> Hello, >> >> In previous message I wonder how to extract just the expressions of 102 >> genes under two conditions after a multtest procedure. >> >> At last, I wrote this unelegant code that seems to work: >> >> quedan <- resT[res$adjp[,"BH"]<0.05,] >> busco <- dimnames(quedan)[[1]] >> >> cosa <- NULL >> for (i in 1:length(dimnames(exprs(esetSub))[[1]])) >> for (j in 1:length(busco)) >> if (dimnames(exprs(esetSub[i,]))[[1]] == busco[j]) { >> cosa <- rbind(cosa, as.data.frame(exprs(esetSub))[i,]) } >> end >> end > > Generally, you can subset ExpressionSets just like you do data frames; > rows are genes or probes and columns are samples. If esetSub is what > you used for your multtest procedure, you should be able to do: > > exprs(esetSub)[res$adjp[,'BH']<0.05,] > > In general, for loops are quite useful in R, but for things like > subsetting or vectorized operations, it is better to look for other > alternatives as they are likely to be faster. > > Sean > jm~ _______________________________ Juan Miguel Marin http://www.est.uc3m.es/jmmarin Dep. of Statistics University Carlos III of Madrid Spain (E.U.)

Login before adding your answer.

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