diff --git a/.Rbuildignore b/.Rbuildignore index 44c3a9e..55e976c 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -6,3 +6,4 @@ ^_pkgdown\.yml$ ^docs$ ^pkgdown$ +^cran-comments\.md$ diff --git a/DESCRIPTION b/DESCRIPTION index 524157f..10e160e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 = "edward.burn@ndorms.ox.ac.uk", role = c("aut", "cre"), @@ -16,7 +16,7 @@ Authors@R: c( person("Danielle", "Newby", email = "danielle.newby@ndorms.ox.ac.uk", 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) @@ -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/ diff --git a/R/addCohortSurvival.R b/R/addCohortSurvival.R index dddc98c..7e9de47 100644 --- a/R/addCohortSurvival.R +++ b/R/addCohortSurvival.R @@ -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 @@ -21,6 +35,7 @@ #' @export #' #' @examples +#' \donttest{ #' cohort <- dplyr::tibble( #' cohort_definition_id = c(1,1,1), #' subject_id = c(1,2,3), @@ -38,6 +53,7 @@ #' outcomeCohortTable = "cohort2", #' outcomeCohortId = 1 #' ) +#' } #' addCohortSurvival <- function(x, cdm, diff --git a/R/benchmarkCohortSurvival.R b/R/benchmarkCohortSurvival.R index 5755b7b..151ae08 100644 --- a/R/benchmarkCohortSurvival.R +++ b/R/benchmarkCohortSurvival.R @@ -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 @@ -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, diff --git a/R/estimateSurvival.R b/R/estimateSurvival.R index faf59be..ab79cf8 100644 --- a/R/estimateSurvival.R +++ b/R/estimateSurvival.R @@ -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 @@ -31,6 +48,7 @@ #' @export #' #' @examples +#' \donttest{ #' cdm <- mockMGUS2cdm() #' surv <- estimateSingleEventSurvival( #' cdm = cdm, @@ -40,6 +58,7 @@ #' outcomeCohortId = 1, #' timeGap = 7 #' ) +#' } #' estimateSingleEventSurvival <- function(cdm, targetCohortTable, @@ -157,6 +176,7 @@ estimateSingleEventSurvival <- function(cdm, #' @export #' #' @examples +#' \donttest{ #' cdm <- mockMGUS2cdm() #' surv <- estimateCompetingRiskSurvival( #' cdm = cdm, @@ -168,6 +188,7 @@ estimateSingleEventSurvival <- function(cdm, #' competingOutcomeCohortId = 1, #' timeGap = 7 #' ) +#' } #' estimateCompetingRiskSurvival <- function(cdm, targetCohortTable, diff --git a/R/generateDeathCohort.R b/R/generateDeathCohort.R index 12a47d4..e05de38 100644 --- a/R/generateDeathCohort.R +++ b/R/generateDeathCohort.R @@ -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 #' @@ -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, diff --git a/R/inputValidation.R b/R/inputValidation.R index 190dbbc..14f70a6 100644 --- a/R/inputValidation.R +++ b/R/inputValidation.R @@ -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"))) { diff --git a/R/mockMGUS2cdm.R b/R/mockMGUS2cdm.R index 0ed7793..49ed327 100644 --- a/R/mockMGUS2cdm.R +++ b/R/mockMGUS2cdm.R @@ -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( diff --git a/R/plotSurvival.R b/R/plotSurvival.R index 7888491..1041e8d 100644 --- a/R/plotSurvival.R +++ b/R/plotSurvival.R @@ -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 @@ -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", @@ -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", diff --git a/R/recordAttrition.R b/R/recordAttrition.R index 98f91e5..a9477ec 100644 --- a/R/recordAttrition.R +++ b/R/recordAttrition.R @@ -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. diff --git a/R/summariseSurvivalParticipants.R b/R/summariseSurvivalParticipants.R index 7acaf5e..743f867 100644 --- a/R/summariseSurvivalParticipants.R +++ b/R/summariseSurvivalParticipants.R @@ -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 diff --git a/R/suppressSurvivalCounts.R b/R/suppressSurvivalCounts.R index d15aa2c..0f8fe29 100644 --- a/R/suppressSurvivalCounts.R +++ b/R/suppressSurvivalCounts.R @@ -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) { diff --git a/R/survivalSummary.R b/R/survivalSummary.R index eeed4c1..2c8df9e 100644 --- a/R/survivalSummary.R +++ b/R/survivalSummary.R @@ -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") } diff --git a/R/utils-tidy-eval.R b/R/utils-tidy-eval.R index 09c3698..238906f 100644 --- a/R/utils-tidy-eval.R +++ b/R/utils-tidy-eval.R @@ -104,4 +104,5 @@ #' @importFrom rlang enquo enquos .data := as_name as_label #' @aliases enquo enquos .data := as_name as_label #' @export enquo enquos .data := as_name as_label +#' @return No return value, called for side effects NULL diff --git a/R/utils.R b/R/utils.R index fc66bf1..12a3448 100644 --- a/R/utils.R +++ b/R/utils.R @@ -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. + #' Participants contributing to a survival analysis #' #' @param result Result object @@ -7,6 +23,14 @@ #' @export #' #' @examples +#' \donttest{ +#' cdm <- mockMGUS2cdm() +#' surv <- estimateSingleEventSurvival(cdm, +#' targetCohortTable = "mgus_diagnosis", +#' outcomeCohortTable = "death_cohort", +#' returnParticipants = TRUE) +#' survivalParticipants(surv) +#'} survivalParticipants <- function(result) { attr(result, "participants") } diff --git a/README.Rmd b/README.Rmd index 3513cde..adb0614 100644 --- a/README.Rmd +++ b/README.Rmd @@ -120,7 +120,7 @@ plotSurvival(MGUS_death, facet= "strata_name") ``` -### Summary statisitics on survival +### Summary statistics on survival For single event analyses, we can extract restricted mean survival and median survival diff --git a/README.md b/README.md index e603349..1c1479b 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ plotSurvival(MGUS_death, -### Summary statisitics on survival +### Summary statistics on survival For single event analyses, we can extract restricted mean survival and median survival diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000..e7ab6ec --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,3 @@ +## R CMD check results + +This is a new release. diff --git a/inst/WORDLIST b/inst/WORDLIST new file mode 100644 index 0000000..b489f3b --- /dev/null +++ b/inst/WORDLIST @@ -0,0 +1,34 @@ +CDM +CDMConnector +CMD +Colour +Lifecycle +MGUS +Metaprogramming +OMOP +ORCID +Postgres +Summarising +benchmarking +cdm +colours +dplyr +estimateSingleEventSurvival +estimateSurvival +eval +gammopathy +ggplot +magrittr +mgus +returnParticipants +rlang +stratifications +summarise +summarises +summarising +targetCohortId +targetCohortTable +tibble +timeGap +tunnelled +tunnelling diff --git a/man/CohortSurvival-package.Rd b/man/CohortSurvival-package.Rd index 528b814..763e40a 100644 --- a/man/CohortSurvival-package.Rd +++ b/man/CohortSurvival-package.Rd @@ -4,14 +4,14 @@ \name{CohortSurvival-package} \alias{CohortSurvival} \alias{CohortSurvival-package} -\title{CohortSurvival: Estimate survival using the OMOP Common Data Model} +\title{CohortSurvival: Estimate Survival from Common Data Model Cohorts} \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. +Estimate survival using data mapped to the Observational Medical Outcomes Partnership common data model. Survival can be estimated based on user-defined study cohorts. } \seealso{ Useful links: \itemize{ - \item \url{https://darwin-eu.github.io/CohortSurvival/} + \item \url{https://darwin-eu-dev.github.io/CohortSurvival/} } } diff --git a/man/addCohortSurvival.Rd b/man/addCohortSurvival.Rd index 4f9c431..f55185e 100644 --- a/man/addCohortSurvival.Rd +++ b/man/addCohortSurvival.Rd @@ -46,6 +46,7 @@ whether the patient had the event (value: 1), or did not have the event Add survival information to a cohort table } \examples{ +\donttest{ cohort <- dplyr::tibble( cohort_definition_id = c(1,1,1), subject_id = c(1,2,3), @@ -63,5 +64,6 @@ cdm$cohort1 <- cdm$cohort1 \%>\% outcomeCohortTable = "cohort2", outcomeCohortId = 1 ) + } } diff --git a/man/benchmarkCohortSurvival.Rd b/man/benchmarkCohortSurvival.Rd index 169993d..3dcf44f 100644 --- a/man/benchmarkCohortSurvival.Rd +++ b/man/benchmarkCohortSurvival.Rd @@ -69,11 +69,13 @@ according to the selected input parameters Estimate performance of estimateSurvival function for benchmarking } \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) +} } diff --git a/man/estimateCompetingRiskSurvival.Rd b/man/estimateCompetingRiskSurvival.Rd index 0a33a0d..abf10a8 100644 --- a/man/estimateCompetingRiskSurvival.Rd +++ b/man/estimateCompetingRiskSurvival.Rd @@ -79,6 +79,7 @@ Estimate survival for a given event and competing risk of interest using cohorts in the OMOP Common Data Model } \examples{ +\donttest{ cdm <- mockMGUS2cdm() surv <- estimateCompetingRiskSurvival( cdm = cdm, @@ -90,5 +91,6 @@ surv <- estimateCompetingRiskSurvival( competingOutcomeCohortId = 1, timeGap = 7 ) +} } diff --git a/man/estimateSingleEventSurvival.Rd b/man/estimateSingleEventSurvival.Rd index 7165ce3..7e83d64 100644 --- a/man/estimateSingleEventSurvival.Rd +++ b/man/estimateSingleEventSurvival.Rd @@ -67,6 +67,7 @@ outputted as an attribute of the output Estimate survival for a given event of interest using cohorts in the OMOP Common Data Model } \examples{ +\donttest{ cdm <- mockMGUS2cdm() surv <- estimateSingleEventSurvival( cdm = cdm, @@ -76,5 +77,6 @@ surv <- estimateSingleEventSurvival( outcomeCohortId = 1, timeGap = 7 ) +} } diff --git a/man/figures/README-unnamed-chunk-11-1.png b/man/figures/README-unnamed-chunk-11-1.png index 76ca092..03c35ce 100644 Binary files a/man/figures/README-unnamed-chunk-11-1.png and b/man/figures/README-unnamed-chunk-11-1.png differ diff --git a/man/figures/README-unnamed-chunk-12-1.png b/man/figures/README-unnamed-chunk-12-1.png index 86038b3..a2bf84b 100644 Binary files a/man/figures/README-unnamed-chunk-12-1.png and b/man/figures/README-unnamed-chunk-12-1.png differ diff --git a/man/generateDeathCohortSet.Rd b/man/generateDeathCohortSet.Rd index 27f7f51..2b814f1 100644 --- a/man/generateDeathCohortSet.Rd +++ b/man/generateDeathCohortSet.Rd @@ -33,3 +33,22 @@ A cohort table with a death cohort in cdm \description{ To create a death cohort } +\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") +} +} diff --git a/man/mockMGUS2cdm.Rd b/man/mockMGUS2cdm.Rd index 21342a3..dd206fb 100644 --- a/man/mockMGUS2cdm.Rd +++ b/man/mockMGUS2cdm.Rd @@ -12,3 +12,9 @@ CDM reference containing data from the survival::mgus2 dataset \description{ Create mock CDM reference with survival::mgus2 dataset } +\examples{ + \donttest{ +cdm <- mockMGUS2cdm() +cdm$person +} +} diff --git a/man/plotCumulativeIncidence.Rd b/man/plotCumulativeIncidence.Rd index cdd6acb..5bc4b49 100644 --- a/man/plotCumulativeIncidence.Rd +++ b/man/plotCumulativeIncidence.Rd @@ -32,6 +32,19 @@ plotCumulativeIncidence( \item{colour_name}{Colour legend name} } +\value{ +A plot of cumulative incidence over time +} \description{ Plot cumulative incidence } +\examples{ +\donttest{ +cdm <- mockMGUS2cdm() +surv <- estimateSingleEventSurvival(cdm, + targetCohortTable = "mgus_diagnosis", + outcomeCohortTable = "death_cohort") +plot <- plotCumulativeIncidence(surv) +plot +} +} diff --git a/man/plotSurvival.Rd b/man/plotSurvival.Rd index 72a0901..85b7040 100644 --- a/man/plotSurvival.Rd +++ b/man/plotSurvival.Rd @@ -33,8 +33,19 @@ plotSurvival( \item{colour_name}{Colour legend name} } \value{ -A ggplot with the survival results plotted +A plot of survival probabilities over time } \description{ Plot survival results } +\examples{ +\donttest{ +cdm <- mockMGUS2cdm() +surv <- estimateSingleEventSurvival(cdm, + targetCohortTable = "mgus_diagnosis", + outcomeCohortTable = "death_cohort") +plot <- plotSurvival(surv) +plot +} + +} diff --git a/man/survivalParticipants.Rd b/man/survivalParticipants.Rd index 42595bd..8ec2b01 100644 --- a/man/survivalParticipants.Rd +++ b/man/survivalParticipants.Rd @@ -16,3 +16,13 @@ a given analysis \description{ Participants contributing to a survival analysis } +\examples{ +\donttest{ +cdm <- mockMGUS2cdm() +surv <- estimateSingleEventSurvival(cdm, + targetCohortTable = "mgus_diagnosis", + outcomeCohortTable = "death_cohort", + returnParticipants = TRUE) +survivalParticipants(surv) +} +} diff --git a/man/survivalSummary.Rd b/man/survivalSummary.Rd index ff9d8b2..28adb37 100644 --- a/man/survivalSummary.Rd +++ b/man/survivalSummary.Rd @@ -9,6 +9,18 @@ survivalSummary(x) \arguments{ \item{x}{Result from estimateSingleEventSurvival} } +\value{ +A tibble containing a summary of observed survival +} \description{ Survival summary } +\examples{ +\donttest{ +cdm <- mockMGUS2cdm() +surv <- estimateSingleEventSurvival(cdm, + targetCohortTable = "mgus_diagnosis", + outcomeCohortTable = "death_cohort") +survivalSummary(surv) +} +} diff --git a/man/tidyeval.Rd b/man/tidyeval.Rd index f773abf..5abf2ec 100644 --- a/man/tidyeval.Rd +++ b/man/tidyeval.Rd @@ -9,6 +9,9 @@ \alias{as_name} \alias{as_label} \title{Tidy eval helpers} +\value{ +No return value, called for side effects +} \description{ This page lists the tidy eval tools reexported in this package from rlang. To learn about using tidy eval in scripts and packages at a diff --git a/tests/testthat/test-addCohortSurvival.R b/tests/testthat/test-addCohortSurvival.R index ae4146d..cadfd22 100644 --- a/tests/testthat/test-addCohortSurvival.R +++ b/tests/testthat/test-addCohortSurvival.R @@ -40,6 +40,8 @@ test_that("working example", { }) test_that("another working example", { + skip_on_cran() + if (Sys.getenv("EUNOMIA_DATA_FOLDER") == "") { Sys.setenv("EUNOMIA_DATA_FOLDER" = tempdir()) } @@ -144,7 +146,9 @@ test_that("another working example", { }) test_that("censorOnCohortExit", { - cohort <- dplyr::tibble( + skip_on_cran() + + cohort <- dplyr::tibble( cohort_definition_id = c(1,1,1), subject_id = c(1,2,3), cohort_start_date = c(as.Date("2020-01-01"), @@ -228,6 +232,8 @@ test_that("censorOnCohortExit", { }) test_that("censorOnDate", { + skip_on_cran() + cohort <- dplyr::tibble( cohort_definition_id = c(1,1,1), subject_id = c(1,2,3), @@ -305,6 +311,8 @@ test_that("censorOnDate", { }) test_that("followUpDays", { + skip_on_cran() + cohort <- dplyr::tibble( cohort_definition_id = c(1,1,1), subject_id = c(1,2,3), @@ -388,6 +396,7 @@ test_that("followUpDays", { }) test_that("expected errors", { + skip_on_cran() cdm <- PatientProfiles::mockPatientProfiles() cdm[["cohort1"]] <- cdm[["cohort1"]] %>% dplyr::filter(cohort_start_date != "2020-01-01") @@ -467,6 +476,7 @@ test_that("expected errors", { }) test_that("expected errors2 - index cohort to have one row per person", { + skip_on_cran() cdm <- PatientProfiles::mockPatientProfiles() expect_error(cdm$cohort1 %>% addCohortSurvival( @@ -478,6 +488,7 @@ test_that("expected errors2 - index cohort to have one row per person", { }) test_that("within cohort survival", { + skip_on_cran() cohort <- dplyr::tibble( cohort_definition_id = c(1,1,1), subject_id = c(1,2,3), @@ -550,6 +561,7 @@ test_that("within cohort survival", { }) test_that("allow overwrite of time and status", { + skip_on_cran() cohort <- dplyr::tibble( cohort_definition_id = c(1,1,1), subject_id = c(1,2,3), @@ -608,6 +620,7 @@ test_that("allow overwrite of time and status", { }) test_that("multiple records per person", { + skip_on_cran() exposure_cohort <- dplyr::tibble( subject_id = c(1, 1, 2, 2, 3), diff --git a/tests/testthat/test-benchmarkCohortSurvival.R b/tests/testthat/test-benchmarkCohortSurvival.R index b5514c0..1d79664 100644 --- a/tests/testthat/test-benchmarkCohortSurvival.R +++ b/tests/testthat/test-benchmarkCohortSurvival.R @@ -1,4 +1,6 @@ test_that("mgus example: benchmark", { + skip_on_cran() + cdm <- mockMGUS2cdm() cdm$condition_occurrence <- cdm$death_cohort %>% dplyr::rename("condition_start_date" = "cohort_start_date", @@ -56,6 +58,8 @@ test_that("mgus example: benchmark", { }) test_that("expected errors benchmark", { + skip_on_cran() + cdm <- mockMGUS2cdm() cdm$condition_occurrence <- cdm$death_cohort %>% dplyr::rename("condition_start_date" = "cohort_start_date", diff --git a/tests/testthat/test-estimateSurvival.R b/tests/testthat/test-estimateSurvival.R index b9c6a06..bc754b3 100644 --- a/tests/testthat/test-estimateSurvival.R +++ b/tests/testthat/test-estimateSurvival.R @@ -101,6 +101,8 @@ test_that("mgus example: no Competing risk", { }) test_that("mgus example: no Competing risk, strata", { + skip_on_cran() + cdm <- mockMGUS2cdm() cdm[["mgus_diagnosis"]] <- cdm[["mgus_diagnosis"]] %>% dplyr::mutate(mspike_r = round(mspike, digits = 0)) @@ -143,6 +145,7 @@ test_that("mgus example: no Competing risk, strata", { }) test_that("mgus example: Competing risk, strata", { + skip_on_cran() cdm <- mockMGUS2cdm() cdm[["mgus_diagnosis"]] <- cdm[["mgus_diagnosis"]] %>% dplyr::mutate(mspike_r = round(mspike, digits = 0)) @@ -196,6 +199,7 @@ test_that("mgus example: Competing risk, strata", { }) test_that("multiple exposures, multiple outcomes: single event", { + skip_on_cran() observation_period <- dplyr::tibble( observation_period_id = c(1, 2, 3, 4, 5), @@ -338,6 +342,7 @@ test_that("multiple exposures, multiple outcomes: single event", { }) test_that("multiple exposures, multiple outcomes: competing risk", { + skip_on_cran() observation_period <- dplyr::tibble( observation_period_id = c(1, 2, 3, 4, 5,6), @@ -523,6 +528,7 @@ test_that("multiple exposures, multiple outcomes: competing risk", { }) test_that("funcionality with created dataset", { + skip_on_cran() exposure_cohort <- dplyr::tibble( subject_id = c(1, 2, 3), cohort_definition_id = c(1, 1, 1), @@ -904,6 +910,7 @@ test_that("funcionality with created dataset", { }) test_that("different exposure cohort ids", { + skip_on_cran() cohort <- dplyr::tibble( cohort_definition_id = c(1, 1, 2), subject_id = c(1, 2, 3), @@ -1000,6 +1007,7 @@ test_that("different exposure cohort ids", { }) test_that("expected errors", { + skip_on_cran() cdm <- mockMGUS2cdm() expect_error(estimateSurvival("cdm", targetCohortTable = "mgus_diagnosis", outcomeCohortTable = "progression")) @@ -1017,6 +1025,7 @@ test_that("expected errors", { }) test_that("return participants", { + skip_on_cran() cdm <- mockMGUS2cdm() surv1 <- estimateSingleEventSurvival(cdm, targetCohortTable = "mgus_diagnosis", @@ -1049,6 +1058,7 @@ test_that("return participants", { }) test_that("within cohort survival", { + skip_on_cran() cohort <- dplyr::tibble( cohort_definition_id = c(1, 1, 1), subject_id = c(1, 2, 3), @@ -1097,6 +1107,7 @@ test_that("within cohort survival", { }) test_that("strata specific survival", { + skip_on_cran() exposure_cohort <- dplyr::tibble( subject_id = c(1, 2, 3, 4, 5), @@ -1263,6 +1274,7 @@ test_that("strata specific survival", { }) test_that("multiple rows per person - same observation period", { + skip_on_cran() exposure_cohort <- dplyr::tibble( subject_id = c(1, 1, 2, 2, 3,4), @@ -1360,6 +1372,7 @@ CDMConnector::cdm_disconnect(cdm) }) test_that("multiple outcomes competing risk", { + skip_on_cran() cdm <- mockMGUS2cdm() result <- estimateCompetingRiskSurvival( @@ -1387,7 +1400,8 @@ test_that("multiple outcomes competing risk", { }) test_that("empty cohort table", { -cdm <- mockMGUS2cdm() + skip_on_cran() + cdm <- mockMGUS2cdm() cdm$progression_type <- cdm$progression_type %>% dplyr::filter(.data$cohort_definition_id != 1) %>% @@ -1405,6 +1419,7 @@ CDMConnector::cdm_disconnect(cdm) }) test_that("min cell count", { + skip_on_cran() cdm <- mockMGUS2cdm() surv <- estimateSingleEventSurvival(cdm, targetCohortTable = "mgus_diagnosis", diff --git a/tests/testthat/test-generateDeathCohort.R b/tests/testthat/test-generateDeathCohort.R index 5c91b15..793e14a 100644 --- a/tests/testthat/test-generateDeathCohort.R +++ b/tests/testthat/test-generateDeathCohort.R @@ -1,4 +1,5 @@ test_that("basic example", { + skip_on_cran() cdm <- PatientProfiles::mockPatientProfiles() deathTable <- dplyr::tibble( @@ -25,6 +26,7 @@ test_that("basic example", { }) test_that("first death record per person", { + skip_on_cran() # check that in the case of multiple death records per person # only the first will be used cdm <- PatientProfiles::mockPatientProfiles() @@ -56,6 +58,7 @@ test_that("first death record per person", { }) test_that("test death in observation criteria", { + skip_on_cran() observation_period <- tibble::tibble( observation_period_id = c(1, 2), @@ -98,6 +101,7 @@ test_that("test death in observation criteria", { }) test_that("test different cohort table name", { + skip_on_cran() cdm <- PatientProfiles::mockPatientProfiles() @@ -125,6 +129,7 @@ test_that("test different cohort table name", { }) test_that("test subsetting death table by a cohort table", { + skip_on_cran() cohort1 <- tibble::tibble( cohort_definition_id = c(1,1,2), @@ -176,6 +181,7 @@ test_that("test subsetting death table by a cohort table", { }) test_that("test expected errors", { + skip_on_cran() cohort1 <- tibble::tibble( cohort_definition_id = c(1,1,1), @@ -214,6 +220,7 @@ test_that("test expected errors", { }) test_that("test single permanent table created", { + skip_on_cran() cdm <- PatientProfiles::mockPatientProfiles() deathTable <- dplyr::tibble( diff --git a/tests/testthat/test-mockMGUS2cdm.R b/tests/testthat/test-mockMGUS2cdm.R index 0e65cb0..ae497b1 100644 --- a/tests/testthat/test-mockMGUS2cdm.R +++ b/tests/testthat/test-mockMGUS2cdm.R @@ -1,4 +1,5 @@ test_that("mock mgus2 as a cdm reference", { + skip_on_cran() cdm <- mockMGUS2cdm() expect_true(cdm$person %>% diff --git a/tests/testthat/test-plotSurvival.R b/tests/testthat/test-plotSurvival.R index 5b08cc4..9121828 100644 --- a/tests/testthat/test-plotSurvival.R +++ b/tests/testthat/test-plotSurvival.R @@ -1,4 +1,5 @@ test_that("basic Survival plot", { + skip_on_cran() cdm <- mockMGUS2cdm() surv <- estimateSingleEventSurvival(cdm, @@ -16,6 +17,7 @@ test_that("basic Survival plot", { }) test_that("plot years on x axis", { + skip_on_cran() cdm <- mockMGUS2cdm() surv <- estimateSingleEventSurvival(cdm, @@ -33,6 +35,7 @@ test_that("plot years on x axis", { }) test_that("plot facets", { + skip_on_cran() cdm <- mockMGUS2cdm() surv <- estimateSingleEventSurvival(cdm, @@ -52,6 +55,7 @@ test_that("plot facets", { }) test_that("plot facets - multiple column", { + skip_on_cran() cdm <- mockMGUS2cdm() surv <- estimateSingleEventSurvival(cdm, @@ -71,6 +75,7 @@ test_that("plot facets - multiple column", { }) test_that("plot colour", { + skip_on_cran() cdm <- mockMGUS2cdm() surv <- estimateSingleEventSurvival(cdm, @@ -91,6 +96,7 @@ test_that("plot colour", { }) test_that("basic cumulative incidence plot", { + skip_on_cran() cdm <- mockMGUS2cdm() surv <- estimateSingleEventSurvival(cdm, @@ -108,6 +114,7 @@ test_that("basic cumulative incidence plot", { }) test_that("plot facets for cumulative incidence plots", { + skip_on_cran() cdm <- mockMGUS2cdm() surv <- estimateSingleEventSurvival(cdm, @@ -126,8 +133,8 @@ test_that("plot facets for cumulative incidence plots", { }) - test_that("plot colour for cumulative incidence plots", { + skip_on_cran() cdm <- mockMGUS2cdm() surv <- estimateSingleEventSurvival(cdm, diff --git a/tests/testthat/test-survivalSummary.R b/tests/testthat/test-survivalSummary.R index 578f6e3..d1e06a4 100644 --- a/tests/testthat/test-survivalSummary.R +++ b/tests/testthat/test-survivalSummary.R @@ -1,5 +1,7 @@ test_that("survival summary", { - cdm <- mockMGUS2cdm() + skip_on_cran() + + cdm <- mockMGUS2cdm() surv <- estimateSingleEventSurvival(cdm, targetCohortTable = "mgus_diagnosis", targetCohortId = 1,