cfr_linReg.Rd
Removing Confounding Factor Effects using Linear Regression
cfr_linReg(mat, cov)
mat | a numeric matrix with the expression values, where columns are the samples and rows are probesets, transcripts, or genes. |
---|---|
cov | a list with covariates to regress out from the expression matrix |
a list with three elements, i) corrected expression matrix, ii) coefficients for the covariates and iii) p values for each covariate
myexp <- sapply( 1:10, function(i){ rnorm(n = 10000, mean = sample(1:3, 1), sd = sample(c(1, 3), 1)) }) mycov <- list(batch = sample(c(0, 1), 10, replace = TRUE)) resx <- cfr_linReg(myexp,mycov) print(myexp[1:5,1:5])#> [,1] [,2] [,3] [,4] [,5] #> [1,] 3.327853 -1.933807 3.214582 -0.2793156 1.3414952 #> [2,] 1.804408 3.096114 6.207055 3.2489682 -0.7878048 #> [3,] 1.989951 3.604186 3.220499 2.8413460 3.1144246 #> [4,] 2.822292 2.778184 -2.487390 1.5423143 2.6529450 #> [5,] 1.192382 -2.589336 7.016897 2.8087686 0.7772838#> [,1] [,2] [,3] [,4] [,5] #> [1,] 3.1903319 -2.0713279 3.077061 -0.4168364 -0.1909669 #> [2,] -2.2191724 -0.9274665 2.183475 -0.7746124 -1.3373517 #> [3,] -0.3577359 1.2564986 0.872812 0.4936587 1.1698603 #> [4,] 1.6939186 1.6498107 -3.615764 0.4139409 0.9326460 #> [5,] -0.9940253 -4.7757435 4.830489 0.6223609 -0.1176258#> [1] 10000 10#> (Intercept) cov #> [1,] 1.5324621 -1.3949413 #> [2,] 0.5495469 3.4740337 #> [3,] 1.9445643 0.4031230 #> [4,] 1.7202990 -0.5919256 #> [5,] 0.8949096 1.2914980 #> [6,] 0.8641718 1.9133033#> (Intercept) cov #> [1,] 0.2912556 0.41455274 #> [2,] 0.6728053 0.04908203 #> [3,] 0.0188698 0.62451397 #> [4,] 0.1057890 0.61397433 #> [5,] 0.5806840 0.50670608 #> [6,] 0.5783433 0.31454629