[BioC] genereating correlation matrix from gene expression data
Steve Lianoglou
mailinglist.honeypot at gmail.com
Wed Nov 18 20:05:16 CET 2009
Hi Pankaj,
On Nov 18, 2009, at 1:30 PM, pankaj borah wrote:
> Hi all,
>
> i am a new user of R and Bioconductor package. i deal with gene
> expression data. i was wondering if there is a way to generate a
> correlation matrix (all to all square symmetric matrix) for a set
> of genes and their expression values. is there any available function?
Try ?cor to get the pairwise correlation between columns of your
matrix, eg:
R> x <- matrix(rnorm(20), 4, 5)
R> x
[,1] [,2] [,3] [,4] [,5]
[1,] 0.5818808 0.58781709 2.5511157 -1.5332180 0.6905731
[2,] -0.7640311 0.25960974 0.7246655 -1.5539226 -0.5459625
[3,] -1.7141619 -0.25808091 -0.0868366 -0.6547804 0.4629494
[4,] -2.2906217 0.04932864 0.5694895 0.7736206 0.4078665
R> cor(x)
[,1] [,2] [,3] [,4] [,5]
[1,] 1.00000000 0.851982381 0.8715055 -0.8404848 0.074770380
[2,] 0.85198238 1.000000000 0.9429553 -0.5338964 0.004627258
[3,] 0.87150545 0.942955253 1.0000000 -0.4719936 0.325584972
[4,] -0.84048477 -0.533896414 -0.4719936 1.0000000 0.309414781
[5,] 0.07477038 0.004627258 0.3255850 0.3094148 1.000000000
If your genes are in rows, you'll just need to pass in the transpose
of your matrix.
HTH,
-steve
--
Steve Lianoglou
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact
More information about the Bioconductor
mailing list