Hi there,

I wonder if there is a way of efficiently generating a correlation matrix of two expression matrices. I want to correlate miRNA and mRNA expression and used the following code:
##dat.mi miRNA expression matrix, dat.m mRNA expression matrix
nc <- nrow(dat.mi)
cor.mat <- data.frame(rep(NA,nrow(dat.m)))
pval.mat <- data.frame(rep(NA,nrow(dat.m)))
for(i in 1:nc)
{
cr <- vector()
pv <- vector()
print(paste(i," mirs out of ", nc,sep=""))
for (k in 1:nrow(dat.m))
{
#print(paste(k," genes out of ",  nrow(dat.m),sep=""))
cr2 <- cor.test(as.numeric(dat.mi[i,]),as.numeric(dat.m[k,]))
cr <- c(cr,cr2$estimate)
pv <- c(pv,cr2$p.value)
}
cor.mat <- cbind(cor.mat,as.vector(cr))
pval.mat <- cbind(pval.mat,as.vector(pv))
}

The columns in the output represent miRNAs and the rows mRNAs. The code works fine but takes ages (about an 1.5h for generating a 169x20043 matrix) so I wonder if there is a more efficient way of doing this calculation?

Best wishes

Kristian

________________________________
Helmholtz Zentrum M?nchen
Deutsches Forschungszentrum f?r Gesundheit und Umwelt (GmbH)
Ingolst?dter Landstr. 1
85764 Neuherberg
www.helmholtz-muenchen.de
Aufsichtsratsvorsitzende: MinDir?in B?rbel Brumme-Bothe
Gesch?ftsf?hrer: Prof. Dr. G?nther Wess und Dr. Nikolaus Blum
Registergericht: Amtsgericht M?nchen HRB 6466
USt-IdNr: DE 129521671

	[[alternative HTML version deleted]]

