项目作者: rivas-lab

项目描述 :
Multiresponse time-to-event Cox proportional hazards model - CPU
高级语言: R
项目地址: git://github.com/rivas-lab/multisnpnet-Cox.git
创建时间: 2020-05-05T05:28:01Z
项目社区:https://github.com/rivas-lab/multisnpnet-Cox

开源协议:Other

下载


Multi-snpnet-Cox (mrcox) Efficient Group-Sparse Lasso solver for multi-response Cox model

This package provide functions that solve the following multi-response, group-sparse regularized Cox regression:

equation

Where is the coefficient vector of the kth (out of K) responses, and are the coefficients of the jth variable on the K responses.

For genetics data in PLINK2 format, we provide a screening procedure similar to the one in this paper.

Installation

Currently mrcox only supports linux and 64-bit intel processors. It requires Intel’s Math Kernel Library (MKL). I suspect you can still get it to run on AMD processors but performance could be significantly worse. To install MKL:

  1. Register and download MKL from https://software.intel.com/content/www/us/en/develop/tools/math-kernel-library/choose-download/linux.html
  2. Under Choose Product to Download, select Intel Math Kernel Library for linux
  3. Untar the downloaded file, run ./install.sh. After installation is done, source intel/mkl/bin/mklvars.sh intel64.

You will also need to install the R dependencies of mrcox (Rcpp, RcppEigen).

Additional dependencies for genetics data

  1. zstd(>=1.4.4). It can be built from source or simply available from conda, pip or brew
  2. PLINK2
    1. library(devtools)
    2. install_github("chrchang/plink-ng", subdir="/2.0/cindex")
    3. install_github("chrchang/plink-ng", subdir="/2.0/pgenlibr")

Once dependencies are installed, run the following in R

  1. devtools::install_github("rivas-lab/multisnpnet-Cox")

Example of Usage

  1. library(mrcox)
  2. # Simulate some data
  3. n = 1000
  4. p = 5000
  5. X = matrix(rnorm(n*p), n, p)
  6. y1 = rexp(n) * exp(X %*% rbinom(p, 1, 0.1))
  7. y2 = rexp(n) * exp(X %*% rbinom(p, 1, 0.1))
  8. s1 = rbinom(n, 1, 0.3)
  9. s2 = rbinom(n, 1, 0.3)
  10. y_list = list(y1, y2)
  11. s_list = list(s1, s2)
  12. # Initialize coefficient matrix at 0
  13. B = matrix(0.0, p, 2)
  14. # Compute residual at B
  15. res = get_residual(X, y_list, s_list, B)
  16. # Compute the gradient of B
  17. g = t(X) %*% res
  18. # Get the dual norm and lambda sequence
  19. alpha = sqrt(2)
  20. dnorm = get_dual_norm(g, alpha)
  21. lambda_max = max(dnorm)
  22. lambda_min = 0.001 * lambda_max
  23. lambda_seq = exp(seq(from = log(lambda_max), to = log(lambda_min), length.out = 100))
  24. # Fit a model
  25. fit = solve_aligned(X, y_list, s_list, lambda_seq, lambda_seq * alpha)
  26. fit = fit[['result']] # fit also contains the residuals at each solution