How transform FPKM values to Z-score using R
2
3
Entering edit mode
9.5 years ago
mjoyraj ▴ 80

I have FPKM values of 2766 genes for 15 different conditions. I want to transform the FPKM into Z-score. How can I do this?

A small glimpse of the data is given below

Gene                 Cluster   cEB1      cEB2      cEb3      cLB1      cLb2      cLB3      cEF1       cEF2      cEF3       cLF1       cLF2       cLF3       cMF1       cMF2       cMF3
Chr1_FK1             1         32125.1   12358.3   5830      9615.8    21497.2   16153     7301.54    5689.22   1559.81    1046.97    9.70811    12.6835    8767.73    8039.51    11612.4
ENSGALG00000000277   1         9.45172   1.13001   3.33611   8.02945   4.31835   1.73261   0.454218   0         0.595844   0          0          0.139979   0.083132   0          0.08953
ENSGALG00000000341   1         25696.9   5322.23   3800.56   3296.56   9739.64   13518     3600.36    2325.34   62.2555    7.96366    1.94201    8.05702    5092.02    3704.02    6048.07
ENSGALG00000000521   1         141.774   65.2475   54.9138   57.7126   96.6525   97.7173   50.6554    47.9005   35.9634    17.1921    20.2356    27.2313    66.7392    50.5141    61.0671
ENSGALG00000000526   1         3.9706    1.15042   1.63248   1.0424    1.69618   1.69195   1.78895    1.14488   0.591284   0.252008   0.594155   0.442257   1.79887    1.39072    1.30568
ENSGALG00000000645   1         3.20263   2.25025   2.47694   2.8685    2.13484   1.60007   0.801766   1.16636   0.830455   0.054204   0.099204   0.151425   0.424215   0.431372   0.314711
ENSGALG00000000748   1         30.7      17.9308   13.7772   9.71653   22.2964   22.2266   7.1346     4.97026   2.45806    1.12066    1.24514    1.30448    8.35496    5.04605    7.71874
ENSGALG00000001885   1         25.7813   13.5145   21.4617   22.9718   17.574    18.2177   3.42242    5.17301   2.50592    0          0.226905   0.346521   3.44081    2.64345    3.74202
ENSGALG00000002412   1         43.9355   31.886    19.9528   24.7974   28.5074   31.8579   24.0985    21.3538   20.1413    7.21469    6.4085     5.69435    21.5841    18.0618    22.9048
ENSGALG00000002681   1         141.55    81.2838   50.0476   93.3922   76.0349   67.5903   57.3259    87.5868   42.1664    21.2901    15.156     15.5312    53.339     54.5204    66.068
ENSGALG00000002988   1         206.862   110.517   137.667   111.514   72.4366   71.3408   31.216     38.0035   36.928     59.9633    10.1934    19.3801    20.2704    18.8814    65.0859
ENSGALG00000003921   1         312.418   218.574   245.381   176.837   194.555   214.552   83.4999    84.6692   65.0635    124.388    133.099    109.405    155.528    145.834    154.364
RNA-seq R • 12k views
ADD COMMENT
11
Entering edit mode
9.5 years ago

The z-score in R code is:

zscore<- function(x){
    z<- (x - mean(x)) / sd(x)
    return(z)
}
z.fpkm<- zscore(data$fpkm)

I would probably log transform the raw fpkm values to make them closer to a normal distribution and consequently make the z-score more meaningful.

ADD COMMENT
0
Entering edit mode

What is X and Z here...??

ADD REPLY
1
Entering edit mode

x is all the data you're using for the population stats. z is holding the calculation, then returning the data to a specified output.

also dariober is correct, you should log transform first. also, you may want to see if you can switch to TPM instead of FPKM or RPKM.

ADD REPLY
7
Entering edit mode
9.5 years ago

See the R scale() and sweep() R functions.

ADD COMMENT

Login before adding your answer.

Traffic: 1860 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