{"id":20693447,"url":"https://github.com/nanxstats/hdnom","last_synced_at":"2025-05-06T20:05:44.026Z","repository":{"id":35913319,"uuid":"40200701","full_name":"nanxstats/hdnom","owner":"nanxstats","description":"🔮 Benchmarking and visualization toolkit for penalized Cox models","archived":false,"fork":false,"pushed_at":"2024-09-05T18:06:40.000Z","size":29339,"stargazers_count":43,"open_issues_count":1,"forks_count":11,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-06T07:00:29.101Z","etag":null,"topics":["benchmark","high-dimensional-data","linear-regression","nomogram-visualization","penalized-cox-models","survival-analysis"],"latest_commit_sha":null,"homepage":"https://nanx.me/hdnom/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nanxstats.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-08-04T18:05:55.000Z","updated_at":"2025-03-13T22:25:59.000Z","dependencies_parsed_at":"2022-08-26T17:40:20.659Z","dependency_job_id":"e3acf89d-deb7-49ee-a714-82e20c4703e4","html_url":"https://github.com/nanxstats/hdnom","commit_stats":{"total_commits":218,"total_committers":2,"mean_commits":109.0,"dds":"0.041284403669724745","last_synced_commit":"33481d89d23ab4ba5590029cde67a1226a458e44"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanxstats%2Fhdnom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanxstats%2Fhdnom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanxstats%2Fhdnom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanxstats%2Fhdnom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nanxstats","download_url":"https://codeload.github.com/nanxstats/hdnom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252761140,"owners_count":21800124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["benchmark","high-dimensional-data","linear-regression","nomogram-visualization","penalized-cox-models","survival-analysis"],"created_at":"2024-11-16T23:26:44.526Z","updated_at":"2025-05-06T20:05:43.997Z","avatar_url":"https://github.com/nanxstats.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include=FALSE}\nknitr::knit_hooks$set(pngquant = knitr::hook_pngquant)\n\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\",\n  echo = FALSE,\n  message = FALSE,\n  warning = FALSE,\n  dev = \"ragg_png\",\n  dpi = 72,\n  fig.retina = 2,\n  fig.align = \"center\",\n  out.width = \"100%\",\n  pngquant = \"--speed=1 --quality=50\"\n)\n```\n\n# hdnom \u003cimg src=\"man/figures/logo.png\" align=\"right\" width=\"120\" /\u003e\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/nanxstats/hdnom/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/nanxstats/hdnom/actions/workflows/R-CMD-check.yaml)\n[![CRAN Version](https://www.r-pkg.org/badges/version/hdnom)](https://cran.r-project.org/package=hdnom)\n[![Downloads from the RStudio CRAN mirror](https://cranlogs.r-pkg.org/badges/hdnom)](https://cranlogs.r-pkg.org/badges/hdnom)\n\u003c!-- badges: end --\u003e\n\n`hdnom` creates nomogram visualizations for penalized Cox regression models, with the support of reproducible survival model building, validation, calibration, and comparison for high-dimensional data.\n\n## Installation\n\nYou can install `hdnom` from CRAN:\n\n```r\ninstall.packages(\"hdnom\")\n```\n\nOr try the development version on GitHub:\n\n```r\nremotes::install_github(\"nanxstats/hdnom\")\n```\n\nBrowse [the vignettes](https://nanx.me/hdnom/articles/) to get started.\n\n## Gallery\n\n### Nomogram\n\n```{r, nomogram, fig.width=10, fig.height=6}\nlibrary(\"hdnom\")\nlibrary(\"survival\")\nlibrary(\"gridExtra\")\nlibrary(\"cowplot\")\nlibrary(\"ggplot2\")\n\ndata(smart)\n\nx \u003c- as.matrix(smart[, -c(1, 2)])\ntime \u003c- smart$TEVENT\nevent \u003c- smart$EVENT\ny \u003c- Surv(time, event)\n\n# Fit penalized Cox model with lasso penalty\nlassofit \u003c- fit_lasso(x, y, nfolds = 10, rule = \"lambda.1se\", seed = 11)\n\n# Plot nomogram\nnom \u003c- as_nomogram(\n  lassofit, x, time, event,\n  pred.at = 365 * 2,\n  funlabel = \"2-Year Overall Survival Probability\"\n)\n\nplot(nom)\n```\n\n### Kaplan-Meier plot with number at risk table\n\n```{r, kmplot, fig.width=10, fig.height=6}\n# Internal calibration\ncal.int \u003c- calibrate(\n  x, time, event,\n  model.type = \"lasso\",\n  alpha = 1, lambda = lassofit$\"lambda\",\n  method = \"repeated.cv\", nfolds = 10, rep.times = 20,\n  pred.at = 365 * 9, ngroup = 3,\n  trace = FALSE\n)\n\nkmplot(\n  cal.int,\n  group.name = c(\"High risk\", \"Medium risk\", \"Low risk\"),\n  time.at = 1:8 * 365\n)\n```\n\n### Model validation and calibration\n\n```{r, model-validation-calibration, fig.width=15, fig.height=6}\nx \u003c- as.matrix(smart[, -c(1, 2)])[1:500, ]\ntime \u003c- smart$TEVENT[1:500]\nevent \u003c- smart$EVENT[1:500]\ny \u003c- Surv(time, event)\n\n# Fit penalized Cox model\nlassofit \u003c- fit_lasso(x, y, nfolds = 5, rule = \"lambda.1se\", seed = 11)\n\n# Model validation by repeated cross-validation with time-dependent AUC\nval.repcv \u003c- validate(\n  x, time, event,\n  model.type = \"lasso\",\n  alpha = 1, lambda = lassofit$\"lambda\",\n  method = \"repeated.cv\", nfolds = 5, rep.times = 20,\n  tauc.type = \"UNO\", tauc.time = seq(0.5, 2, 0.25) * 365,\n  seed = 1010,\n  trace = FALSE\n)\n\n# Model calibration by repeated cross-validation\ncal.repcv \u003c- calibrate(\n  x, time, event,\n  model.type = \"lasso\",\n  alpha = 1, lambda = lassofit$\"lambda\",\n  method = \"repeated.cv\", nfolds = 10, rep.times = 20,\n  pred.at = 365 * 9, ngroup = 5,\n  seed = 1010,\n  trace = FALSE\n)\n\ninvisible(capture.output(\n  p1 \u003c- plot(val.repcv, ylim = c(0.3, 0.9)) +\n    theme_cowplot()\n))\ninvisible(capture.output(\n  p2 \u003c- plot(cal.repcv) +\n    theme_cowplot()\n))\n\ngrid.arrange(p1, p2, ncol = 2)\n```\n\n### Model comparison by validation or calibration\n\n```{r, model-comparison, fig.width=15, fig.height=6}\n# Compare lasso and adaptive lasso by 5-fold cross-validation\ncmp.val.cv \u003c- compare_by_validate(\n  x, time, event,\n  model.type = c(\"lasso\", \"alasso\"),\n  method = \"repeated.cv\", nfolds = 10, rep.times = 20,\n  tauc.type = \"UNO\",\n  tauc.time = seq(1, 4, 0.5) * 365, seed = 1001,\n  trace = FALSE\n)\n\n# Compare lasso and adaptive lasso by 5-fold cross-validation\ncmp.cal.cv \u003c- compare_by_calibrate(\n  x, time, event,\n  model.type = c(\"lasso\", \"alasso\"),\n  method = \"fitting\",\n  pred.at = 365 * 9, ngroup = 5, seed = 1001,\n  trace = FALSE\n)\n\ninvisible(capture.output(\n  p3 \u003c- plot(cmp.val.cv, interval = TRUE) +\n    theme_cowplot() +\n    theme(legend.position = \"bottom\")\n))\ninvisible(capture.output(\n  p4 \u003c- plot(cmp.cal.cv) +\n    theme_cowplot() +\n    theme(legend.position = \"bottom\")\n))\n\ngrid.arrange(p3, p4, ncol = 2)\n```\n\n## Shiny app\n\n- Shiny app: \u003chttps://github.com/nanxstats/hdnom-app\u003e\n- Shiny app maker: \u003chttps://github.com/nanxstats/hdnom-appmaker\u003e\n\n## Contribute\n\nTo contribute to this project, please take a look at the\n[Contributing Guidelines](https://nanx.me/hdnom/CONTRIBUTING.html) first.\nPlease note that the hdnom project is released with a\n[Contributor Code of Conduct](https://nanx.me/hdnom/CODE_OF_CONDUCT.html).\nBy contributing to this project, you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnanxstats%2Fhdnom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnanxstats%2Fhdnom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnanxstats%2Fhdnom/lists"}