Hello,
If by all possible gene ratios you mean all pairwise column ratios, try
the following.
# Make up some data
x <- matrix(1:24, ncol=6)
cmb <- combn(ncol(x), 2)
r1 <- apply(cmb, 2, function(j) x[, j[1]]/x[, j[2]])
r2 <- apply(cmb, 2, function(j) x[, j[2]]/x[, j[1]])
cbind(r1, r2)
Note that the dataset must be a numeric only matrix or data.frame.
Hope this helps,
Rui Barradas
Em 12-05-2012 11:00, r-help-requ...@r-project.org escreveu:
Date: Fri, 11 May 2012 12:39:23 -0700 (PDT)
From: genome1976<genome1...@hotmail.com>
To:r-help@r-project.org
Subject: [R] Calculating all possible ratios
Message-ID:<1336765163039-4627405.p...@n4.nabble.com>
Content-Type: text/plain
I have a data matrix with genes as columns and samples as rows. I want to
create all possible gene ratios.Is there an elegant and fast way to do it in
R and write it to a dataframe?
Thanks for any help.
Som.
--
View this message in
context:http://r.789695.n4.nabble.com/Calculating-all-possible-ratios-tp4627405.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.