Skip to content

Commit

Permalink
manually merge develop -> time_varying
Browse files Browse the repository at this point in the history
  • Loading branch information
jianxiaoyang committed Oct 30, 2023
2 parents 46d5039 + 6141974 commit eb76ddf
Show file tree
Hide file tree
Showing 17 changed files with 150 additions and 111 deletions.
95 changes: 39 additions & 56 deletions .github/workflows/R_CMD_check_Hades.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: 'release'} # Does not appear to have Java 32-bit, hence the --no-multiarch
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
# - {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}

env:
GITHUB_PAT: ${{ secrets.GH_TOKEN }}
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
CDM5_ORACLE_CDM_SCHEMA: ${{ secrets.CDM5_ORACLE_CDM_SCHEMA }}
Expand All @@ -43,75 +43,51 @@ jobs:
CDM5_SQL_SERVER_PASSWORD: ${{ secrets.CDM5_SQL_SERVER_PASSWORD }}
CDM5_SQL_SERVER_SERVER: ${{ secrets.CDM5_SQL_SERVER_SERVER }}
CDM5_SQL_SERVER_USER: ${{ secrets.CDM5_SQL_SERVER_USER }}
CDM5_REDSHIFT_CDM_SCHEMA: ${{ secrets.CDM5_REDSHIFT_CDM_SCHEMA }}
CDM5_REDSHIFT_OHDSI_SCHEMA: ${{ secrets.CDM5_REDSHIFT_OHDSI_SCHEMA }}
CDM5_REDSHIFT_PASSWORD: ${{ secrets.CDM5_REDSHIFT_PASSWORD }}
CDM5_REDSHIFT_SERVER: ${{ secrets.CDM5_REDSHIFT_SERVER }}
CDM5_REDSHIFT_USER: ${{ secrets.CDM5_REDSHIFT_USER }}
CDM5_SPARK_USER: ${{ secrets.CDM5_SPARK_USER }}
CDM5_SPARK_PASSWORD: ${{ secrets.CDM5_SPARK_PASSWORD }}
CDM5_SPARK_CONNECTION_STRING: ${{ secrets.CDM5_SPARK_CONNECTION_STRING }}
WEBAPI_TEST_WEBAPI_URL: ${{ secrets.WEBAPI_TEST_WEBAPI_URL }}
WEBAPI_TEST_SECURE_WEBAPI_URL: ${{ secrets.WEBAPI_TEST_SECURE_WEBAPI_URL }}
WEBAPI_TEST_ADMIN_USER_NAME: ${{ secrets.WEBAPI_TEST_ADMIN_USER_NAME }}
WEBAPI_TEST_ADMIN_USER_PASSWORD: ${{ secrets.WEBAPI_TEST_ADMIN_USER_PASSWORD }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}

- uses: r-lib/actions/setup-tinytex@v1
- uses: r-lib/actions/setup-tinytex@v2

- uses: r-lib/actions/setup-pandoc@v1
- uses: r-lib/actions/setup-pandoc@v2

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install system dependencies
- name: Install system requirements
if: runner.os == 'Linux'
run: |
sudo apt-get install -y libssh-dev
Rscript -e 'install.packages("remotes")'
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
- name: Install libssh
if: runner.os == 'Linux'
run: |
sudo apt-get install libssh-dev
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE, INSTALL_opts=c("--no-multiarch"))
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: Install covr
if: runner.os == 'macOS'
run: |
remotes::install_cran("covr")
shell: Rscript {0}

- name: Remove check folder if exists
if: runner.os == 'macOS'
run: unlink("check", recursive = TRUE)
shell: Rscript {0}

- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran", "--no-multiarch"), error_on = "warning", check_dir = "check")
shell: Rscript {0}
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- name: Upload check results
if: failure()
uses: actions/upload-artifact@v2
- uses: r-lib/actions/check-r-package@v2
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
args: 'c("--no-manual", "--as-cran")'
build_args: 'c("--compact-vignettes=both")'
error-on: '"warning"'
check-dir: '"check"'

- name: Upload source package
if: success() && runner.os == 'macOS' && github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
Expand All @@ -120,6 +96,12 @@ jobs:
name: package_tarball
path: check/*.tar.gz

- name: Install covr
if: runner.os == 'macOS'
run: |
install.packages("covr")
shell: Rscript {0}

- name: Test coverage
if: runner.os == 'macOS'
run: covr::codecov()
Expand All @@ -137,7 +119,7 @@ jobs:

steps:

- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

Expand All @@ -163,7 +145,7 @@ jobs:
draft: false
prerelease: false

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
if: ${{ env.new_version != '' }}

- name: Install drat
Expand Down Expand Up @@ -192,3 +174,4 @@ jobs:
if: ${{ env.new_version != '' }}
run: |
curl --data "build=true" -X POST https://registry.hub.docker.com/u/ohdsi/broadsea-methodslibrary/trigger/f0b51cec-4027-4781-9383-4b38b42dd4f5/
4 changes: 2 additions & 2 deletions Cyclops.Rproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
Expand Down
5 changes: 2 additions & 3 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.3.1.99
Version: 3.3.1.999
Authors@R: c(
person("Marc A.", "Suchard", email = "[email protected]", role = c("aut","cre")),
person("Martijn J.", "Schuemie", role = "aut"),
Expand Down Expand Up @@ -30,7 +30,7 @@ Biarch: true
URL: https://github.com/ohdsi/cyclops
BugReports: https://github.com/ohdsi/cyclops/issues
Depends:
R (>= 3.1.0)
R (>= 3.5.0)
Imports:
rlang,
Matrix,
Expand All @@ -41,7 +41,6 @@ Imports:
survival,
bit64
LinkingTo: Rcpp,
BH (>= 1.51.0),
RcppEigen (>= 0.3.2),
RcppParallel
Suggests:
Expand Down
15 changes: 9 additions & 6 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
develop
Cyclops v3.4.0
==============

Changes:

1. improvements on adaptive likelihood profiling
2. add `auto` option to `cvRepetitions`
3. bumped explicit C++11 requirement up to R v4.1
1. remove dependence on `BH`
2. improvements on adaptive likelihood profiling
3. add `auto` option to `cvRepetitions`
4. bumped explicit C++11 requirement up to R v4.1
5. removed deprecated use of `dbplyr:::$.tbl_lazy`
a. breaking change in `dbplyr v2.4.0`

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()
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
Expand Down
4 changes: 2 additions & 2 deletions R/DataManagement.R
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,8 @@ reduce <- function(object, covariates, groupBy, power = 1) {
#' \code{appendSqlCyclopsData} appends data to an OHDSI data object.
#'
#' @details Append data using two tables. The outcomes table is dense and contains ... The covariates table is sparse and contains ...
#' All entries in the outcome table must be sorted in increasing order by {oStratumId, oRowId}. All entries in the covariate table
#' must be sorted in increasing order by {cRowId}. Each cRowId value must match exactly one oRowId value.
#' All entries in the outcome table must be sorted in increasing order by (oStratumId, oRowId). All entries in the covariate table
#' must be sorted in increasing order by (cRowId). Each cRowId value must match exactly one oRowId value.
#'
#' @param object OHDSI Cyclops data object to append entries
#' @param oStratumId Integer vector (optional): non-unique stratum identifier for each row in outcomes table
Expand Down
2 changes: 1 addition & 1 deletion R/NewDataConversion.R
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ convertToCyclopsData.tbl_dbi <- function(outcomes,
}

if (modelType == "pr" | modelType == "cpr") {
if (any((select(outcomes, time) %>% pull()) <= 0)) {
if (any(pull(outcomes, .data$time) <= 0)) {
stop("time cannot be non-positive", call. = FALSE)
}
}
Expand Down
19 changes: 10 additions & 9 deletions R/TimeEffects.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ splitTime <- function(shortOut, cut) {
if (!"y" %in% colnames(shortOut)) stop("Must provide observed event status.")
if ("rowId" %in% colnames(shortOut)) {
shortOut <- shortOut %>%
rename(subjectId = rowId) %>%
arrange(subjectId)
rename(subjectId = .data$rowId) %>%
arrange(.data$subjectId)
} else {
shortOut <- shortOut %>%
mutate(subjectId = row_number())
Expand All @@ -36,10 +36,10 @@ splitTime <- function(shortOut, cut) {
episode = "stratumId",
id = "newSubjectId"))
longOut <- longOut %>%
rename(y = event) %>%
mutate(time = tstop - tstart) %>%
select(-c(newSubjectId, tstart, tstop)) %>%
arrange(stratumId, subjectId)
rename(y = .data$event) %>%
mutate(time = .data$tstop - .data$tstart) %>%
select(-c(.data$newSubjectId, .data$tstart, .data$tstop)) %>%
arrange(.data$stratumId, .data$subjectId)

# Restore rowIds
SubjectIds <- shortOut$subjectId
Expand All @@ -49,9 +49,10 @@ splitTime <- function(shortOut, cut) {

# Reorder columns
longOut <- longOut %>%
select(rowId, everything()) %>%
select(subjectId, everything()) %>%
select(stratumId, everything())
select(.data$stratumId, .data$subjectId, .data$rowId, everything())
# select(.data$rowId, everything()) %>%
# select(.data$subjectId, everything()) %>%
# select(.data$stratumId, everything())

return(longOut)
}
Expand Down
4 changes: 2 additions & 2 deletions man/appendSqlCyclopsData.Rd

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

14 changes: 8 additions & 6 deletions src/cyclops/CcdInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "CyclicCoordinateDescent.h"
#include "ModelData.h"

#include "boost/iterator/counting_iterator.hpp"
//#include "boost/iterator/counting_iterator.hpp"
#include "Thread.h"

// #include "io/InputReader.h"
Expand Down Expand Up @@ -373,9 +373,9 @@ double CcdInterface::profileModel(CyclicCoordinateDescent *ccd, AbstractModelDat
}
);
} else {
auto scheduler = TaskScheduler<boost::counting_iterator<int> >(
boost::make_counting_iterator(0),
boost::make_counting_iterator(static_cast<int>(bounds.size())),
auto scheduler = TaskScheduler<IncrementableIterator<size_t>>(
IncrementableIterator<size_t>(0), // boost::make_counting_iterator(0),
IncrementableIterator<size_t>(bounds.size()), //boost::make_counting_iterator(static_cast<int>(bounds.size())),
nThreads);

auto oneTask = [&getBound, &scheduler, &ccdPool, &bounds](unsigned long task) {
Expand Down Expand Up @@ -587,8 +587,10 @@ double CcdInterface::evaluateProfileModel(CyclicCoordinateDescent *ccd, Abstract
values[i] = evaluate(points[i], ccd);
}
} else {
auto scheduler = TaskScheduler<boost::counting_iterator<int>>(
boost::make_counting_iterator(0), boost::make_counting_iterator(static_cast<int>(points.size())), nThreads);
auto scheduler = TaskScheduler<IncrementableIterator<size_t>>(
IncrementableIterator<size_t>(0), //boost::make_counting_iterator(0),
IncrementableIterator<size_t>(points.size()), //boost::make_counting_iterator(static_cast<int>(points.size())),
nThreads);

auto oneTask = [&evaluate, &scheduler, &ccdPool, &points, &values](unsigned long task) {
values[task] = evaluate(points[task], ccdPool[scheduler.getThreadIndex(task)]);
Expand Down
8 changes: 4 additions & 4 deletions src/cyclops/CyclicCoordinateDescent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,12 @@ void CyclicCoordinateDescent::init(bool offset) {

// initialize starting betas to default value 0.0
startingBeta.resize(J, static_cast<double>(0.0));

// hXBeta.resize(K, static_cast<double>(0.0));
// hXBetaSave.resize(K, static_cast<double>(0.0));

fixBeta.resize(J, false);

hWeights.resize(0);
cWeights.resize(0); // ESK: For censor weights

Expand Down Expand Up @@ -757,7 +757,7 @@ void CyclicCoordinateDescent::kktSwindle(const ModeFindingArguments& arguments)
int swindleIterationCount = 1;

// int initialActiveSize = activeSet.size();
int perPassSize = arguments.swindleMultipler;
// int perPassSize = arguments.swindleMultipler;

while (!done) {

Expand Down Expand Up @@ -885,7 +885,7 @@ void CyclicCoordinateDescent::kktSwindle(const ModeFindingArguments& arguments)
}
}
++swindleIterationCount;
perPassSize *= 2;
// perPassSize *= 2;

logger->yield(); // This is not re-entrant safe
}
Expand Down
Loading

0 comments on commit eb76ddf

Please sign in to comment.