[R] correlatation matrix

From: Unger, Kristian, Dr. <unger_at_helmholtz-muenchen.de>
Date: Tue, 31 May 2011 09:03:50 +0200

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


Helmholtz Zentrum M?nchen
Deutsches Forschungszentrum f?r Gesundheit und Umwelt (GmbH) Ingolst?dter Landstr. 1
85764 Neuherberg
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]]

R-help_at_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. Received on Tue 31 May 2011 - 07:06:03 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 31 May 2011 - 11:00:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive