[R] pairwise correlations for large dataset

Alayne L. Brunner alayne.brunner at stanford.edu
Fri Aug 27 20:00:47 CEST 2010


Actually, I've answered my own question.

It turns out that transposing the expression matrix first, outside of the loop, significantly improves the speed.  It now looks like the entire matrix should be calculated in a day or two.  So I think this solution should be fine.



I now have this:

expression.data<-t(expression.data)

for (j in 1:dim(genes2)[1]){

        for(i in 1:dim(genes1)[1]){

 		 peak1<-as.vector(expression.data[genes1[i,1],])
 		 peak2<-as.vector(expression.data[genes2[j,1],])
 		
                 Cor.matrix[i,j]<-cor(peak1,peak2,method='s')
  } 
}



Thanks for reading.
Alayne



More information about the R-help mailing list