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.19214892  0.29169337  1.1410231933  1.82361371 -0.55488085  1.2842145
#>  [2,]  0.19637459  0.33544744  0.4695820350 -2.03747028 -1.32150193 -1.1962742
#>  [3,] -0.61266190  0.38236037 -0.4813165832  1.31013347  1.38004265 -0.7924195
#>  [4,] -1.11263437 -0.77372633  0.1659866243  2.19527855 -0.24921547 -0.2653995
#>  [5,] -0.46653521  1.06254789 -0.2136806017  0.04763128 -0.09470142  0.7354033
#>  [6,] -3.20407206 -1.08612945  0.0002276474  0.76702628  0.99352507 -1.6475528
#>  [7,]  1.26551093 -0.24841244 -0.1582293933  1.34714926 -1.57694280  0.3742961
#>  [8,]  0.58799843  0.04244211  1.1851529376  0.83682342 -1.71306776  0.5126034
#>  [9,]  0.47603032  0.16773467 -1.6727463856  1.43673650 -0.56375488  0.4703505
#> [10,] -0.05089495  0.02352091  1.5647845946 -0.34291619  0.19183851  1.1135237
#>              [,7]          [,8]        [,9]        [,10]      [,11]       [,12]
#>  [1,] -0.45508284  1.9677002991 -1.45027467 -1.262067373  0.4210053 -2.25857893
#>  [2,]  0.44017717 -0.1251146244 -0.89553521  0.412153603 -1.3686871  0.05016143
#>  [3,]  0.71252317 -0.7087513674  0.18703555  2.827450781  1.6745229 -0.18703555
#>  [4,]  0.73090598  2.0929744845 -0.68564210 -0.615732535  1.5274349 -0.43195857
#>  [5,]  0.09442895  0.8353215951 -0.11079297  0.222615312 -0.1834742  0.49730680
#>  [6,]  0.53092825 -0.0002276474  0.55884984 -1.973000258  0.4388213  1.23158814
#>  [7,]  0.02493341  2.3959319754  0.35925995 -0.899541400  0.7807217  0.68847454
#>  [8,] -0.04387935  0.3305686232  0.03636754  2.486369793 -1.0074860  0.54606224
#>  [9,] -0.41222129  0.2686884953 -0.32969727 -0.002998255  1.2361906 -0.81434769
#> [10,]  0.26353038  0.0551197438 -2.06862334  0.112528225  1.0543743 -0.31726677
#>            [,13]       [,14]      [,15]       [,16]        [,17]      [,18]
#>  [1,]  0.4397230 -0.78430136 -0.4009632 -0.33215941  0.935347896  0.1921489
#>  [2,]  0.2955891  0.25051127  0.3511655 -2.96431452 -0.050161427 -1.8163308
#>  [3,]  1.1887199 -0.33715916 -0.2586602 -0.46611134 -0.243233148  0.7138331
#>  [4,]  0.9297794 -1.75448913 -0.1659866 -1.49394633  1.025704160  1.5115660
#>  [5,] -1.4516439  0.61710070  2.6994812 -0.04763128  1.215888391 -0.7919387
#>  [6,] -1.5264982 -0.98587255  0.1877269  0.79182909 -1.079265197 -0.0241513
#>  [7,] -0.4527777 -0.38134872 -1.2683602 -0.37611365 -0.024933412  0.4174020
#>  [8,] -0.4301548 -0.36253330 -1.2341271 -0.23376889 -0.036367544  0.5331509
#>  [9,]  0.2833737 -0.09818734  0.1361249 -0.21745817  0.002998255 -0.5374032
#> [10,] -0.2081346 -0.53909346 -1.3689357 -0.02352091 -0.349551421 -1.2273119
#>             [,19]      [,20]
#>  [1,] -1.05982393  1.2032443
#>  [2,] -1.16787528  0.3393083
#>  [3,]  0.62036837 -0.4849150
#>  [4,]  0.55818705  0.4653572
#>  [5,] -0.13600842 -1.8278832
#>  [6,]  1.32075703 -1.2209984
#>  [7,]  0.57034238 -0.7533678
#>  [8,] -1.20264699 -0.2530687
#>  [9,]  1.43338042 -0.6826914
#> [10,]  0.03816367  1.4773788
#> attr(,"scaled:center")
#>  [1]  0.16955809  0.18146726 -0.29812035 -0.28389104 -0.16700013  0.45613993
#>  [7] -0.43543291  0.04986245 -0.39233627  0.08212878