hdnom

🔮 Benchmarking and visualization toolkit for penalized Cox models

https://github.com/nanxstats/hdnom

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • â—‹
    CITATION.cff file
  • ✓
    codemeta.json file
    Found codemeta.json file
  • ✓
    .zenodo.json file
    Found .zenodo.json file
  • â—‹
    DOI references
  • â—‹
    Academic publication links
  • â—‹
    Committers with academic emails
  • â—‹
    Institutional organization owner
  • â—‹
    JOSS paper metadata
  • â—‹
    Scientific vocabulary similarity
    Low similarity (15.1%) to scientific vocabulary

Keywords

benchmark high-dimensional-data linear-regression nomogram-visualization penalized-cox-models survival-analysis
Last synced: 6 months ago · JSON representation

Repository

🔮 Benchmarking and visualization toolkit for penalized Cox models

Basic Info
  • Host: GitHub
  • Owner: nanxstats
  • License: gpl-3.0
  • Language: R
  • Default Branch: master
  • Homepage: https://nanx.me/hdnom/
  • Size: 30.4 MB
Statistics
  • Stars: 44
  • Watchers: 7
  • Forks: 11
  • Open Issues: 1
  • Releases: 14
Topics
benchmark high-dimensional-data linear-regression nomogram-visualization penalized-cox-models survival-analysis
Created over 10 years ago · Last pushed 9 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct

README.Rmd

---
output: github_document
---



```{r, include=FALSE}
knitr::knit_hooks$set(pngquant = knitr::hook_pngquant)

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%",
  echo = FALSE,
  message = FALSE,
  warning = FALSE,
  dev = "ragg_png",
  dpi = 72,
  fig.retina = 2,
  fig.align = "center",
  out.width = "100%",
  pngquant = "--speed=1 --quality=50"
)
```

# hdnom 


[![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)
[![CRAN Version](https://www.r-pkg.org/badges/version/hdnom)](https://cran.r-project.org/package=hdnom)
[![Downloads from the RStudio CRAN mirror](https://cranlogs.r-pkg.org/badges/hdnom)](https://cranlogs.r-pkg.org/badges/hdnom)


`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.

## Installation

You can install `hdnom` from CRAN:

```r
install.packages("hdnom")
```

Or try the development version on GitHub:

```r
remotes::install_github("nanxstats/hdnom")
```

Browse [the vignettes](https://nanx.me/hdnom/articles/) to get started.

## Gallery

### Nomogram

```{r, nomogram, fig.width=10, fig.height=6}
library("hdnom")
library("survival")
library("gridExtra")
library("cowplot")
library("ggplot2")

data(smart)

x <- as.matrix(smart[, -c(1, 2)])
time <- smart$TEVENT
event <- smart$EVENT
y <- Surv(time, event)

# Fit penalized Cox model with lasso penalty
lassofit <- fit_lasso(x, y, nfolds = 10, rule = "lambda.1se", seed = 11)

# Plot nomogram
nom <- as_nomogram(
  lassofit, x, time, event,
  pred.at = 365 * 2,
  funlabel = "2-Year Overall Survival Probability"
)

plot(nom)
```

### Kaplan-Meier plot with number at risk table

```{r, kmplot, fig.width=10, fig.height=6}
# Internal calibration
cal.int <- calibrate(
  x, time, event,
  model.type = "lasso",
  alpha = 1, lambda = lassofit$"lambda",
  method = "repeated.cv", nfolds = 10, rep.times = 20,
  pred.at = 365 * 9, ngroup = 3,
  trace = FALSE
)

kmplot(
  cal.int,
  group.name = c("High risk", "Medium risk", "Low risk"),
  time.at = 1:8 * 365
)
```

### Model validation and calibration

```{r, model-validation-calibration, fig.width=15, fig.height=6}
x <- as.matrix(smart[, -c(1, 2)])[1:500, ]
time <- smart$TEVENT[1:500]
event <- smart$EVENT[1:500]
y <- Surv(time, event)

# Fit penalized Cox model
lassofit <- fit_lasso(x, y, nfolds = 5, rule = "lambda.1se", seed = 11)

# Model validation by repeated cross-validation with time-dependent AUC
val.repcv <- validate(
  x, time, event,
  model.type = "lasso",
  alpha = 1, lambda = lassofit$"lambda",
  method = "repeated.cv", nfolds = 5, rep.times = 20,
  tauc.type = "UNO", tauc.time = seq(0.5, 2, 0.25) * 365,
  seed = 1010,
  trace = FALSE
)

# Model calibration by repeated cross-validation
cal.repcv <- calibrate(
  x, time, event,
  model.type = "lasso",
  alpha = 1, lambda = lassofit$"lambda",
  method = "repeated.cv", nfolds = 10, rep.times = 20,
  pred.at = 365 * 9, ngroup = 5,
  seed = 1010,
  trace = FALSE
)

invisible(capture.output(
  p1 <- plot(val.repcv, ylim = c(0.3, 0.9)) +
    theme_cowplot()
))
invisible(capture.output(
  p2 <- plot(cal.repcv) +
    theme_cowplot()
))

grid.arrange(p1, p2, ncol = 2)
```

### Model comparison by validation or calibration

```{r, model-comparison, fig.width=15, fig.height=6}
# Compare lasso and adaptive lasso by 5-fold cross-validation
cmp.val.cv <- compare_by_validate(
  x, time, event,
  model.type = c("lasso", "alasso"),
  method = "repeated.cv", nfolds = 10, rep.times = 20,
  tauc.type = "UNO",
  tauc.time = seq(1, 4, 0.5) * 365, seed = 1001,
  trace = FALSE
)

# Compare lasso and adaptive lasso by 5-fold cross-validation
cmp.cal.cv <- compare_by_calibrate(
  x, time, event,
  model.type = c("lasso", "alasso"),
  method = "fitting",
  pred.at = 365 * 9, ngroup = 5, seed = 1001,
  trace = FALSE
)

invisible(capture.output(
  p3 <- plot(cmp.val.cv, interval = TRUE) +
    theme_cowplot() +
    theme(legend.position = "bottom")
))
invisible(capture.output(
  p4 <- plot(cmp.cal.cv) +
    theme_cowplot() +
    theme(legend.position = "bottom")
))

grid.arrange(p3, p4, ncol = 2)
```

## Shiny app

- Shiny app: 
- Shiny app maker: 

## Contribute

To contribute to this project, please take a look at the
[Contributing Guidelines](https://nanx.me/hdnom/CONTRIBUTING.html) first.
Please note that the hdnom project is released with a
[Contributor Code of Conduct](https://nanx.me/hdnom/CODE_OF_CONDUCT.html).
By contributing to this project, you agree to abide by its terms.

Owner

  • Name: Nan Xiao
  • Login: nanxstats
  • Kind: user
  • Location: Upper Gwynedd, PA
  • Company: Merck & Co.

Statistician

GitHub Events

Total
  • Issues event: 2
  • Watch event: 4
  • Delete event: 1
  • Issue comment event: 1
  • Push event: 7
  • Pull request event: 3
  • Create event: 1
Last Year
  • Issues event: 2
  • Watch event: 4
  • Delete event: 1
  • Issue comment event: 1
  • Push event: 7
  • Pull request event: 3
  • Create event: 1

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 218
  • Total Committers: 2
  • Avg Commits per committer: 109.0
  • Development Distribution Score (DDS): 0.041
Past Year
  • Commits: 19
  • Committers: 1
  • Avg Commits per committer: 19.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Nan Xiao r****t@g****m 209
selaginella l****r@g****m 9

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 16
  • Total pull requests: 5
  • Average time to close issues: 9 days
  • Average time to close pull requests: 9 minutes
  • Total issue authors: 6
  • Total pull request authors: 1
  • Average comments per issue: 1.19
  • Average comments per pull request: 0.0
  • Merged pull requests: 5
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 4
  • Pull requests: 5
  • Average time to close issues: 3 days
  • Average time to close pull requests: 9 minutes
  • Issue authors: 2
  • Pull request authors: 1
  • Average comments per issue: 0.5
  • Average comments per pull request: 0.0
  • Merged pull requests: 5
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • nanxstats (10)
  • JianGuoZhou3 (3)
  • Bich12 (1)
  • 1511878618 (1)
  • rhobis (1)
  • teigentler (1)
Pull Request Authors
  • nanxstats (9)
Top Labels
Issue Labels
cran (3) enhancement (2)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 324 last-month
  • Total docker downloads: 21,825
  • Total dependent packages: 2
  • Total dependent repositories: 1
  • Total versions: 19
  • Total maintainers: 1
cran.r-project.org: hdnom

Benchmarking and Visualization Toolkit for Penalized Cox Models

  • Versions: 19
  • Dependent Packages: 2
  • Dependent Repositories: 1
  • Downloads: 324 Last month
  • Docker Downloads: 21,825
Rankings
Forks count: 6.8%
Stargazers count: 8.2%
Docker downloads count: 12.6%
Dependent packages count: 13.7%
Average: 14.0%
Downloads: 19.1%
Dependent repos count: 23.9%
Maintainers (1)
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.5.0 depends
  • foreach * imports
  • ggplot2 * imports
  • glmnet * imports
  • gridExtra * imports
  • ncvreg * imports
  • penalized * imports
  • survival * imports
  • doParallel * suggests
  • knitr * suggests
  • rmarkdown * suggests