# [R] How to calculate p value and correlation coefficient for Spearman’s correlation of differential expression data with 40000 permutations?

Ana Marija @okov|c@@n@m@r|j@ @end|ng |rom gm@||@com
Thu Oct 31 22:08:28 CET 2019

```Hello,

I have 3 groups,let's call them g1, g2, g3. Each of them is a result
of analysis in between groups of conditions, and g1 looks like this

geneSymbol      logFC         t      P.Value
EXykpF1BRREdXnv9Xk      MKI67 -0.3115880 -5.521186 5.772137e-07
0.008986062 4.3106665
0Tm7hdRJxd9zoevPlA     CCL3L3  0.1708020  4.162115 9.109798e-05
0.508784638 0.6630544
u_M5UdFdhg3lZ.qe64     UBE2G1 -0.1528149 -4.031466 1.430822e-04
0.508784638 0.3354065
lkkLCXcnzL9NXFXTl4     SEL1L3 -0.2138729 -3.977482 1.720517e-04
0.508784638 0.2015945
0Uu3XrB6Bd14qoNeuc      ZFP36  0.1667330  3.944917 1.921715e-04
0.508784638 0.1213335
3h7Sgq2i3sAUkxL_n8      ITGB5  0.3419488  3.938960 1.960886e-04
0.508784638 0.1066896

g2 and g2 look the same and each has  15568 entries (genes)

How to calculate p value and correlation coefficient for Spearman’s
correlation for this data for 40000 permutations?

I joined all 3 groups, g1, g2, g3, and extracted only Beta (B)

I got this data frame (d), with matching 15568 entries:

B.x       B.y         B
EXykpF1BRREdXnv9Xk -4.970533 -4.752771 -5.404054
0Tm7hdRJxd9zoevPlA -4.862168 -5.147294 -3.909654
u_M5UdFdhg3lZ.qe64 -5.368846 -5.396183 -5.405330
lkkLCXcnzL9NXFXTl4 -4.367704 -4.847795 -5.148524
0Uu3XrB6Bd14qoNeuc -5.286592 -4.949305 -5.278798
3h7Sgq2i3sAUkxL_n8 -4.579528 -2.403240 -4.710600

To calculate Spearman’s I could use in R:

> cor(d,use="pairwise.complete.obs",method="spearman")
B.x          B.y            B
B.x 1.000000000  0.234171932  0.002474729
B.y 0.234171932  1.000000000 -0.005469126
B   0.002474729 -0.005469126  1.000000000

Can someone please tell me what would be the method to use to get
correlation coefficient and p value taken in account number of
permutations? And am I am correct to use Beta in order to do
correlation in between these 3 groups?

Thanks!

```