Re: [R] Calculating all possible ratios

2012-10-05 Thread Rui Barradas
And was it it? Rui Barradas Em 05-10-2012 21:44, genome1976 escreveu: Thanks Rui.I actually exactly did that. Date: Fri, 5 Oct 2012 05:49:20 -0700 From: ml-node+s789695n4645154...@n4.nabble.com To: genome1...@hotmail.com Subject: Re: Calculating all possible ratios Hello, Comment

Re: [R] Calculating all possible ratios

2012-10-05 Thread genome1976
Thanks Rui.I actually exactly did that. Date: Fri, 5 Oct 2012 05:49:20 -0700 From: ml-node+s789695n4645154...@n4.nabble.com To: genome1...@hotmail.com Subject: Re: Calculating all possible ratios Hello, Comment out the second apply and all following instructions using 'r2'. In the

Re: [R] Calculating all possible ratios

2012-10-05 Thread Rui Barradas
Hello, Comment out the second apply and all following instructions using 'r2'. In the end return 'r1', not cbind. Hope this helps, Rui Barradas Em 04-10-2012 23:38, genome1976 escreveu: Hi Rui, A while ago you helped me with calculaing all possible ratios from a dataset. This is the co

Re: [R] Calculating all possible ratios

2012-10-04 Thread genome1976
Hi Rui, A while ago you helped me with calculaing all possible ratios from a dataset. This is the code I am using as suggested by you. data <- read.table("new_data.txt", header=T, row.names=1, sep="\t") pairwise.ratios <- function(x, prefix="probeset", char=":"){ n <- ncol(x)

Re: [R] Calculating all possible ratios

2012-05-15 Thread Rui Barradas
ces of the same dimensions. Hope this helps, Rui Barradas Em 15-05-2012 11:00, r-help-requ...@r-project.org escreveu: Date: Mon, 14 May 2012 05:49:33 -0700 (PDT) From: genome1976 To:r-help@r-project.org Subject: Re: [R] Calculating all possible ratios Message-ID: Content-Type: text/plain Hi Ru

Re: [R] Calculating all possible ratios

2012-05-14 Thread genome1976
Hi Rui, Thanks once again for all the help. I need to ask for one more help from you. I have two matrices, with probesets as rows and samples as columns. The samples in the two matrices are matched (from the same animal but two different tissues). I want to create a correlation matrix of sample

Re: [R] Calculating all possible ratios

2012-05-12 Thread genome1976
I apologize. You were right. You are a genius! Thanks so much! Best Regards, Som. Date: Sat, 12 May 2012 15:20:52 -0700 From: ml-node+s789695n4629656...@n4.nabble.com To: genome1...@hotmail.com Subject: RE: Calculating all possible ratios Hello, Nothing wrong with me, maybe your R

Re: [R] Calculating all possible ratios

2012-05-12 Thread genome1976
Hi Rui, Thanks once again. I really appreciate it. I tried using the code with the following dataset: Sample P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 S1 5292.9 605.1 5213.9 1710.6 1407.8 1079.4 1379.6 9321.4 6951 1205.8 S2 104.6 57.129 625.

Re: [R] Calculating all possible ratios

2012-05-12 Thread Rui Barradas
Hello, Nothing wrong with me, maybe your R session has some conflicting objects. Running the function in the previous post on the first 4 rows and first 6 columns of your dataset the result was (copy&paste to your session) result <- structure(c(8.74714923153198, 1.83094400392095, 9.92065138471113

Re: [R] Calculating all possible ratios

2012-05-12 Thread Rui Barradas
Hello, I'm glad it helped. Now to make the result readable. (I had thought of it.) pairwise.ratios <- function(x, prefix="probeset", char=":"){ n <- ncol(x) cn <- colnames(x) if(length(cn) == 0){ cn <- gsub(" ", "0", formatC(seq.int(n), width=nchar(n)))

Re: [R] Calculating all possible ratios

2012-05-12 Thread genome1976
Thanks so much Rui. I really appreciate all the help. I implemented the code and it ran fine. I was wondering how I could include the probeset ids as probeset1:probeset2 in the final output so that I know which ratios are for which probeset pairs. Thanks so much. Som. Date: Sat, 12 May 2012 0

Re: [R] Calculating all possible ratios

2012-05-12 Thread Rui Barradas
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 th