Skip to contents

Takes a matrix and centers the rows by their median.

Usage

medianCtr(x)

Arguments

x

a matrix

Value

A matrix with median centered rows.

Details

The data matrix should have genes as rows and samples as columns. After centering, each row should have median approximately 0.

Author

Samuel Leung

Examples

x <- matrix(rnorm(200), nrow = 10)
medianCtr(x)
#>              [,1]        [,2]          [,3]        [,4]        [,5]       [,6]
#>  [1,] -0.09793309  0.58799843  0.0424421089  1.18515294  0.83682342 -1.7130678
#>  [2,] -0.45409894  0.47603032  0.1677346702 -1.67274639  1.43673650 -0.5637549
#>  [3,] -1.02320273 -0.01368702  0.0607288366  1.60199252 -0.30570826  0.2290464
#>  [4,] -0.19214892  0.29169337  1.1410231933  1.82361371 -0.55488085  1.2842145
#>  [5,]  0.19637459  0.33544744  0.4695820350 -2.03747028 -1.32150193 -1.1962742
#>  [6,] -0.61266190  0.38236037 -0.4813165832  1.31013347  1.38004265 -0.7924195
#>  [7,] -1.11263437 -0.77372633  0.1659866243  2.19527855 -0.24921547 -0.2653995
#>  [8,] -0.46653521  1.06254789 -0.2136806017  0.04763128 -0.09470142  0.7354033
#>  [9,] -3.20407206 -1.08612945  0.0002276474  0.76702628  0.99352507 -1.6475528
#> [10,]  1.26551093 -0.24841244 -0.1582293933  1.34714926 -1.57694280  0.3742961
#>              [,7]          [,8]        [,9]       [,10]        [,11]
#>  [1,]  0.51260339 -0.0438793522  0.33056862  0.03636754  2.486369793
#>  [2,]  0.47035053 -0.4122212895  0.26868850 -0.32969727 -0.002998255
#>  [3,]  1.15073162  0.3007383093  0.09232767 -2.03141541  0.149736155
#>  [4,] -0.45508284  1.9677002991 -1.45027467 -1.26206737  0.421005321
#>  [5,]  0.44017717 -0.1251146244 -0.89553521  0.41215360 -1.368687063
#>  [6,]  0.71252317 -0.7087513674  0.18703555  2.82745078  1.674522919
#>  [7,]  0.73090598  2.0929744845 -0.68564210 -0.61573254  1.527434870
#>  [8,]  0.09442895  0.8353215951 -0.11079297  0.22261531 -0.183474219
#>  [9,]  0.53092825 -0.0002276474  0.55884984 -1.97300026  0.438821304
#> [10,]  0.02493341  2.3959319754  0.35925995 -0.89954140  0.780721713
#>             [,12]      [,13]      [,14]       [,15]       [,16]       [,17]
#>  [1,] -1.00748599  0.5460622 -0.4301548 -0.36253330 -1.23412707 -0.23376889
#>  [2,]  1.23619059 -0.8143477  0.2833737 -0.09818734  0.13612492 -0.21745817
#>  [3,]  1.09158223 -0.2800588 -0.1709266 -0.50188553 -1.33172775  0.01368702
#>  [4,] -2.25857893  0.4397230 -0.7843014 -0.40096318 -0.33215941  0.93534790
#>  [5,]  0.05016143  0.2955891  0.2505113  0.35116546 -2.96431452 -0.05016143
#>  [6,] -0.18703555  1.1887199 -0.3371592 -0.25866017 -0.46611134 -0.24323315
#>  [7,] -0.43195857  0.9297794 -1.7544891 -0.16598662 -1.49394633  1.02570416
#>  [8,]  0.49730680 -1.4516439  0.6171007  2.69948117 -0.04763128  1.21588839
#>  [9,]  1.23158814 -1.5264982 -0.9858725  0.18772690  0.79182909 -1.07926520
#> [10,]  0.68847454 -0.4527777 -0.3813487 -1.26836020 -0.37611365 -0.02493341
#>              [,18]      [,19]      [,20]
#>  [1,] -0.036367544  0.5331509 -1.2026470
#>  [2,]  0.002998255 -0.5374032  1.4333804
#>  [3,] -0.312343491 -1.1901040  0.0753716
#>  [4,]  0.192148919 -1.0598239  1.2032443
#>  [5,] -1.816330766 -1.1678753  0.3393083
#>  [6,]  0.713833085  0.6203684 -0.4849150
#>  [7,]  1.511566037  0.5581871  0.4653572
#>  [8,] -0.791938712 -0.1360084 -1.8278832
#>  [9,] -0.024151301  1.3207570 -1.2209984
#> [10,]  0.417401977  0.5703424 -0.7533678
#> attr(,"scaled:center")
#>  [1]  0.04986245 -0.39233627  0.04492085  0.16955809  0.18146726 -0.29812035
#>  [7] -0.28389104 -0.16700013  0.45613993 -0.43543291