**1.4k**wrote:

I am stuck with a very simple problem. I want to build a Pearson correlation matrix for my microarray dataset. My .cvs file consists of normalized, log-transformed expression values of 18k genes across 36 samples. I want to find the gene-gene Pearson correlation from this matrix using R package. After that, I want to transform the matrix to the form of an edge-list with genes in the first two columns and the value of the correlation in the last column. I was trying out the cor() function in R, but I guess there is some issue with numeric/character values because of which it gives me the error 'x has to be numeric'. Kindly give some suggestions as to what way I can read in the file and transform the matrix.

Thanks

Gene | sample1 | sample2 | sample3 |
---|---|---|---|

A | 10 | 50 | 78 |

B | 50 | 45 | 55 |

C | 70 | 56 | 44 |

**82k**• written 5.8 years ago by pixie@bioinfo •

**1.4k**

I think the

`cor()`

function is trying to also use the geneName (column 1) to infer correlations, have you tried`cor(myData[,-1])`

to calculate it? Also have a look at the vigniette of the {stats} package!25k• written 5.8 years ago by Phil S. •660Thanks..just a query..as I have to find correlations between A&B..B&C..etc...I read somewhere that R works column wise..so I used cor(t(myData[,-1]))..to transform the matrix...am I doing right ? Another issue is this way I am loosing all the row and column headings ..

1.4kto transpose your data is, in general, just fine. Please have in mind the comment from Istvan Albert.

25k• written 5.8 years ago by Phil S. •660