Skip to content

Commit

Permalink
v0.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
edward-burn committed Dec 11, 2023
1 parent 760a3c4 commit eed5e26
Show file tree
Hide file tree
Showing 40 changed files with 425 additions and 20 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
^_pkgdown\.yml$
^docs$
^pkgdown$
^cran-comments\.md$
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: CohortSurvival
Title: Estimate survival using the OMOP Common Data Model
Version: 0.2.4
Title: Estimate Survival from Common Data Model Cohorts
Version: 0.2.5
Authors@R: c(
person("Edward", "Burn", email = "[email protected]",
role = c("aut", "cre"),
Expand All @@ -16,7 +16,7 @@ Authors@R: c(
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.
Description: Estimate survival using data mapped to the Observational Medical Outcomes Partnership 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 Expand Up @@ -51,4 +51,4 @@ Suggests:
Config/testthat/edition: 3
Config/testthat/parallel: true
VignetteBuilder: knitr
URL: https://darwin-eu.github.io/CohortSurvival/
URL: https://darwin-eu-dev.github.io/CohortSurvival/
18 changes: 17 additions & 1 deletion R/addCohortSurvival.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@

# Copyright 2023 DARWIN EU®
#
# This file is part of CohortSurvival
#
# 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.

#' Add survival information to a cohort table
#' @param x cohort table to add survival information
Expand All @@ -21,6 +35,7 @@
#' @export
#'
#' @examples
#' \donttest{
#' cohort <- dplyr::tibble(
#' cohort_definition_id = c(1,1,1),
#' subject_id = c(1,2,3),
Expand All @@ -38,6 +53,7 @@
#' outcomeCohortTable = "cohort2",
#' outcomeCohortId = 1
#' )
#' }
#'
addCohortSurvival <- function(x,
cdm,
Expand Down
20 changes: 19 additions & 1 deletion R/benchmarkCohortSurvival.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Copyright 2023 DARWIN EU®
#
# This file is part of CohortSurvival
#
# 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.


#' Estimate performance of estimateSurvival function for benchmarking
#'
#' @param cdm CDM reference
Expand Down Expand Up @@ -29,15 +46,16 @@
#' @return tibble with performance of estimateSurvival function information,
#' according to the selected input parameters
#' @export
#' @importFrom tictoc
#'
#' @examples
#' \donttest{
#' cdm <- mockMGUS2cdm()
#' cdm$condition_occurrence <- cdm$death_cohort %>%
#' dplyr::rename("condition_start_date" = "cohort_start_date",
#' "condition_end_date" = "cohort_end_date")
#' surv_timings <- benchmarkCohortSurvival(
#' cdm, targetSize = 100, outcomeSize = 20)
#'}
#'
benchmarkCohortSurvival <- function(cdm,
targetSize,
Expand Down
21 changes: 21 additions & 0 deletions R/estimateSurvival.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# Copyright 2023 DARWIN EU®
#
# This file is part of CohortSurvival
#
# 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.


#' Estimate survival for a given event of interest using cohorts in the OMOP Common Data Model
#'
#' @param cdm CDM reference
Expand Down Expand Up @@ -31,6 +48,7 @@
#' @export
#'
#' @examples
#' \donttest{
#' cdm <- mockMGUS2cdm()
#' surv <- estimateSingleEventSurvival(
#' cdm = cdm,
Expand All @@ -40,6 +58,7 @@
#' outcomeCohortId = 1,
#' timeGap = 7
#' )
#' }
#'
estimateSingleEventSurvival <- function(cdm,
targetCohortTable,
Expand Down Expand Up @@ -157,6 +176,7 @@ estimateSingleEventSurvival <- function(cdm,
#' @export
#'
#' @examples
#' \donttest{
#' cdm <- mockMGUS2cdm()
#' surv <- estimateCompetingRiskSurvival(
#' cdm = cdm,
Expand All @@ -168,6 +188,7 @@ estimateSingleEventSurvival <- function(cdm,
#' competingOutcomeCohortId = 1,
#' timeGap = 7
#' )
#' }
#'
estimateCompetingRiskSurvival <- function(cdm,
targetCohortTable,
Expand Down
33 changes: 33 additions & 0 deletions R/generateDeathCohort.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Copyright 2023 DARWIN EU®
#
# This file is part of CohortSurvival
#
# 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.

#' To create a death cohort
#'
Expand All @@ -14,6 +29,24 @@
#' @export
#'
#' @examples
#' \donttest{
#' library(CDMConnector)
#' library(CohortSurvival)
#' cdm <- PatientProfiles::mockPatientProfiles()
#' deathTable <- dplyr::tibble(
#' person_id = c(1,2,3),
#' death_date = c(as.Date("2020-01-01"),
#' as.Date("2020-01-02"),
#' as.Date("2020-01-01")))
#' DBI::dbWithTransaction(attr(cdm, "dbcon"), {
#' DBI::dbWriteTable(attr(cdm, "dbcon"), "death",
#' deathTable, overwrite = TRUE)
#' })
#' cdm$death <- dplyr::tbl(attr(cdm, "dbcon"), "death")
#' cdm <- generateDeathCohortSet(cdm=cdm,
#' name = "death_cohort")
#' }

generateDeathCohortSet <- function(
cdm,
name,
Expand Down
15 changes: 15 additions & 0 deletions R/inputValidation.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Copyright 2023 DARWIN EU®
#
# This file is part of CohortSurvival
#
# 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.

checkCdm <- function(cdm, tables = NULL) {
if (!isTRUE(inherits(cdm, "cdm_reference"))) {
Expand Down
20 changes: 20 additions & 0 deletions R/mockMGUS2cdm.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
# Copyright 2023 DARWIN EU®
#
# This file is part of CohortSurvival
#
# 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.

#' Create mock CDM reference with survival::mgus2 dataset
#'
#' @return CDM reference containing data from the survival::mgus2 dataset
#' @export
#'
#' @examples
#' \donttest{
#' cdm <- mockMGUS2cdm()
#' cdm$person
#' }
mockMGUS2cdm <- function() {
mgus2 <- survival::mgus2 %>%
dplyr::mutate(
Expand Down
37 changes: 35 additions & 2 deletions R/plotSurvival.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2023 DARWIN EU®
#
# This file is part of CohortSurvival
#
# 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.

#' Plot survival results
#'
#' @param result Survival results
Expand All @@ -9,10 +25,19 @@
#' @param colour Variables to use for colours
#' @param colour_name Colour legend name
#'
#' @return A ggplot with the survival results plotted
#' @return A plot of survival probabilities over time
#' @export
#'
#' @examples
#' \donttest{
#' cdm <- mockMGUS2cdm()
#' surv <- estimateSingleEventSurvival(cdm,
#' targetCohortTable = "mgus_diagnosis",
#' outcomeCohortTable = "death_cohort")
#' plot <- plotSurvival(surv)
#' plot
#'}
#'
plotSurvival <- function(result,
x = "time",
xscale = "days",
Expand Down Expand Up @@ -63,10 +88,18 @@ plotSurvival <- function(result,
#' @param colour Variables to use for colours
#' @param colour_name Colour legend name
#'
#' @return
#' @return A plot of cumulative incidence over time
#' @export
#'
#' @examples
#' \donttest{
#' cdm <- mockMGUS2cdm()
#' surv <- estimateSingleEventSurvival(cdm,
#' targetCohortTable = "mgus_diagnosis",
#' outcomeCohortTable = "death_cohort")
#' plot <- plotCumulativeIncidence(surv)
#' plot
#'}
plotCumulativeIncidence <- function(result,
x = "time",
xscale = "days",
Expand Down
2 changes: 1 addition & 1 deletion R/recordAttrition.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright 2023 DARWIN EU®
#
# This file is part of IncidencePrevalence
# This file is part of CohortSurvival
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
15 changes: 15 additions & 0 deletions R/summariseSurvivalParticipants.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Copyright 2023 DARWIN EU®
#
# This file is part of CohortSurvival
#
# 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.

#' @importFrom PatientProfiles summariseCharacteristics
#' @export
Expand Down
16 changes: 16 additions & 0 deletions R/suppressSurvivalCounts.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Copyright 2023 DARWIN EU®
#
# This file is part of CohortSurvival
#
# 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.

suppressSurvivalCounts <- function(result,
minCellCount = 5) {

Expand Down
26 changes: 25 additions & 1 deletion R/survivalSummary.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
# Copyright 2023 DARWIN EU®
#
# This file is part of CohortSurvival
#
# 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.


#' Survival summary
#'
#' @param x Result from estimateSingleEventSurvival
#'
#' @return
#' @return A tibble containing a summary of observed survival
#' @export
#'
#' @examples
#' \donttest{
#' cdm <- mockMGUS2cdm()
#' surv <- estimateSingleEventSurvival(cdm,
#' targetCohortTable = "mgus_diagnosis",
#' outcomeCohortTable = "death_cohort")
#' survivalSummary(surv)
#'}
survivalSummary <- function(x){
attr(x, "summary")
}
Loading

0 comments on commit eed5e26

Please sign in to comment.