Skip to content

Commit

Permalink
v0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
edward-burn committed Sep 19, 2023
1 parent 09083ef commit d8ab252
Show file tree
Hide file tree
Showing 7 changed files with 219 additions and 222 deletions.
24 changes: 18 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
Package: CohortSurvival
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9000
Authors@R:
person("First", "Last", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "YOUR-ORCID-ID"))
Description: What the package does (one paragraph).
Title: Estimate survival using the OMOP Common Data Model
Version: 0.1
Authors@R: c(
person("Edward", "Burn", email = "[email protected]",
role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-9286-1128")),
person("Kim", "Lopez", email = "[email protected]", role = c("ctb"),
comment = c(ORCID = "0000-0002-8462-8668")),
person("Marti", "Catala", email = "[email protected]",
role = c("ctb"),
comment = c(ORCID = "0000-0003-3308-9905")),
person("Xintong", "Li", email = "[email protected]",
role = c("ctb"),
comment = c(ORCID = "0000-0003-3308-9905")),
person("Danielle", "Newby", email = "[email protected]",
role = c("ctb"),
comment = c(ORCID = "0000-0002-3001-1478")))
Description: Estimate survival using data mapped to the Observational Medical Outcomes Partnership (OMOP) common data model. Survival can be estimated based on user-defined study cohorts.
License: Apache License (>= 2)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
Expand Down
20 changes: 14 additions & 6 deletions R/generateDeathCohort.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#' @param name name for the created death cohort table
#' @param cohortTable name of the cohort table to create a death cohort for
#' @param cohortId name of the cohort table to create a death cohort for
#' @param overwrite Should the cohort table be overwritten if it already exists?
#'
#' @return A cohort table with a death cohort in cdm
#' @export
Expand All @@ -18,7 +19,8 @@ generateDeathCohortSet <- function(
deathInObservation = FALSE,
name = "death_cohort",
cohortTable = NULL,
cohortId = NULL){
cohortId = NULL,
overwrite = FALSE){

# 0. validate inputs...
checkCdm(cdm, tables = c(
Expand Down Expand Up @@ -80,7 +82,9 @@ generateDeathCohortSet <- function(
) %>%
CDMConnector::computeQuery(
name = paste0(attr(cdm, "write_prefix"), name),
FALSE, attr(cdm, "write_schema"), TRUE
temporary = FALSE,
schema = attr(cdm, "write_schema"),
overwrite = overwrite
)

cohortSetRef <- cohortRef %>%
Expand All @@ -89,7 +93,9 @@ generateDeathCohortSet <- function(
dplyr::mutate(cohort_name = "death_cohort") %>%
CDMConnector::computeQuery(
name = paste0(attr(cdm, "write_prefix"), name, "_set"),
FALSE, attr(cdm, "write_schema"), TRUE
temporary = FALSE,
schema = attr(cdm, "write_schema"),
overwrite = overwrite
)

cohortCountRef <- cohortRef %>%
Expand All @@ -101,15 +107,17 @@ generateDeathCohortSet <- function(
) %>%
CDMConnector::computeQuery(
name = paste0(attr(cdm, "write_prefix"), name, "_count"),
FALSE, attr(cdm, "write_schema"), TRUE
temporary = FALSE,
schema = attr(cdm, "write_schema"),
overwrite = overwrite
)


if(cohortRef %>% utils::head(5) %>% dplyr::tally() %>% dplyr::pull("n") > 0){
cdm[[name]] <- CDMConnector::newGeneratedCohortSet(
cohortRef = cohortRef,
cohortSetRef = cohortSetRef,
cohortCountRef = cohortCountRef
)
)}

attr(cdm[[name]], "cohort_attrition") <- tibble::tibble(
"reason" = "Qualifying initial records",
Expand Down
4 changes: 2 additions & 2 deletions R/suppressSurvivalCounts.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ for(i in seq_along(toObscure$group_name)){
.data$strata_name == toObscure$strata_name[i] &
.data$strata_level == toObscure$strata_level[i] &
.data$variable_type == "n_start", paste0("<", minCellCount),
as.character(estimate))) %>%
as.character(.data$estimate))) %>%
dplyr::mutate(estimate = dplyr::if_else(
.data$group_name == toObscure$group_name[i] &
.data$group_level == toObscure$group_level[i] &
.data$strata_name == toObscure$strata_name[i] &
.data$strata_level == toObscure$strata_level[i] &
.data$variable_type != "n_start",
as.character(NA),
as.character(estimate)))
as.character(.data$estimate)))
}
}

Expand Down
14 changes: 11 additions & 3 deletions man/CohortSurvival-package.Rd

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

5 changes: 4 additions & 1 deletion man/generateDeathCohortSet.Rd

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

Loading

0 comments on commit d8ab252

Please sign in to comment.