Compute TWAS weights via ridge regression (glmnet, alpha = 0)
Source:R/regularizedRegressionWrappers.R
ridgeWeights.RdConvenience wrapper for glmnetWeights with alpha = 0.
Usage
ridgeWeights(
X,
y,
fitRetention = c("none", "slim", "full"),
methodArgs = GlmnetOptions()
)Arguments
- X
Numeric genotype / design matrix (samples x variants).
- y
Numeric response (phenotype) vector of length
nrow(X).- fitRetention
How much of the fit is kept as the
"fit"attribute of the returned weights:"none"(default) attaches nothing;"slim"the selected fit, as a list of its coefficients (coef, over the variants fitted),intercept,lambdaand cross-validated error there (cvm,cvsd);"full"the wholecv.glmnetobject, with everylambda's coefficients. Either names the variants it was fitted on.- methodArgs
Additional arguments forwarded to
glmnet::cv.glmnet, built withGlmnetOptions. A bare list is refused, since it cannot be checked against the engine's formals.
Value
Numeric vector of length ncol(X) of per-variant weights,
with the fit attached as attribute "fit" unless
fitRetention = "none".
Examples
data(eqtlRegionExample)
X <- eqtlRegionExample$X[, 1:30]
y <- eqtlRegionExample$yRes
ridgeWeights(X, y)
#> [,1]
#> [1,] -5.062171e-04
#> [2,] -5.062365e-04
#> [3,] 3.735322e-04
#> [4,] -3.593713e-05
#> [5,] -3.593628e-05
#> [6,] -1.674700e-04
#> [7,] -2.100183e-04
#> [8,] 1.837077e-04
#> [9,] -1.703815e-04
#> [10,] -1.704199e-04
#> [11,] -5.292013e-05
#> [12,] -2.994142e-04
#> [13,] -5.664245e-05
#> [14,] -1.482979e-04
#> [15,] -5.291703e-05
#> [16,] 1.837147e-04
#> [17,] -3.250155e-04
#> [18,] -3.581537e-04
#> [19,] 6.945953e-05
#> [20,] -3.581769e-04
#> [21,] -3.581882e-04
#> [22,] -1.674813e-04
#> [23,] -3.581882e-04
#> [24,] 1.725879e-05
#> [25,] -5.667378e-05
#> [26,] -1.674818e-04
#> [27,] -3.511836e-04
#> [28,] -7.401435e-05
#> [29,] 5.302680e-05
#> [30,] 2.284702e-04