{"id":21310442,"url":"https://github.com/ocbe-uio/bayessurvive","last_synced_at":"2025-03-15T20:28:29.574Z","repository":{"id":234570274,"uuid":"789160675","full_name":"ocbe-uio/BayesSurvive","owner":"ocbe-uio","description":"Bayesian survival models for high-dimensional data","archived":false,"fork":false,"pushed_at":"2024-04-20T15:58:39.000Z","size":925,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-20T21:39:03.576Z","etag":null,"topics":["bayesian-cox-models","bayesian-variable-selection","graph-learning","high-dimensional-statistics","omics-data-integration","survival-analysis"],"latest_commit_sha":null,"homepage":"","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/ocbe-uio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-04-19T20:28:56.000Z","updated_at":"2024-04-23T21:12:33.513Z","dependencies_parsed_at":"2024-04-23T21:12:29.167Z","dependency_job_id":"b08ae2f2-60ab-44f4-9a6b-ac82798fa178","html_url":"https://github.com/ocbe-uio/BayesSurvive","commit_stats":null,"previous_names":["ocbe-uio/bayessurvive"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocbe-uio%2FBayesSurvive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocbe-uio%2FBayesSurvive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocbe-uio%2FBayesSurvive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocbe-uio%2FBayesSurvive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ocbe-uio","download_url":"https://codeload.github.com/ocbe-uio/BayesSurvive/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243789855,"owners_count":20348304,"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":["bayesian-cox-models","bayesian-variable-selection","graph-learning","high-dimensional-statistics","omics-data-integration","survival-analysis"],"created_at":"2024-11-21T17:13:34.121Z","updated_at":"2025-03-15T20:28:29.521Z","avatar_url":"https://github.com/ocbe-uio.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BayesSurvive\n\n[![CRAN\nstatus](https://www.r-pkg.org/badges/version/BayesSurvive)](https://cran.r-project.org/package=BayesSurvive)\n[![r-universe](https://ocbe-uio.r-universe.dev/badges/BayesSurvive)](https://ocbe-uio.r-universe.dev/BayesSurvive)\n[![R-CMD-check](https://github.com/ocbe-uio/BayesSurvive/workflows/R-CMD-check/badge.svg)](https://github.com/ocbe-uio/BayesSurvive/actions)\n[![License](https://img.shields.io/badge/License-GPLv3-brightgreen.svg)](https://www.gnu.org/licenses/gpl-3.0)\n[![DOI](https://img.shields.io/badge/doi-10.32614%2FCRAN.package.BayesSurvive-brightgreen)](https://doi.org/10.32614/CRAN.package.BayesSurvive)\n\n\nThis is a R/Rcpp package **BayesSurvive** for Bayesian survival models with graph-structured selection priors for sparse identification of high-dimensional features predictive of survival ([Madjar et al., 2021](https://bmcbioinformatics.biomedcentral.com/articles/10.1186/s12859-021-04483-z)) (see the three models of the first column in the table below) and its extensions with the use of a fixed graph via a Markov Random Field (MRF) prior for capturing known structure of high-dimensional features (see the three models of the second column in the table below), e.g. disease-specific pathways from the Kyoto Encyclopedia of Genes and Genomes (KEGG) database.\n\nModel        | Infer `MRF_G` | Fix `MRF_G`\n------------:| --------------|---------------\n`Pooled`     |        ✔      |           ✔          \n`CoxBVSSL`   |        ✔      |           ✔          \n`Sub-struct` |        ✔      |           ✔          \n\n## Installation\n\nInstall the latest released version from [CRAN](https://CRAN.R-project.org/package=BayesSurvive)\n\n```r\ninstall.packages(\"BayesSurvive\")\n```\n\nInstall the latest development version from [GitHub](https://github.com/ocbe-uio/BayesSurvive)\n\n```r\n#install.packages(\"remotes\")\nremotes::install_github(\"ocbe-uio/BayesSurvive\")\n```\n\n\n## Examples\n\n### Simulate data\n\n```r\nlibrary(\"BayesSurvive\")\n# Load the example dataset\ndata(\"simData\", package = \"BayesSurvive\")\ndataset = list(\"X\" = simData[[1]]$X, \n               \"t\" = simData[[1]]$time,\n               \"di\" = simData[[1]]$status)\n```\n\n### Run a Bayesian Cox model\n\n```r\n## Initial value: null model without covariates\ninitial = list(\"gamma.ini\" = rep(0, ncol(dataset$X)))\n# Prior parameters\nhyperparPooled = list(\n  \"c0\"     = 2,                      # prior of baseline hazard\n  \"tau\"    = 0.0375,                 # sd (spike) for coefficient prior\n  \"cb\"     = 20,                     # sd (slab) for coefficient prior\n  \"pi.ga\"  = 0.02,                   # prior variable selection probability for standard Cox models\n  \"a\"      = -4,                     # hyperparameter in MRF prior\n  \"b\"      = 0.1,                    # hyperparameter in MRF prior\n  \"G\"      = simData$G               # hyperparameter in MRF prior\n)   \n\n## run Bayesian Cox with graph-structured priors\nset.seed(123)\nfit \u003c- BayesSurvive(survObj = dataset, model.type = \"Pooled\", MRF.G = TRUE, \n                    hyperpar = hyperparPooled, initial = initial, \n                    nIter = 200, burnin = 100)\n\n## show posterior mean of coefficients and 95% credible intervals\nlibrary(\"GGally\")\nplot(fit) + \n  coord_flip() + \n  theme(axis.text.x = element_text(angle = 90, size = 7))\n```\n\n\u003cimg src=\"man/figures/README_plot_beta.png\" width=\"130%\" /\u003e\n\nShow the index of selected variables by controlling Bayesian false discovery rate (FDR) at the level $\\alpha = 0.05$\n\n```r\nwhich( VS(fit, method = \"FDR\", threshold = 0.05) )\n```\n```\n#[1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15 194\n```\n\n### Plot time-dependent Brier scores\n\nThe function `BayesSurvive::plotBrier()` can show the time-dependent Brier scores based on posterior mean of coefficients or Bayesian model averaging.\n\n```r\nplotBrier(fit, survObj.new = dataset)\n```\n\n\u003cimg src=\"man/figures/README_plot_brier.png\" width=\"50%\" /\u003e\n\nWe can also use the function `BayesSurvive::predict()` to obtain the Brier score at time 8.5, the integrated Brier score (IBS) from time 0 to 8.5 and the index of prediction accuracy (IPA).\n\n```r\npredict(fit, survObj.new = dataset, times = 8.5)\n```\n```{ .text .no-copy }\n##               Brier(t=8.5) IBS(t:0~8.5) IPA(t=8.5)\n## Null.model      0.2290318   0.08185316  0.0000000\n## Bayesian.Cox    0.1013692   0.02823275  0.5574011\n```\n\n### Predict survival probabilities and cumulative hazards\n\nThe function `BayesSurvive::predict()` can estimate the survival probabilities and cumulative hazards.\n\n```r\npredict(fit, survObj.new = dataset, type = c(\"cumhazard\", \"survival\"))\n```\n```{ .text .no-copy }\n#        observation times cumhazard  survival\n##              \u003cint\u003e \u003cnum\u003e     \u003cnum\u003e     \u003cnum\u003e\n##     1:           1   3.3  7.41e-05  1.00e+00\n##     2:           2   3.3  2.51e-01  7.78e-01\n##     3:           3   3.3  9.97e-07  1.00e+00\n##     4:           4   3.3  1.84e-03  9.98e-01\n##     5:           5   3.3  3.15e-04  1.00e+00\n##    ---                                      \n##  9996:          96   9.5  7.15e+00  7.88e-04\n##  9997:          97   9.5  3.92e+02 7.59e-171\n##  9998:          98   9.5  2.81e+00  6.02e-02\n##  9999:          99   9.5  3.12e+00  4.42e-02\n## 10000:         100   9.5  1.97e+01  2.79e-09\n```\n\n### Run a 'Pooled' Bayesian Cox model with graphical learning\n\n```r\nhyperparPooled \u003c- append(hyperparPooled, list(\"lambda\" = 3, \"nu0\" = 0.05, \"nu1\" = 5))\nfit2 \u003c- BayesSurvive(survObj = list(dataset), model.type = \"Pooled\", MRF.G = FALSE,\n                     hyperpar = hyperparPooled, initial = initial, nIter = 10)\n```\n\n### Run a Bayesian Cox model with subgroups using fixed graph \n\n```r\n# specify a fixed joint graph between two subgroups\nhyperparPooled$G \u003c- Matrix::bdiag(simData$G, simData$G)\ndataset2 \u003c- simData[1:2]\ndataset2 \u003c- lapply(dataset2, setNames, c(\"X\", \"t\", \"di\", \"X.unsc\", \"trueB\"))\nfit3 \u003c- BayesSurvive(survObj = dataset2, \n                     hyperpar = hyperparPooled, initial = initial, \n                     model.type=\"CoxBVSSL\", MRF.G = TRUE, \n                     nIter = 10, burnin = 5)\n```\n\n### Run a Bayesian Cox model with subgroups using graphical learning\n\n```r\nfit4 \u003c- BayesSurvive(survObj = dataset2, \n                     hyperpar = hyperparPooled, initial = initial, \n                     model.type=\"CoxBVSSL\", MRF.G = FALSE, \n                     nIter = 3, burnin = 0)\n```\n\n## References\n\n\u003e Zhi Zhao, Katrin Madjar, Tobias Østmo Hermansen (2024).\n\u003e BayesSurvive: Bayesian Survival Models for High-Dimensional Data.\n\u003e _R package version 0.0.2_. DOI: [10.32614/CRAN.package.BayesSurvive](https://doi.org/10.32614/CRAN.package.BayesSurvive).\n\n\u003e Katrin Madjar, Manuela Zucknick, Katja Ickstadt, Jörg Rahnenführer (2021).\n\u003e Combining heterogeneous subgroups with graph‐structured variable selection priors for Cox regression.\n\u003e _BMC Bioinformatics_, 22(1):586. DOI: [10.1186/s12859-021-04483-z](https://bmcbioinformatics.biomedcentral.com/articles/10.1186/s12859-021-04483-z).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focbe-uio%2Fbayessurvive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Focbe-uio%2Fbayessurvive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focbe-uio%2Fbayessurvive/lists"}