项目作者: ShixiangWang

项目描述 :
Easily Process a Batch of Cox Models
高级语言: R
项目地址: git://github.com/ShixiangWang/ezcox.git
创建时间: 2019-08-06T09:55:11Z
项目社区:https://github.com/ShixiangWang/ezcox

开源协议:GNU General Public License v3.0

下载


ezcox: Easily Process a Batch of Cox Models

CRAN
status

Hits
R-CMD-check
Lifecycle:
stable

The goal of ezcox is to operate a batch of univariate or multivariate
Cox models and return tidy result.

:arrow_double_down: Installation

You can install the released version of ezcox from
CRAN with:

  1. install.packages("ezcox")

And the development version from GitHub with:

  1. # install.packages("remotes")
  2. remotes::install_github("ShixiangWang/ezcox")

It is possible to install ezcox from Conda conda-forge channel:

  1. conda install r-ezcox --channel conda-forge

Visualization feature of ezcox needs the recent version of
forestmodel, please run the following commands:

  1. remotes::install_github("ShixiangWang/forestmodel")

:beginner: Example

This is a basic example which shows you how to get result from a batch
of cox models.

  1. library(ezcox)
  2. #> Welcome to 'ezcox' package!
  3. #> =======================================================================
  4. #> You are using ezcox version 1.0.2
  5. #>
  6. #> Project home : https://github.com/ShixiangWang/ezcox
  7. #> Documentation: https://shixiangwang.github.io/ezcox
  8. #> Cite as : arXiv:2110.14232
  9. #> =======================================================================
  10. #>
  11. library(survival)
  12. # Build unvariable models
  13. ezcox(lung, covariates = c("age", "sex", "ph.ecog"))
  14. #> => Processing variable age
  15. #> ==> Building Surv object...
  16. #> ==> Building Cox model...
  17. #> ==> Done.
  18. #> => Processing variable sex
  19. #> ==> Building Surv object...
  20. #> ==> Building Cox model...
  21. #> ==> Done.
  22. #> => Processing variable ph.ecog
  23. #> ==> Building Surv object...
  24. #> ==> Building Cox model...
  25. #> ==> Done.
  26. #> # A tibble: 3 × 12
  27. #> Variable is_cont…¹ contr…² ref_l…³ n_con…⁴ n_ref beta HR lower…⁵ upper…⁶
  28. #> <chr> <lgl> <chr> <chr> <int> <int> <dbl> <dbl> <dbl> <dbl>
  29. #> 1 age FALSE age age 228 228 0.0187 1.02 1 1.04
  30. #> 2 sex FALSE sex sex 228 228 -0.531 0.588 0.424 0.816
  31. #> 3 ph.ecog FALSE ph.ecog ph.ecog 227 227 0.476 1.61 1.29 2.01
  32. #> # … with 2 more variables: p.value <dbl>, global.pval <dbl>, and abbreviated
  33. #> # variable names ¹​is_control, ²​contrast_level, ³​ref_level, ⁴​n_contrast,
  34. #> # ⁵​lower_95, ⁶​upper_95
  35. # Build multi-variable models
  36. # Control variable 'age'
  37. ezcox(lung, covariates = c("sex", "ph.ecog"), controls = "age")
  38. #> => Processing variable sex
  39. #> ==> Building Surv object...
  40. #> ==> Building Cox model...
  41. #> ==> Done.
  42. #> => Processing variable ph.ecog
  43. #> ==> Building Surv object...
  44. #> ==> Building Cox model...
  45. #> ==> Done.
  46. #> # A tibble: 4 × 12
  47. #> Variable is_cont…¹ contr…² ref_l…³ n_con…⁴ n_ref beta HR lower…⁵ upper…⁶
  48. #> <chr> <lgl> <chr> <chr> <int> <int> <dbl> <dbl> <dbl> <dbl>
  49. #> 1 sex FALSE sex sex 228 228 -0.513 0.599 0.431 0.831
  50. #> 2 sex TRUE age age 228 228 0.017 1.02 0.999 1.04
  51. #> 3 ph.ecog FALSE ph.ecog ph.ecog 227 227 0.443 1.56 1.24 1.96
  52. #> 4 ph.ecog TRUE age age 228 228 0.0113 1.01 0.993 1.03
  53. #> # … with 2 more variables: p.value <dbl>, global.pval <dbl>, and abbreviated
  54. #> # variable names ¹​is_control, ²​contrast_level, ³​ref_level, ⁴​n_contrast,
  55. #> # ⁵​lower_95, ⁶​upper_95
  1. lung$ph.ecog = factor(lung$ph.ecog)
  2. zz = ezcox(lung, covariates = c("sex", "ph.ecog"), controls = "age", return_models=TRUE)
  3. #> => Processing variable sex
  4. #> ==> Building Surv object...
  5. #> ==> Building Cox model...
  6. #> ==> Done.
  7. #> => Processing variable ph.ecog
  8. #> ==> Building Surv object...
  9. #> ==> Building Cox model...
  10. #> ==> Done.
  11. mds = get_models(zz)
  12. str(mds, max.level = 1)
  13. #> List of 2
  14. #> $ Surv ~ sex + age :List of 19
  15. #> ..- attr(*, "class")= chr "coxph"
  16. #> ..- attr(*, "Variable")= chr "sex"
  17. #> $ Surv ~ ph.ecog + age:List of 22
  18. #> ..- attr(*, "class")= chr "coxph"
  19. #> ..- attr(*, "Variable")= chr "ph.ecog"
  20. #> - attr(*, "class")= chr [1:2] "ezcox_models" "list"
  21. #> - attr(*, "has_control")= logi TRUE
  22. show_models(mds)

:star2: Vignettes

:page_with_curl: Citation

If you are using it in academic research, please cite the preprint
arXiv:2110.14232 along with URL of
this repo.