Skip to contents

Fits L0-penalized regression (with optional L1/L2 components) on the RSS objective, searching over a shrinkage grid s and lambda0 path. Model selection uses LD-quadratic pseudovalidation by default.

Usage

l0learnRssWeights(
  stat,
  ldReference,
  penalty = c("L0", "L0L1", "L0L2"),
  s = c(0.2, 0.5, 0.9, 1),
  lambda0 = exp(seq(log(0.001), log(1), length.out = 10)),
  lambda = NULL,
  lambda2 = 0,
  selection = c("ldQuadratic", "minFbeta"),
  maxSwaps = 100,
  fitRetention = c("none", "slim", "full"),
  methodArgs = PenalizedRssOptions()
)

Arguments

stat

A list of summary statistics: n (per-variant sample sizes) and the marginal effects as cor (standardized), z, b with seb, or b alone, taken as already standardized. The engine receives the standardized effects z / sqrt(n), with n the median of n.

ldReference

The LD reference the statistics' variants are matched to by stat$variantNames: a genotype panel (see readGenotypes), a GenotypeMixture or an LdMatrix. A genotype reference's LD is used through its standardized genotypes, never formed as a matrix.

penalty

L0 variant: "L0", "L0L1", or "L0L2". Default "L0".

s

Numeric vector of LD shrinkage parameters. Default: c(0.2, 0.5, 0.9, 1.0).

lambda0

Numeric vector of L0 penalty values to search over. Default: exp(seq(log(0.001), log(1), length.out = 10)).

lambda

Numeric vector of L1 penalty values (for L0L1). Default: c(0) (no L1 unless L0L1 is used).

lambda2

L2 penalty weight (for L0L2). Default 0.

selection

Selection strategy: "ldQuadratic" (default) or "minFbeta".

maxSwaps

Maximum swap rounds per lambda. Default 100.

fitRetention

How much of the search is kept as the "fit" attribute of the returned weights. "none" (default) attaches nothing. "slim" keeps path, a table with one row per candidate (s, lambda0, lambda) giving the solver's objective fbeta, loss, convergence flag conv and number of non-zero coefficients nparams, with selected marking the candidate returned. "full" also keeps beta, the candidates' coefficients (variants x candidates, in the rows' order).

methodArgs

Options forwarded to the solver, penalizedRss, built with PenalizedRssOptions. A bare list is refused: it cannot be checked against the engine, so a misspelled option would be silently ignored.

Value

A numeric vector of SNP coefficient weights. Unless fitRetention = "none", the search is attached as attribute "fit".

Details

The swap optimization from L0Learn is included: after coordinate descent converges, non-zero coefficients are tested for swaps with zero ones to escape local optima.

Examples

data(eqtlRegionExample)
X <- eqtlRegionExample$X[, 1:30]
y <- eqtlRegionExample$yRes
ss <- lapply(
  seq_len(ncol(X)), function(j) coef(summary(lm(y ~ X[, j])))[2, 1:2])
stat <- list(
  b = vapply(ss, `[`, numeric(1), 1L),
  seb = vapply(ss, `[`, numeric(1), 2L),
  n = rep(nrow(X), ncol(X)),
  variantNames = colnames(X)
)
l0learnRssWeights(stat, LdMatrix(cor(X)))
#>  [1] -0.08905530  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000
#>  [7]  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000 -0.06017384
#> [13]  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000
#> [19]  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000
#> [25]  0.00000000  0.00000000 -0.12434615  0.00000000  0.06731129  0.00000000
#> attr(,"penalized_rss_selection")
#>          mode         index       penalty             s       lambda0 
#> "ldQuadratic"           "1"          "L0"         "0.2"       "0.001" 
#>        lambda 
#>           "0"