Skip to content

Commit

Permalink
initial BipolarMissclassificationValidation commit
Browse files Browse the repository at this point in the history
added code to create cohorts, apply simple score model, evaluate it, calculate summary survival info, find relationship between predicted score and outcome over 10 years
  • Loading branch information
jreps committed Jan 15, 2020
1 parent 6154650 commit 0f3e310
Show file tree
Hide file tree
Showing 37 changed files with 10,297 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
^.*\.Rproj$
^\.Rproj\.user$
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
*.html
20 changes: 20 additions & 0 deletions BipolarMisclassificationValidation.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: ISO8859-1

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
28 changes: 28 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Package: BipolarMisclassificationValidation
Type: Package
Title: External Validation of Model Predicting Bipolar Misdiagnosed as MDD
Version: 0.0.1
Date: 2020-01-01
Author: Jenna Reps
Maintainer: Jenna Reps <youremail@address>
Description: This study applies and evaluates a simple score model to OMOP CDM data that predicts which newly diagnosed MDD patients will be diagnosed with bipolar within the next 3 years
License: Apache License 2.0
Depends:
R (>= 3.3.0),
DatabaseConnector (>= 1.11.4),
survival
Imports:
FeatureExtraction (>= 2.0.0),
SqlRender,
Cyclops (>= 1.2.2),
PatientLevelPrediction (>= 3.0.10),
ggplot2,
gridExtra,
ff,
ffbase (>= 0.12.1),
ParallelLogger,
OhdsiSharing
Suggests:
testthat
NeedsCompilation: no
RoxygenNote: 6.0.1
38 changes: 38 additions & 0 deletions HydraConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"skeletonType": "PatientLevelPredictionValidationStudy",
"skeletonVersion": "v0.0.1",
"requiredHydraVersion": "v0.0.3",
"actions":[{
"type": "fileNameFindAndReplace",
"input": "packageName",
"find": "bipolarValidation"
},{
"type": "stringFindAndReplace",
"input": "packageName",
"find": "bipolarValidation"
},{
"type": "jsonArrayToCsv",
"input": "cohortDefinitions",
"mapping": [{"source": "id", "target": "cohortId"},
{"source": "id", "target": "atlasId"},
{"source": "name", "target": "name", "modifiers": ["convertToFileName"]}],
"output": "inst/settings/CohortsToCreate.csv"
},{
"type": "jsonArrayToJson",
"input": "cohortDefinitions",
"fileName": "name",
"payload": "expression",
"output": "inst/cohorts"
},{
"type": "jsonArrayToSql",
"input": "cohortDefinitions",
"fileName": "name",
"payload": "expression",
"output": "inst/sql/sql_server"
},
{
"type": "jsonToJson",
"input": "",
"output": "inst/settings/plpAnalysisList.json"
}]
}
9 changes: 9 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated by roxygen2: do not edit by hand

export(checkInstall)
export(createCohorts)
export(execute)
export(getTable1)
export(packageResults)
export(transportPlpModels)
import(DatabaseConnector)
71 changes: 71 additions & 0 deletions R/PackageResults.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright 2018 Observational Health Data Sciences and Informatics
#
# This file is part of PredictionNetworkStudySkeleton
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#' Package the results for sharing with OHDSI researchers
#'
#' @details
#' This function packages the results.
#'
#' @param outputFolder Name of local folder to place results; make sure to use forward slashes
#' (/)
#' @param minCellCount The minimum number of subjects contributing to a count before it can be included in the results.
#'
#' @export
packageResults <- function(outputFolder,
minCellCount = 5) {
if(missing(outputFolder)){
stop('Missing outputFolder...')
}

# transport the results

#create export subfolder in workFolder
exportFolder <- file.path(outputFolder, "resultsToShare")

if (!file.exists(exportFolder)){
dir.create(exportFolder, recursive = T)
}

# loads analysis results
if(file.exists(file.path(outputFolder, 'validationResults.rds'))){
plpResult <- readRDS(file.path(outputFolder, 'validationResults.rds'))

if(minCellCount==0){
minCellCount <- NULL
}
result <- PatientLevelPrediction::transportPlp(plpResult, save = F,
n=minCellCount,
includeEvaluationStatistics=T,
includeThresholdSummary=T,
includeDemographicSummary=T,
includeCalibrationSummary =T,
includePredictionDistribution=T,
includeCovariateSummary=T)
saveRDS(result, file.path(exportFolder, 'validationResults.rds'))

}



### Add all to zip file ###
zipName <- paste0(outputFolder, '.zip')
OhdsiSharing::compressFolder(exportFolder, zipName)
# delete temp folder
unlink(exportFolder, recursive = T)

writeLines(paste("\nStudy results are compressed and ready for sharing at:", zipName))
return(zipName)
}
24 changes: 24 additions & 0 deletions R/SkeletonValidationPackage.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# @file SkeletonValidationPackage.R
#
# Copyright 2018 Observational Health Data Sciences and Informatics
#
# This file is part of SkeletonValidationPackage
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#' SkeletonValidationPackage
#'
#' @docType package
#' @name SkeletonValidationPackage
#' @import DatabaseConnector
NULL
Loading

0 comments on commit 0f3e310

Please sign in to comment.