Pearson correlation and p-values for a matrix
1
0
Entering edit mode
Dren Scott ▴ 10
@dren-scott-1208
Last seen 10.1 years ago
Hi All, I was trying to calculate the pearson correlation (and p-value) for a gene dataset ( 6000 rows x 10 columns). For each row vector, I wanted to calculate the p-value with respect to the other row vectors. My resulting p-value matrix should be of size 6000 x 6000. I tried the iterative approach: for(i in 1:nrow(data)){ for(j in i:nrow(data)){ p_value <- cor.test(data[i,],data[j,])$p.value pmatrix[j,i] <- pmatrix[i,j] <- p_value } } But this will take too long for nrow(data) = 6000. Is there some method by which I can pass the matrix into a function to get the p-values? The dataset would also have some/many NA's. thanks, Dren --------------------------------- [[alternative HTML version deleted]]
• 2.5k views
ADD COMMENT
0
Entering edit mode
xpeng ▴ 60
@xpeng-1210
Last seen 10.1 years ago
Hi Dren, I had the similar question, then I wrote my own C program to calculate correlation matrices (2-3min for a 8000 x 60 matrix). You can contact with me directly (xpeng@utk.edu), it need some extra works to get p-values. I will post it somewhere online if there are enough interests. Best, Xinxia >===== Original Message From Dren Scott <dren_scott@yahoo.com> ===== >Hi All, > >I was trying to calculate the pearson correlation (and p-value) for a gene dataset ( 6000 rows x 10 columns). For each row vector, I wanted to calculate the p-value with respect to the other row vectors. My resulting p-value matrix should be of size 6000 x 6000. > >I tried the iterative approach: > > >for(i in 1:nrow(data)){ > > for(j in i:nrow(data)){ > > p_value <- cor.test(data[i,],data[j,])$p.value > > pmatrix[j,i] <- pmatrix[i,j] <- p_value > > } > >} > > > >But this will take too long for nrow(data) = 6000. Is there some method by which I can pass the matrix into a function to get the p-values? The dataset would also have some/many NA's. > > > >thanks, > > > >Dren > > > >--------------------------------- > > > [[alternative HTML version deleted]] > >_______________________________________________ >Bioconductor mailing list >Bioconductor@stat.math.ethz.ch >https://stat.ethz.ch/mailman/listinfo/bioconductor
ADD COMMENT
0
Entering edit mode
Here is what I would do: use "cor" to compute the correlations extract the test part of the cor.test into a function that inputs a vector of correlations and outputs a vector of p-values. Run the new function on the correlation matrix. --Naomi At 11:19 AM 4/19/2005, xpeng wrote: >Hi Dren, > >I had the similar question, then I wrote my own C program to calculate >correlation matrices (2-3min for a 8000 x 60 matrix). You can contact with me >directly (xpeng@utk.edu), it need some extra works to get p-values. I will >post it somewhere online if there are enough interests. > >Best, >Xinxia > > > > > >===== Original Message From Dren Scott <dren_scott@yahoo.com> ===== > >Hi All, > > > >I was trying to calculate the pearson correlation (and p-value) for a gene >dataset ( 6000 rows x 10 columns). For each row vector, I wanted to calculate >the p-value with respect to the other row vectors. My resulting p-value >matrix >should be of size 6000 x 6000. > > > >I tried the iterative approach: > > > > > >for(i in 1:nrow(data)){ > > > > for(j in i:nrow(data)){ > > > > p_value <- cor.test(data[i,],data[j,])$p.value > > > > pmatrix[j,i] <- pmatrix[i,j] <- p_value > > > > } > > > >} > > > > > > > >But this will take too long for nrow(data) = 6000. Is there some method by >which I can pass the matrix into a function to get the p-values? The dataset >would also have some/many NA's. > > > > > > > >thanks, > > > > > > > >Dren > > > > > > > >--------------------------------- > > > > > > [[alternative HTML version deleted]] > > > >_______________________________________________ > >Bioconductor mailing list > >Bioconductor@stat.math.ethz.ch > >https://stat.ethz.ch/mailman/listinfo/bioconductor > >_______________________________________________ >Bioconductor mailing list >Bioconductor@stat.math.ethz.ch >https://stat.ethz.ch/mailman/listinfo/bioconductor Naomi S. Altman 814-865-3791 (voice) Associate Professor Bioinformatics Consulting Center Dept. of Statistics 814-863-7114 (fax) Penn State University 814-865-1348 (Statistics) University Park, PA 16802-2111
ADD REPLY

Login before adding your answer.

Traffic: 463 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6