Skip to content

Commit

Permalink
version 2.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
zhizuio authored and cran-robot committed Dec 9, 2023
1 parent 0e42d7e commit 4d1c116
Show file tree
Hide file tree
Showing 32 changed files with 1,903 additions and 650 deletions.
13 changes: 8 additions & 5 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: psbcSpeedUp
Title: Penalized Semiparametric Bayesian Cox Models
Version: 2.0.4
Date: 2023-10-12
Version: 2.0.5
Date: 2023-12-08
URL: https://github.com/ocbe-uio/psbcSpeedUp
BugReports: https://github.com/ocbe-uio/psbcSpeedUp/issues
Authors@R: c(person("Zhi", "Zhao", role=c("aut","cre"), email = "zhi.zhao@medisin.uio.no"),
Expand All @@ -13,18 +13,21 @@ License: GPL-3
Copyright: The C++ files pugixml.cpp, pugixml.h and pugiconfig.h are
with Copyright (C) 2006-2018 Arseny Kapoulkine and Copyright
(C) 2003 Kristen Wegner.
VignetteBuilder: knitr
Depends: R (>= 4.0)
Encoding: UTF-8
RoxygenNote: 7.2.3
LinkingTo: Rcpp, RcppArmadillo (>= 0.9.000)
Imports: Rcpp, xml2, ggplot2, GGally, MASS, utils, stats
Imports: Rcpp, xml2, ggplot2, GGally, MASS, survival, riskRegression,
utils, stats
Suggests: knitr
LazyData: true
NeedsCompilation: yes
Packaged: 2023-10-12 14:26:35 UTC; zhiz
Packaged: 2023-12-08 13:29:37 UTC; zhiz
Author: Zhi Zhao [aut, cre],
Manuela Zucknick [aut],
Maral Saadati [aut],
Axel Benner [aut]
Maintainer: Zhi Zhao <zhi.zhao@medisin.uio.no>
Repository: CRAN
Date/Publication: 2023-10-12 14:50:02 UTC
Date/Publication: 2023-12-08 14:00:02 UTC
51 changes: 30 additions & 21 deletions MD5
@@ -1,35 +1,44 @@
1868650e39faca1f5dedc86c07805b25 *DESCRIPTION
54e2e2200e0daa66e9280c35d1b4000b *NAMESPACE
ea197f74ec3c62ca7e62a4e0138bd1de *NEWS.md
2100e91bb0b3d40e8dab72338c31364e *DESCRIPTION
528177306a09bb4b73a2d277e4774f41 *NAMESPACE
589656534e41b8049f499f8588b24cb7 *NEWS.md
7ae1823500df61c6e97cd9c55c9887ee *R/RcppExports.R
17c06d2717a04d99091398ebdaba248e *R/coef.psbcSpeedUp.R
e72d4c8e2051f1c3b28f183877177cfa *R/coef.psbcSpeedUp.R
c0dd2e03b926a0d3c5ee44898121cfbe *R/exampleData.R
8f6d5a01629e0114c94b6a40b5effb50 *R/plot.psbcSpeedUp.R
3eaa3a18e170d678eae4987cd3b853de *R/psbcSpeedUp.R
4942867172878bba53688412bd604ec3 *README.md
6dbf181478c9ac518bb19a51aabfd071 *cleanup
705a0e2e69bd51f57ba3946767b27d3e *R/plot.psbcSpeedUp.R
2d4e430e28f76e8f8ecf4e559f4e27ba *R/plotBrier.R
ad667492d82cfeb09de126ff0ef00df9 *R/predict.psbcSpeedUp.R
0f897c98dfb5e258207f57b477748efc *R/psbcSpeedUp.R
bb43106f8e2b174e93d6b5be3258e87c *README.md
f5f1417afaaf64682000372990355e1c *build/vignette.rds
7b46749938e49991ac03f0fec0dd825b *cleanup
b10b1d4c04f04e9373c3ca9fb70f160f *configure
b7870d69722ee15726af3d1b9a503c8a *configure.ac
f91c2ee39ced0e6e91f98b81e9344f11 *data/datalist
7b548c9bd6a373f888b1abd5f788be24 *data/exampleData.rda
d5bf793431394a60bbbb8c177199a114 *man/coef.psbcSpeedUp.Rd
8f9e9b60cc3d91d8587aac05992e1578 *inst/doc/BayesCox.R
c9b3cf22cbf9c151eff3cd5138214bb3 *inst/doc/BayesCox.Rmd
c1714fc32357cecdc7b9a25dbd310495 *inst/doc/BayesCox.html
c71ddfcaa90c21b64cbff740de7f58e1 *man/coef.psbcSpeedUp.Rd
ceb1aaadfdec68603d5cc77d5f796051 *man/exampleData.Rd
198b70412d51b344f358c6bdf480f5c7 *man/figures/README_plot_beta.png
c060bdd050536703a862d7643828f59a *man/plot.psbcSpeedUp.Rd
ace731c93dee9955cd42e9c1945af37e *man/psbcSpeedUp.Rd
9d60f8c028133fa5c6a3cd284e1e00ed *man/figures/README_plot_brier.png
335479598736f774954c56b098dfc737 *man/plot.psbcSpeedUp.Rd
09fec13c66ae23170a78f21c5cf5b2e9 *man/plotBrier.Rd
26494214e06876cf942b75ecfde81728 *man/predict.psbcSpeedUp.Rd
7dc417e48efb39b297c96a458967937f *man/psbcSpeedUp.Rd
2a825488988b01ee93aea8f884fc9070 *src/Makevars.in
83488be6b1f2f015234720a0a25ff076 *src/Makevars.win
4c38a99ae49306c08d6798a2b4c21dbc *src/RcppExports.cpp
d41d8cd98f00b204e9800998ecf8427e *src/drive-e758d6e6.o.tmp
488b8a39ebc55e50d4decc286f6b7995 *src/drive.cpp
15069450d96221dda3b547bae245aaeb *src/drive.h
ca89b29337087802b658b063fcedf3b1 *src/global.cpp
fcc63ff239f7e16106ebff3b268e81a8 *src/global.h
185e7e0d65856fa49943cb9e87e28875 *src/init.c
6441a235e47e5cf4fde31c3ff81cc10c *src/psbc.cpp
73b9016725850b3dab1e3bdce00e846d *src/psbc.h
a208ba9b0b9b6953dd665b516eba303d *src/drive.cpp
a4d019b89b1606ffd530751c1e640f63 *src/drive.h
99fa8dc58ea0ffc37d1e6e5e2e51d378 *src/global.cpp
05ad67a54a213f89504a68cc7a253f86 *src/global.h
cc174f5cdd978352648cec44c0919628 *src/init.c
b3fe30bb06c10bed689613b6c0d7c82c *src/psbc.cpp
ca15a2e754117b535063fb35585ad1ca *src/psbc.h
63fb7f837f5ead3567c138071d25469d *src/pugiconfig.h
2a482565cd695663ed7426f6302af0ae *src/pugixml.cpp
654ec0ae83f4bc6dcdd26c633cb4ee08 *src/pugixml.h
e07acc941971e653481244878da70084 *src/utils.cpp
89b7b0a35fd94e7bdec8f425188492eb *src/utils.h
ed81f47ae1fcab8a9c33b71a53ed8f81 *src/utils.cpp
ab4382c863ccfbb58cef66a0bb024c33 *src/utils.h
c9b3cf22cbf9c151eff3cd5138214bb3 *vignettes/BayesCox.Rmd
12 changes: 12 additions & 0 deletions NAMESPACE
Expand Up @@ -2,16 +2,28 @@

S3method(coef,psbcSpeedUp)
S3method(plot,psbcSpeedUp)
S3method(predict,psbcSpeedUp)
export(plotBrier)
export(psbcSpeedUp)
importFrom(GGally,ggcoef)
importFrom(MASS,mvrnorm)
importFrom(Rcpp,evalCpp)
importFrom(ggplot2,aes)
importFrom(ggplot2,element_blank)
importFrom(ggplot2,geom_step)
importFrom(ggplot2,ggplot)
importFrom(ggplot2,theme)
importFrom(ggplot2,xlab)
importFrom(ggplot2,ylab)
importFrom(riskRegression,Score)
importFrom(riskRegression,predictCox)
importFrom(stats,quantile)
importFrom(stats,rexp)
importFrom(stats,rgamma)
importFrom(stats,runif)
importFrom(survival,Surv)
importFrom(survival,coxph)
importFrom(utils,read.table)
importFrom(utils,write.table)
importFrom(xml2,as_xml_document)
importFrom(xml2,write_xml)
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Expand Up @@ -4,11 +4,15 @@
* remove Rcpp::List object, instead writing all output objects into files
* allow multiple chains and omp for parallelisation
* add R functions for feature (stability) selection
* add R functions for survival predictions
* extend C++ source code for implementing other shrinkage and group priors

# psbcSpeedUp 2.0.5

* Added R functions for survival predictions, e.g. time-dependent Brier scores, integrated Brier score

# psbcSpeedUp 2.0.4

* For Linux machines, installed GitHub v2.0.4 seems twice faster than CRAN v2.0.4 due to `omp_set_*` in drive.cpp to solve CRAN pre-test NOTE `CPU-elapse times ratio`
* Improved C++ code to speedup 10-20%
* Declared functions inside PSBC class
* Added configuration files for checking omp, compilers etc.
Expand Down
9 changes: 5 additions & 4 deletions R/coef.psbcSpeedUp.R
Expand Up @@ -24,11 +24,12 @@
#'
#' # Set hyperparameters
#' mypriorPara <- list(
#' "groupInd" = 1:p, "eta0" = 0.02, "kappa0" = 1, "c0" = 2, "r" = 10 / 9,
#' "delta" = 1e-05, "lambdaSq" = 1, "sigmaSq" = runif(1, 0.1, 10),
#' "beta.prop.var" = 1, "beta.clin.var" = 1)
#' "groupInd" = 1:p, "eta0" = 0.02, "kappa0" = 1, "c0" = 2, "r" = 10 / 9,
#' "delta" = 1e-05, "lambdaSq" = 1, "sigmaSq" = runif(1, 0.1, 10),
#' "beta.prop.var" = 1, "beta.clin.var" = 1
#' )
#'
#'\donttest{
#' \donttest{
#' # run Bayesian Lasso Cox
#' library("psbcSpeedUp")
#' set.seed(123)
Expand Down
15 changes: 8 additions & 7 deletions R/plot.psbcSpeedUp.R
Expand Up @@ -28,11 +28,12 @@
#'
#' # Set hyperparameters
#' mypriorPara <- list(
#' "groupInd" = 1:p, "eta0" = 0.02, "kappa0" = 1, "c0" = 2, "r" = 10 / 9,
#' "delta" = 1e-05, "lambdaSq" = 1, "sigmaSq" = runif(1, 0.1, 10),
#' "beta.prop.var" = 1, "beta.clin.var" = 1)
#' "groupInd" = 1:p, "eta0" = 0.02, "kappa0" = 1, "c0" = 2, "r" = 10 / 9,
#' "delta" = 1e-05, "lambdaSq" = 1, "sigmaSq" = runif(1, 0.1, 10),
#' "beta.prop.var" = 1, "beta.clin.var" = 1
#' )
#'
#'\donttest{
#' \donttest{
#' # run Bayesian Lasso Cox
#' library("psbcSpeedUp")
#' set.seed(123)
Expand All @@ -45,7 +46,7 @@
#'
#' @export
plot.psbcSpeedUp <- function(x, type = "mean", interval = TRUE, ...) {
if (!(inherits(x, "psbcSpeedUp") | is.matrix(x))) {
if (!(inherits(x, "psbcSpeedUp") || is.matrix(x))) {
stop("Use only with 'psbcSpeedUp' object or a matrix!")
}

Expand All @@ -63,14 +64,14 @@ plot.psbcSpeedUp <- function(x, type = "mean", interval = TRUE, ...) {

if (inherits(x, "psbcSpeedUp")) {
if (is.null(colnames(x$output$beta.p))) {
x_names <- paste0("x", 1:ncol(x$output$beta.p))
x_names <- paste0("x", seq_len(ncol(x$output$beta.p)))
} else {
x_names <- colnames(x$output$beta.p)
}
beta_p <- x$output$beta.p[-(1:(x$input$burnin / x$input$thin + 1)), ]
} else {
if (is.null(colnames(x))) {
x_names <- paste0("x", 1:ncol(x))
x_names <- paste0("x", seq_len(ncol(x)))
} else {
x_names <- colnames(x)
}
Expand Down
64 changes: 64 additions & 0 deletions R/plotBrier.R
@@ -0,0 +1,64 @@
#' psbcSpeedUp
#'
#' @title Time-dependent Brier scores
#'
#' @description
#' Predict time-dependent Brier scores based on Cox regression models
#'
#' @name plotBrier
#'
#' @importFrom ggplot2 ggplot aes geom_step theme element_blank
#'
#' @param object fitted object obtained with \code{psbcSpeedUp}
#' @param survObj.new a list containing observed data from new subjects with
#' components \code{t}, \code{di}, \code{x}. If \code{NULL}, the prediction is
#' based on the training data
#' @param times maximum time point to evaluate the prediction
#' @param method option to use the posterior mean (\code{"mean"}) of coefficients
#' for prediction or Bayesian model averaging (\code{"BMA"}) for prediction
#' @param \dots not used
#'
#' @keywords survival
##' @examples
##'
#' # Load the example dataset
#' data("exampleData", package = "psbcSpeedUp")
#' p <- exampleData$p
#' q <- exampleData$q
#' survObj <- exampleData[1:3]
#'
#' # Set hyperparameters
#' mypriorPara <- list(
#' "groupInd" = 1:p, "eta0" = 0.02, "kappa0" = 1, "c0" = 2, "r" = 10 / 9,
#' "delta" = 1e-05, "lambdaSq" = 1, "sigmaSq" = runif(1, 0.1, 10),
#' "beta.prop.var" = 1, "beta.clin.var" = 1)
#'
#' \donttest{
#' # run Bayesian Lasso Cox
#' library("psbcSpeedUp")
#' set.seed(123)
#' fitBayesCox <- psbcSpeedUp(survObj,
#' p = p, q = q, hyperpar = mypriorPara,
#' nIter = 10, burnin = 0, outFilePath = tempdir()
#' )
#' # predict survival probabilities of the train data
#' plotBrier(fitBayesCox, times = 80)
#' }
#'
#' @export
plotBrier <- function(object, survObj.new = NULL,
method = "mean", times = NULL, ...) {

Brier_score <- predict.psbcSpeedUp(object,
survObj.new = survObj.new,
method = method,
times = times)
Brier <- model <- NULL
#Brier_score %>%
ggplot2::ggplot(Brier_score,
aes(times, Brier, group = model, color = model)) +
xlab("Evaluation time points") +
ylab("Brier score") +
geom_step(direction = "vh") +
theme(legend.title = element_blank())
}

0 comments on commit 4d1c116

Please sign in to comment.