Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
Fix wrong data passed to non-parameteric bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
nextpagesoft committed Mar 26, 2023
1 parent 3f5cd0e commit db7b3e1
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 72 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## 3.0.0

###### _March 20 2023_
###### _March 26 2023_

- Set constraints and step in delta4Fac input
- Set constraints and step in delta4Fac input
- Fix wrong case-based data (non-bootstrap specific) passed to modelling


## 3.0.0
Expand Down
10 changes: 5 additions & 5 deletions Client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@mui/icons-material": "^5.11.11",
"@mui/lab": "5.0.0-alpha.123",
"@mui/material": "^5.11.13",
"@mui/system": "^5.11.13",
"echarts": "^5.4.1",
"@mui/lab": "5.0.0-alpha.124",
"@mui/material": "^5.11.14",
"@mui/system": "^5.11.14",
"echarts": "^5.4.2",
"echarts-for-react": "^3.0.2",
"file-saver": "^2.0.5",
"jquery": "^3.6.4",
Expand All @@ -56,7 +56,7 @@
"filemanager-webpack-plugin": "^8.0.0",
"html-webpack-plugin": "^5.5.0",
"terser-webpack-plugin": "^5.3.7",
"webpack": "^5.76.2",
"webpack": "^5.76.3",
"webpack-bundle-analyzer": "^4.8.0",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.13.1",
Expand Down
86 changes: 43 additions & 43 deletions Client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2239,9 +2239,9 @@ __metadata:
languageName: node
linkType: hard

"@mui/base@npm:5.0.0-alpha.121":
version: 5.0.0-alpha.121
resolution: "@mui/base@npm:5.0.0-alpha.121"
"@mui/base@npm:5.0.0-alpha.122":
version: 5.0.0-alpha.122
resolution: "@mui/base@npm:5.0.0-alpha.122"
dependencies:
"@babel/runtime": ^7.21.0
"@emotion/is-prop-valid": ^1.2.0
Expand All @@ -2258,14 +2258,14 @@ __metadata:
peerDependenciesMeta:
"@types/react":
optional: true
checksum: b14c9b5ed631058a0ef780a78c5e9129c67338baa4f65a4ab90e23f68410e24d133a9c19f195c136325338b5f444600e43cdd817430b546b73e5371b5d24f32f
checksum: 6d229f6f736074a41e0cf787cc5ef98eba23a52044d7edf22fcc42f03250275fd1b4bb4a7ab47fc1f1aec06bf777bde5474229cc381e515eefee8876f2d8cd5c
languageName: node
linkType: hard

"@mui/core-downloads-tracker@npm:^5.11.13":
version: 5.11.13
resolution: "@mui/core-downloads-tracker@npm:5.11.13"
checksum: b8a32c9fc4beac4b596afe5fd3d2aecc2449e59d9e58a7ae6fbe528249fa6eabff3abf9195233eb7a46d523d6f1dc5c4ae95e1a69c287182c81311508c07c2c6
"@mui/core-downloads-tracker@npm:^5.11.14":
version: 5.11.14
resolution: "@mui/core-downloads-tracker@npm:5.11.14"
checksum: 8b1b42e125b15136ee82d2cb48354202b87beb8e20defcf3a8b758b033732444d09446d85a28c23b0dcaa8b5d067bc20bdd654c9adf551d826b142b4b09d7dd7
languageName: node
linkType: hard

Expand All @@ -2285,13 +2285,13 @@ __metadata:
languageName: node
linkType: hard

"@mui/lab@npm:5.0.0-alpha.123":
version: 5.0.0-alpha.123
resolution: "@mui/lab@npm:5.0.0-alpha.123"
"@mui/lab@npm:5.0.0-alpha.124":
version: 5.0.0-alpha.124
resolution: "@mui/lab@npm:5.0.0-alpha.124"
dependencies:
"@babel/runtime": ^7.21.0
"@mui/base": 5.0.0-alpha.121
"@mui/system": ^5.11.13
"@mui/base": 5.0.0-alpha.122
"@mui/system": ^5.11.14
"@mui/types": ^7.2.3
"@mui/utils": ^5.11.13
clsx: ^1.2.1
Expand All @@ -2311,18 +2311,18 @@ __metadata:
optional: true
"@types/react":
optional: true
checksum: 492bec98df414691ad6f90f88542fb3f16a5ac4abff126265aef45d1c60971e9e198d8e84001090b04de9034efdc195e4726a1c83017ece3d50d0eb459159033
checksum: bc96ada0f2eec0bdb1ed0aa0ad03e7d8c41f50f3c0869114e5c21c4b428a7a1de476e6858b6d1d308cc70a587fd802b81fd2b6e890c5d9debdc6983ae5ff516e
languageName: node
linkType: hard

"@mui/material@npm:^5.11.13":
version: 5.11.13
resolution: "@mui/material@npm:5.11.13"
"@mui/material@npm:^5.11.14":
version: 5.11.14
resolution: "@mui/material@npm:5.11.14"
dependencies:
"@babel/runtime": ^7.21.0
"@mui/base": 5.0.0-alpha.121
"@mui/core-downloads-tracker": ^5.11.13
"@mui/system": ^5.11.13
"@mui/base": 5.0.0-alpha.122
"@mui/core-downloads-tracker": ^5.11.14
"@mui/system": ^5.11.14
"@mui/types": ^7.2.3
"@mui/utils": ^5.11.13
"@types/react-transition-group": ^4.4.5
Expand All @@ -2344,7 +2344,7 @@ __metadata:
optional: true
"@types/react":
optional: true
checksum: 008e7e79bff7f193724c80308c9751151fc61dcaa76ce8f96d11473280ec6d78f61c9bdb8d23f0869e78b9359aa0bdd5164953d57a4e2f7160280f5d2a6b0b2d
checksum: 48fdd56ee55da6d551b8b716b8a080afe2276a62e0441efdd58be3b10ab1204d196a8ecc5f35ac23b8e9c7f5d6884ce37966cdcf8846771fe8ccc5ca626a8e1e
languageName: node
linkType: hard

Expand Down Expand Up @@ -2386,9 +2386,9 @@ __metadata:
languageName: node
linkType: hard

"@mui/system@npm:^5.11.13":
version: 5.11.13
resolution: "@mui/system@npm:5.11.13"
"@mui/system@npm:^5.11.14":
version: 5.11.14
resolution: "@mui/system@npm:5.11.14"
dependencies:
"@babel/runtime": ^7.21.0
"@mui/private-theming": ^5.11.13
Expand All @@ -2410,7 +2410,7 @@ __metadata:
optional: true
"@types/react":
optional: true
checksum: e6f1852ecf3dc901645c096f650950b858f5a5e53fc72ca68a7565e844d0841681c79402c3b63100574d1863b3af88d84b832bc680e8dae3a4a2147c7c9aee0f
checksum: a9df588ee7358438244ba5115f1f3bfe548b4c9077280204b6f6d4b98f20fd93f76bc36bf1430848b64e5c3a495ecb0e5000379932faa3dfb92360a34262f301
languageName: node
linkType: hard

Expand Down Expand Up @@ -4192,13 +4192,13 @@ __metadata:
languageName: node
linkType: hard

"echarts@npm:^5.4.1":
version: 5.4.1
resolution: "echarts@npm:5.4.1"
"echarts@npm:^5.4.2":
version: 5.4.2
resolution: "echarts@npm:5.4.2"
dependencies:
tslib: 2.3.0
zrender: 5.4.1
checksum: 2868541087045d27691e99950a96896da48be2c758cb9cd6ab57244bfa40967edecc5a215e02f63a48fa9d56aa1dc91c8339982fdb8d2b1323b19852e91d9fa8
zrender: 5.4.3
checksum: 933c28dada362314f7c7a5fd4243b44b24f75adb233f7c87541ac9a81734cb380a9683c3f56c8e559dacfddd363879e95a96f0047e33820123cd8f5b95b60f8f
languageName: node
linkType: hard

Expand Down Expand Up @@ -4895,14 +4895,14 @@ fsevents@~2.3.2:
"@emotion/react": ^11.10.6
"@emotion/styled": ^11.10.6
"@mui/icons-material": ^5.11.11
"@mui/lab": 5.0.0-alpha.123
"@mui/material": ^5.11.13
"@mui/system": ^5.11.13
"@mui/lab": 5.0.0-alpha.124
"@mui/material": ^5.11.14
"@mui/system": ^5.11.14
"@types/webpack-merge": ^5.0.0
babel-loader: ^9.1.2
clean-webpack-plugin: ^4.0.0
cross-env: ^7.0.3
echarts: ^5.4.1
echarts: ^5.4.2
echarts-for-react: ^3.0.2
file-loader: ^6.2.0
file-saver: ^2.0.5
Expand All @@ -4917,7 +4917,7 @@ fsevents@~2.3.2:
serializr: ^3.0.2
terser-webpack-plugin: ^5.3.7
tslib: ^2.5.0
webpack: ^5.76.2
webpack: ^5.76.3
webpack-bundle-analyzer: ^4.8.0
webpack-cli: ^5.0.1
webpack-dev-server: ^4.13.1
Expand Down Expand Up @@ -7804,9 +7804,9 @@ resolve@^1.14.2:
languageName: node
linkType: hard

"webpack@npm:^5.76.2":
version: 5.76.2
resolution: "webpack@npm:5.76.2"
"webpack@npm:^5.76.3":
version: 5.76.3
resolution: "webpack@npm:5.76.3"
dependencies:
"@types/eslint-scope": ^3.7.3
"@types/estree": ^0.0.51
Expand Down Expand Up @@ -7837,7 +7837,7 @@ resolve@^1.14.2:
optional: true
bin:
webpack: bin/webpack.js
checksum: 86db98299a175c371031449c26077e87b33acd8f45de7f7945ed4b9b37c8ca11bc5169af9c44743efccd4d55e08042a3aa3a3bc42aff831309a0821ffbcd395e
checksum: 363f536b56971d056e34ab4cffa4cbc630b220e51be1a8c3adea87d9f0b51c49cfc7c3720d6614a1fd2c8c63f1ab3100db916fe8367c8bb9299327ff8c3f856d
languageName: node
linkType: hard

Expand Down Expand Up @@ -7962,11 +7962,11 @@ resolve@^1.14.2:
languageName: node
linkType: hard

"zrender@npm:5.4.1":
version: 5.4.1
resolution: "zrender@npm:5.4.1"
"zrender@npm:5.4.3":
version: 5.4.3
resolution: "zrender@npm:5.4.3"
dependencies:
tslib: 2.3.0
checksum: 9a50cc2cc42ef44a436cfca5a29d6378b92790f50755b4d54f513a55dc7dab9698cecbc5640d731b380ad282aab1c33ae8cc1d14b61c0d51f0e951085a1bf17c
checksum: ae89584fbe4256217e500a74183fd5870a2bed7e7b3234cd78fcbc0a1a82da8449596b2019105927069531b567ecf94425fb171abd6cedcbf517e52fdf438722
languageName: node
linkType: hard
2 changes: 1 addition & 1 deletion Server/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: hivPlatform
Type: Package
Title: HIV Platform
Version: 3.0.0
Date: 2023-03-20
Date: 2023-03-26
Authors@R: c(person('Magdalena', 'Rosinska', email = '[email protected]',
role = c('aut', 'cph')), person('Nikos', 'Pantazis', email =
'[email protected]', role = c('aut')), person('Ard', 'van Sighem',
Expand Down
30 changes: 16 additions & 14 deletions Server/R/HIVModelManager.R
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ HIVModelManager <- R6::R6Class( # nolint

fits <- list()
i <- 0

for (imp in names(mainFitResult)) {
i <- i + 1
mainFit <- mainFitResult[[imp]]
Expand All @@ -518,24 +517,24 @@ HIVModelManager <- R6::R6Class( # nolint

PrintH2('Main data set {.val {imp}}')

dataAfterMigr <- FALSE
if (bsType == 'NON-PARAMETRIC') {
caseDataImp <- caseData[Imputation == as.integer(imp)]
dataAfterMigr <- 'ProbPre' %in% colnames(caseDataImp)
} else {
bootData <- context$Data
}

jSucc <- 1
jSucc <- 0
j <- 0
bootResults <- list()
while (jSucc <= bsCount) {
while (jSucc < bsCount) {
j <- j + 1

# Bootstrap data set
dataAfterMigr <- FALSE

if (bsType == 'NON-PARAMETRIC') {
dataAfterMigr <- 'ProbPre' %in% colnames(caseDataImp)
bootCaseDataImp <- caseDataImp[sample.int(nrow(caseDataImp), replace = TRUE)]

if (dataAfterMigr && migrConnFlag) {
bootCaseDataImp[, MigrClass := data.table::fcase(
!is.na(DateOfArrival) & DateOfHIVDiagnosis < DateOfArrival, 'Diagnosed prior to arrival', # nolint
Expand Down Expand Up @@ -571,7 +570,7 @@ HIVModelManager <- R6::R6Class( # nolint
aggrData <- NULL
}
} else {
caseDataAll <- PrepareDataSetsForModel(caseDataImp, splitBy = 'Imputation')
caseDataAll <- PrepareDataSetsForModel(caseData, splitBy = 'Imputation')
}
bootData <- CombineData(caseDataAll, aggrData)[[1]]
}
Expand Down Expand Up @@ -616,11 +615,19 @@ HIVModelManager <- R6::R6Class( # nolint
dataAfterMigr
)

msgType <- ifelse(bootResult$Converged, 'success', 'danger')
if (bootResult$Converged) {
msgType <- 'success'
jSucc <- jSucc + 1
progress <- (jSucc + (i - 1) * bsCount) / (mainCount * bsCount) * 100
} else {
msgType <- 'danger'
}
jSuccRate <- jSucc / j

PrintAlert(
'Iteration {.val {jSucc}} done |',
'Run time: {.timestamp {prettyunits::pretty_dt(runTime)}}',
'Run time: {.timestamp {prettyunits::pretty_dt(runTime)}} |',
'Success rate: {.val {jSuccRate * 100}}%',
type = msgType
)

Expand All @@ -632,11 +639,6 @@ HIVModelManager <- R6::R6Class( # nolint
DataSet = imp,
BootIteration = jSucc
)

if (bootResult$Converged) {
jSucc <- jSucc + 1
progress <- (jSucc - 1 + (i - 1) * bsCount) / (mainCount * bsCount) * 100
}
}

fits[[imp]] <- bootResults
Expand Down
2 changes: 1 addition & 1 deletion Server/inst/app/www/js/main.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Server/inst/app/www/js/vendors.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Server/utils/Example.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ appMgr$CaseMgr$SetFilters(filters = list(
# STEP 3 - Adjust case-based data ------------------------------------------------------------------
adjustmentSpecs <- hivPlatform::GetAdjustmentSpecs(c(
# "Multiple Imputation using Chained Equations - MICE",
"Reporting Delays with trend"
# "Reporting Delays with trend"
))

result <- hivPlatform::RunAdjustments(
Expand Down Expand Up @@ -310,7 +310,6 @@ appMgr$HIVModelMgr$SetMigrConnFlag(TRUE)
migrConnFlag <- appMgr$HIVModelMgr$MigrConnFlag
randomSeed <- .Random.seed


json <- ConvertObjToJSON(appMgr$HIVModelMgr$PlotData, dataframe = 'columns')
writeLines(json, 'json.txt')

Expand Down Expand Up @@ -365,12 +364,13 @@ avgRunTime <- mean(sapply(appMgr$HIVModelMgr$MainFitResult, '[[', 'RunTime'))
maxRunTime <- as.difftime(avgRunTime * maxRunTimeFactor, units = 'secs')
prettyunits::pretty_dt(maxRunTime)
mainFitResult <- isolate(appMgr$HIVModelMgr$MainFitResult)
avgModelOutputs <- isolate(appMgr$HIVModelMgr$AvgModelOutputs)
caseData <- isolate(appMgr$CaseMgr$Data)
aggrData <- isolate(appMgr$AggrMgr$Data)
popCombination <- isolate(appMgr$HIVModelMgr$PopCombination)
aggrDataSelection <- isolate(appMgr$HIVModelMgr$AggrDataSelection)
randomSeed <- .Random.seed
migrConnFlag <- TRUE
migrConnFlag <- FALSE

# 3. Detailed HIV Model bootstrap results (rds)
appMgr$HIVModelMgr$BootstrapFitResult
Expand Down

0 comments on commit db7b3e1

Please sign in to comment.