Skip to content

Commit

Permalink
Updating and regenerating documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Admin_mschuemi authored and Admin_mschuemi committed Apr 17, 2023
1 parent 4f1ea31 commit fb43f26
Show file tree
Hide file tree
Showing 58 changed files with 1,033 additions and 277 deletions.
1 change: 1 addition & 0 deletions CohortMethod.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

BuildType: Package
PackageCleanBeforeInstall: No
PackageInstallArgs: --no-multiarch --with-keep.source
PackageBuildArgs: --resave-data
PackageRoxygenize: rd,collate,namespace
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: CohortMethod
Type: Package
Title: New-User Cohort Method with Large Scale Propensity and Outcome Models
Version: 5.0.0
Date: 2022-06-21
Date: 2023-04-17
Authors@R: c(
person("Martijn", "Schuemie", , "[email protected]", role = c("aut", "cre")),
person("Marc", "Suchard", role = c("aut")),
Expand Down
7 changes: 7 additions & 0 deletions R/Export.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ createCmDiagnosticThresholds <- function(mdrrThreshold = 10,
sdmThreshold = 0.1,
equipoiseThreshold = 0.2,
attritionFractionThreshold = 1) {
errorMessages <- checkmate::makeAssertCollection()
checkmate::assertNumeric(mdrrThreshold, len = 1, lower = 0, add = errorMessages)
checkmate::assertNumeric(easeThreshold, len = 1, lower = 0, add = errorMessages)
checkmate::assertNumeric(sdmThreshold, len = 1, lower = 0, add = errorMessages)
checkmate::assertNumeric(equipoiseThreshold, len = 1, lower = 0, add = errorMessages)
checkmate::assertNumeric(attritionFractionThreshold, len = 1, lower = 0, add = errorMessages)
checkmate::reportAssertions(collection = errorMessages)
thresholds <- list()
for (name in names(formals(createCmDiagnosticThresholds))) {
thresholds[[name]] <- get(name)
Expand Down
1 change: 0 additions & 1 deletion R/KaplanMeier.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.


#' Plot the Kaplan-Meier curve
#'
#' @description
Expand Down
8 changes: 2 additions & 6 deletions R/RunAnalyses.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,7 @@ runCmAnalyses <- function(connectionDetails,
refitPsForEveryStudyPopulation = TRUE,
multiThreadingSettings = createMultiThreadingSettings()) {
errorMessages <- checkmate::makeAssertCollection()
if (is(connectionDetails, "connectionDetails")) {
checkmate::assertClass(connectionDetails, "connectionDetails", add = errorMessages)
} else {
checkmate::assertClass(connectionDetails, "ConnectionDetails", add = errorMessages)
}
checkmate::assertClass(connectionDetails, "ConnectionDetails", add = errorMessages)
checkmate::assertCharacter(cdmDatabaseSchema, len = 1, add = errorMessages)
checkmate::assertCharacter(tempEmulationSchema, len = 1, null.ok = TRUE, add = errorMessages)
checkmate::assertCharacter(exposureDatabaseSchema, len = 1, add = errorMessages)
Expand Down Expand Up @@ -1623,7 +1619,7 @@ createReferenceTable <- function(cmAnalysisList,
#' @param outputFolder Name of the folder where all the outputs have been written to.
#'
#' @return
#' A tibble containing file nams of artifacts generated for each target-comparator-outcome-analysis combination.
#' A tibble containing file names of artifacts generated for each target-comparator-outcome-analysis combination.
#'
#' @export
getFileReference <- function(outputFolder) {
Expand Down
5 changes: 0 additions & 5 deletions R/Simulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ createCohortMethodDataSimulationProfile <- function(cohortMethodData) {
select("covariateId", "prevalence") %>%
collect()

# covariatePrevalence <- sums$prevalence
# names(covariatePrevalence) <- sums$covariateId

message("Computing propensity model")
propensityScore <- createPs(cohortMethodData,
maxCohortSizeForFitting = 25000,
Expand All @@ -84,7 +81,6 @@ createCohortMethodDataSimulationProfile <- function(cohortMethodData) {
removeSubjectsWithPriorOutcome = FALSE,
outcomeId = outcomeId
)
# studyPop <- trimByPsToEquipoise(studyPop)
studyPop <- matchOnPs(studyPop, caliper = 0.25, caliperScale = "standardized", maxRatio = 1)
outcomeModel <- fitOutcomeModel(
population = studyPop,
Expand Down Expand Up @@ -172,7 +168,6 @@ simulateCohortMethodData <- function(profile, n = 10000) {
checkmate::assertInt(n, lower = 1, add = errorMessages)
checkmate::reportAssertions(collection = errorMessages)


message("Generating covariates")
# Treatment variable is generated elsewhere:
covariatePrevalence <- profile$covariatePrevalence[names(profile$covariatePrevalence) != "1"]
Expand Down
29 changes: 26 additions & 3 deletions R/Viewer.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# 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.

# exportFolder = file.path(folder, "export")
# library(dplyr)

Expand All @@ -31,6 +32,13 @@
#'
#' @export
insertExportedResultsInSqlite <- function(sqliteFileName, exportFolder, cohorts) {
errorMessages <- checkmate::makeAssertCollection()
checkmate::assertCharacter(sqliteFileName, len = 1, add = errorMessages)
checkmate::assertCharacter(exportFolder, len = 1, add = errorMessages)
checkmate::assertDataFrame(cohorts, add = errorMessages)
checkmate::assertNames(colnames(cohorts), must.include = c("cohortId", "cohortName"), add = errorMessages)
checkmate::reportAssertions(collection = errorMessages)

ensureInstalled("RSQLite")
connectionDetails <- DatabaseConnector::createConnectionDetails(
dbms = "sqlite",
Expand Down Expand Up @@ -62,7 +70,6 @@ insertExportedResultsInSqlite <- function(sqliteFileName, exportFolder, cohorts)
#' using the [exportToCsv()] function.
#' @template Cohorts
#'
#'
#' @return
#' Does not return anything. Is called for the side-effect of having the results uploaded
#' to the server.
Expand All @@ -73,15 +80,22 @@ uploadExportedResults <- function(connectionDetails,
append = FALSE,
exportFolder,
cohorts) {
# ensureInstalled("CohortGenerator")
errorMessages <- checkmate::makeAssertCollection()
checkmate::assertClass(connectionDetails, "ConnectionDetails", add = errorMessages)
checkmate::assertCharacter(databaseSchema, len = 1, add = errorMessages)
checkmate::assertLogical(append, len = 1, add = errorMessages)
checkmate::assertCharacter(exportFolder, len = 1, add = errorMessages)
checkmate::assertDataFrame(cohorts, add = errorMessages)
checkmate::assertNames(colnames(cohorts), must.include = c("cohortId", "cohortName"), add = errorMessages)
checkmate::reportAssertions(collection = errorMessages)

ensureInstalled("ResultModelManager")
connection <- DatabaseConnector::connect(connectionDetails)
on.exit(DatabaseConnector::disconnect(connection))

if (!append) {
# Create tables
rdmsFile <- system.file("csv", "resultsDataModelSpecification.csv", package = "CohortMethod")
# specification <- CohortGenerator::readCsv(file = rdmsFile)
specification <- readr::read_csv(file = rdmsFile, show_col_types = FALSE) %>%
SqlRender::snakeCaseToCamelCaseNames()
sql <- ResultModelManager::generateSqlSchema(csvFilepath = rdmsFile)
Expand Down Expand Up @@ -147,6 +161,10 @@ uploadExportedResults <- function(connectionDetails,
#'
#' @export
launchResultsViewerUsingSqlite <- function(sqliteFileName) {
errorMessages <- checkmate::makeAssertCollection()
checkmate::assertCharacter(sqliteFileName, len = 1, add = errorMessages)
checkmate::reportAssertions(collection = errorMessages)

ensureInstalled("RSQLite")
connectionDetails <- DatabaseConnector::createConnectionDetails(
dbms = "sqlite",
Expand All @@ -171,6 +189,11 @@ launchResultsViewerUsingSqlite <- function(sqliteFileName) {
#'
#' @export
launchResultsViewer <- function(connectionDetails, databaseSchema) {
errorMessages <- checkmate::makeAssertCollection()
checkmate::assertClass(connectionDetails, "ConnectionDetails", add = errorMessages)
checkmate::assertCharacter(databaseSchema, len = 1, add = errorMessages)
checkmate::reportAssertions(collection = errorMessages)

ensureInstalled("ShinyAppBuilder")
ensureInstalled("markdown")
aboutModule <- ShinyAppBuilder::createDefaultAboutConfig(
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ User Documentation
Documentation can be found on the [package website](https://ohdsi.github.io/CohortMethod).

PDF versions of the documentation are also available:

* Vignette: [Single studies using the CohortMethod package](https://raw.githubusercontent.com/OHDSI/CohortMethod/main/inst/doc/SingleStudies.pdf)
* Vignette: [Running multiple analyses at once using the CohortMethod package](https://raw.githubusercontent.com/OHDSI/CohortMethod/main/inst/doc/MultipleAnalyses.pdf)
* Package manual: [CohortMethod.pdf](https://raw.githubusercontent.com/OHDSI/CohortMethod/main/extras/CohortMethod.pdf)
Expand Down
9 changes: 9 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,20 @@ reference:
- createMultiThreadingSettings
- createDefaultMultiThreadingSettings
- runCmAnalyses
- title: "Results of multiple analyses"
desc: >
Functions for viewing results of multiple analyses.
contents:
- getFileReference
- getResultsSummary
- getInteractionResultsSummary
- createCmDiagnosticThresholds
- exportToCsv
- getResultsDataModel
- insertExportedResultsInSqlite
- launchResultsViewerUsingSqlite
- uploadExportedResults
- launchResultsViewer
- title: "Simulation"
desc: >
Functions for simulating cohort method data objects.
Expand Down
Loading

0 comments on commit fb43f26

Please sign in to comment.