Skip to content

Commit

Permalink
manually merge gpu_cox -> time_varying
Browse files Browse the repository at this point in the history
  • Loading branch information
jianxiaoyang committed Oct 20, 2023
2 parents fee07f5 + d8ceec2 commit 7538e27
Show file tree
Hide file tree
Showing 45 changed files with 3,026 additions and 100 deletions.
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ deprecated
^\.github$
^CRAN-RELEASE$
.covrignore
src/Makevars$
src/Makevars.win$
to_fix*
^CRAN-SUBMISSION$
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ CRAN-RELEASE
.DS_Store
*.gcno
*.gcda
src/Makevars
src/Makevars.win
3 changes: 3 additions & 0 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Version: 3.3.1
Date: 2023-04-09 20:06:33 UTC
SHA: d88c531efa06933c1007cb785343f1382c95ee0d
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: Cyclops
Type: Package
Title: Cyclic Coordinate Descent for Logistic, Poisson and Survival Analysis
Version: 3.2.1
Version: 3.3.1.99
Authors@R: c(
person("Marc A.", "Suchard", email = "msuchard@ucla.edu", role = c("aut","cre")),
person("Martijn J.", "Schuemie", role = "aut"),
Expand All @@ -26,6 +26,7 @@ Description: This model fitting tool incorporates cyclic coordinate descent and
Suchard, Simpson, Zorych, Ryan and Madigan (2013) <doi:10.1145/2414416.2414791>.
License: Apache License 2.0
LazyData: Yes
Biarch: true
URL: https://github.com/ohdsi/cyclops
BugReports: https://github.com/ohdsi/cyclops/issues
Depends:
Expand All @@ -51,4 +52,4 @@ Suggests:
ggplot2,
microbenchmark,
cmprsk
RoxygenNote: 7.1.2
RoxygenNote: 7.2.3
20 changes: 20 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,26 @@ develop
Changes:

1. improvements on adaptive likelihood profiling
2. add `auto` option to `cvRepetitions`
3. bumped explicit C++11 requirement up to R v4.1

Cyclops v3.3.1
==============

Changes:

1. fix uninitialized value in detected in computeAsymptoticPrecisionMatrix(); value was priorType
2. fix memory leak caused by call to ::Rf_error()
3. fix line-endings on Makevar on windows

Cyclops v3.3.0
==============

1. bump for R 4.2
2. fix CRAN warnings
a. used `minValues`
3. fix CRAN notes
a. remove explicit dependence on C++11 (except for R <= 4.0)

Cyclops v3.2.1
==============
Expand All @@ -14,6 +33,7 @@ Changes:
1. fix small memory leak caused by direct call to '::Rf_error()'
2. disable JVM calls on CRAN due to uninitialized memory in Java JVM


Cyclops v3.2.0
==============

Expand Down
6 changes: 6 additions & 0 deletions R/Cyclops-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#' @keywords internal
"_PACKAGE"

## usethis namespace: start
## usethis namespace: end
NULL
20 changes: 19 additions & 1 deletion R/ModelFit.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ fitCyclopsModel <- function(cyclopsData,
writeLines(paste("Using cross-validation selector type", control$selectorType))
}
}

if (control$cvRepetitions == "auto") {
control$cvRepetitions <- .getNumberOfRepetitions(getNumberOfRows(cyclopsData))
}

control <- .setControl(cyclopsData$cyclopsInterfacePtr, control)
threads <- control$threads

Expand All @@ -218,6 +223,7 @@ fitCyclopsModel <- function(cyclopsData,
}

.cyclopsSetBeta(cyclopsData$cyclopsInterfacePtr, startingCoefficients)
.cyclopsSetStartingBeta(cyclopsData$cyclopsInterfacePtr, startingCoefficients)
}

if (!is.null(fixedCoefficients)) {
Expand Down Expand Up @@ -324,6 +330,11 @@ fitCyclopsModel <- function(cyclopsData,
fit$scale <- cyclopsData$scale
fit$threads <- threads
fit$seed <- control$seed

if (prior$useCrossValidation) {
fit$cvRepetitions <- control$cvRepetitions
}

class(fit) <- "cyclopsFit"
return(fit)
}
Expand Down Expand Up @@ -784,7 +795,6 @@ getSEs <- function(object, covariates) {
ses
}


#' @title Run Bootstrap for Cyclops model parameter
#'
#' @param object A fitted Cyclops model object
Expand Down Expand Up @@ -1136,3 +1146,11 @@ convertToGlmnetLambda <- function(variance, nobs) {
graph <- lapply(0:(nParents - 1), function(n, types) { 0:(nTypes - 1) + n * nTypes }, types = nTypes)
graph
}

.getNumberOfRepetitions <- function(nrows) {
top <- 1E2
factor <- 0.5
pmax(pmin(
ceiling(top / nrows^(factor))
, 10), 1)
}
12 changes: 12 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,22 @@
invisible(.Call(`_Cyclops_cyclopsSetBeta`, inRcppCcdInterface, beta))
}

.cyclopsGetBeta <- function(inRcppCcdInterface, index) {
.Call(`_Cyclops_cyclopsGetBeta`, inRcppCcdInterface, index)
}

.cyclopsSetStartingBeta <- function(inRcppCcdInterface, inStartingBeta) {
invisible(.Call(`_Cyclops_cyclopsSetStartingBeta`, inRcppCcdInterface, inStartingBeta))
}

.cyclopsSetFixedBeta <- function(inRcppCcdInterface, beta, fixed) {
invisible(.Call(`_Cyclops_cyclopsSetFixedBeta`, inRcppCcdInterface, beta, fixed))
}

.cyclopsGetFixedBeta <- function(inRcppCcdInterface, index) {
.Call(`_Cyclops_cyclopsGetFixedBeta`, inRcppCcdInterface, index)
}

.cyclopsGetIsRegularized <- function(inRcppCcdInterface, index) {
.Call(`_Cyclops_cyclopsGetIsRegularized`, inRcppCcdInterface, index)
}
Expand Down
6 changes: 4 additions & 2 deletions R/Survfit.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
#' @description
#' \code{survfit.cyclopsFit} computes baseline hazard function
#'
#' @param cyclopsFit A Cyclops survival model fit object
#' @param formula A Cyclops survival model fit object
#' @param type type of baseline survival, choices are: "aalen" (Breslow)
#' @param ... for future methods
#'
#' @return Baseline survival function for mean covariates
#'
#' @importFrom survival survfit
#'
#' @export
survfit.cyclopsFit <- function(cyclopsFit, type="aalen") {
survfit.cyclopsFit <- function(formula, type="aalen", ...) {
cyclopsFit <- formula
delta = meanLinearPredictor(cyclopsFit)

times = getTimeVector(cyclopsFit$cyclopsData)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Cyclops
=======

[![Build Status](https://github.com/ohdsi/Cyclops/workflows/R-CMD-check/badge.svg)](https://github.com/OHDSI/Cyclops/actions?query=workflow%3AR-CMD-check)
[![codecov.io](https://codecov.io/github/OHDSI/Cyclops/coverage.svg?branch=main)](https://codecov.io/github/OHDSI/Cyclops?branch=main)
[![codecov.io](https://app.codecov.io/github/OHDSI/Cyclops/coverage.svg?branch=main)](https://app.codecov.io/github/OHDSI/Cyclops?branch=main)
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/Cyclops)](https://CRAN.R-project.org/package=Cyclops)
[![CRAN_Status_Badge](https://cranlogs.r-pkg.org/badges/Cyclops)](https://cran.r-project.org/package=Cyclops)

Expand Down Expand Up @@ -76,7 +76,7 @@ License
=======
Cyclops is licensed under Apache License 2.0. Cyclops contains the TinyThread libray.

The TinyThread library is licensed under the [zlib/libpng](https://opensource.org/licenses/Zlib/) license as described [here](https://tinythreadpp.bitsnbites.eu/).
The TinyThread library is licensed under the [zlib/libpng](https://opensource.org/license/zlib-license-php/) license as described [here](https://tinythreadpp.bitsnbites.eu/).

Development
===========
Expand Down
3 changes: 3 additions & 0 deletions cleanup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

rm -f config.* src/Makevars src/Markvars.win src/config.h
18 changes: 18 additions & 0 deletions configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env sh

# adapted from https://github.com/tidyverse/purrr/blob/main/configure

# Check that this is not just ./configure. We need to run this
# from R CMD INSTALL, to have the R env vars set.

if [ -z "$R_HOME" ]; then
echo >&2 R_HOME is not set, are you running R CMD INSTALL?
exit 1
fi

# Find the R binary we need to use. This is a bit trickier on
# Windows, because it has two architectures. On windows R_ARCH_BIN
# is set, so this should work everywhere.
RBIN="${R_HOME}/bin${R_ARCH_BIN}/R"

"$RBIN" --vanilla --slave -f tools/configure.R
2 changes: 2 additions & 0 deletions configure.win
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#! /usr/bin/env sh
sh ./configure
30 changes: 13 additions & 17 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
## Re-submission after 'valgrind' check email from Uwe Ligges:
## Resubmission after VALGRIND feedback from Brian Ripley

```
Thanks, we see with valgrind it is better, but still leaking.
```
* fixed VALGRIND uninitialized value (UB) issue; variable 'priorType' was uninitialized,
specifically in:

## Fixes

* all definite leaks on my M1 and linux (R 4.1) valgrind-versions are now gone.
* replaced calls to '::Rf_error()' with 'Rcpp::stop()' to ensure that destructors get
called before returning to R.
* removed calls to JVM through Andromeda package (was an issue with the CRAN system JVM).
==2293460== Conditional jump or move depends on uninitialised value(s)
==2293460== at 0x22CE4848: bsccs::CyclicCoordinateDescent::computeAsymptoticPrecisionMatrix() (packages/tests-vg/Cyclops/src/cyclops/CyclicCoordinateDescent.cpp:1335)

* fixed VALGRIND memory leak issue; was caused by calls to '::Rf_error()' instead of
'Rcpp::stop()' when handling some error edge-cases

## Test environments
* local OS X install, R 4.1
* r-devel-valgrind docker container
* ubuntu 20.04 (via gh-actions: devel and release)
* win-builder (devel and release)

## R CMD check results
* There were no ERRORs
* There is 1 occasional WARNING:
inclusion of 'abort'.

This inclusion comes from 'RcppEigen' and not 'Cyclops' on some platforms with R-devel.

* There were no ERRORs or WARNINGs
* There is 1 occasional NOTE:
checking installed package size ... NOTE
checking installed package size ... NOTE
installed size is 22.5Mb
sub-directories of 1Mb or more:
libs 21.7Mb
Expand All @@ -37,3 +31,5 @@ availability of C++17 'if (constexpr ...)' should decrease library size substant
## Downstream dependencies
* 'EvidenceSynthesis' - checked and works.
* 'EmpiricalCalibration' - checked and works.
* 'IterativeHardThresholding' - checked and works.
* 'BrokenAdaptiveRidge' - checked and works.
10 changes: 5 additions & 5 deletions inst/CITATION
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
citHeader("To cite Cyclops in publications use:")

bibentry(bibtype = "Article",
author = personList(as.person("M. A. Suchard"),
as.person("S. E. Simpson"),
as.person("I. Zorych"),
as.person("P. Ryan"),
as.person("D. Madigan")),
author = c(as.person("M. A. Suchard"),
as.person("S. E. Simpson"),
as.person("I. Zorych"),
as.person("P. Ryan"),
as.person("D. Madigan")),
title = "Massive parallelization of serial inference algorithms for complex generalized linear models",
journal = "ACM Transactions on Modeling and Computer Simulation",
volume = "23",
Expand Down
41 changes: 41 additions & 0 deletions man/Cyclops-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/convertToCyclopsData.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/survfit.cyclopsFit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/Makevars → src/Makevars.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CUDA_HOME = /usr/local/cuda

CUB_PATH = $(CUDA_HOME)/include
#CUB_PATH = /home/jianxiao/cub_1.8.0/cub

## Use the R_HOME indirection to support installations of multiple R version
PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` -lOpenCL -pthread -L$(CUDA_HOME)/lib64 -lcuda -lcudart
Expand Down
2 changes: 0 additions & 2 deletions src/Makevars.win → src/Makevars.win.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ PKG_LIBS = `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"`
## done by a number of packages, but recommended only for more advanced users
## comfortable with autoconf and its related tools.

CXX_STD = CXX11

PKG_CPPFLAGS = -I. -Icyclops -DR_BUILD -DWIN_BUILD -DDOUBLE_PRECISION -DRCPP_PARALLEL_USE_TBB=1

# PKG_LIBS += $(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" \
Expand Down
Loading

0 comments on commit 7538e27

Please sign in to comment.