Intersecting the index and marker cohorts prior to calculating Sequence Symmetry Ratios
Source:R/generateSequenceCohortSet.R
generateSequenceCohortSet.Rd
Join two tables in the CDM (one for index and the other for marker cohorts) into a new table in the cdm taking into account the maximum time interval between events. Index and marker cohorts should be instantiated in advance by the user.
Arguments
- cdm
A CDM reference.
- indexTable
A table in the CDM that the index cohorts should come from.
- markerTable
A table in the CDM that the marker cohorts should come from.
- name
The name within the cdm that the output is called. Default is joined_cohorts.
- indexId
Cohort definition IDs in indexTable to be considered for the analysis. Change to NULL if all indices are wished to be included.
- markerId
Cohort definition IDs in markerTable to be considered for the analysis. Change to NULL if all markers are wished to be included.
- cohortDateRange
Two dates indicating study period and the sequences that the user wants to restrict to.
- daysPriorObservation
The minimum amount of prior observation required on both the index and marker cohorts per person.
- washoutWindow
A washout window to be applied on both the index cohort event and marker cohort.
- indexMarkerGap
The maximum allowable gap between the end of the first episode and the start of the second episode in a sequence/combination.
- combinationWindow
A constrain to be placed on the gap between two initiations. Default c(0,365), meaning the gap should be larger than 0 but less than or equal to 365.
- movingAverageRestriction
The moving window when calculating nSR, default is 548.
Examples
# \donttest{
library(CohortSymmetry)
cdm <- mockCohortSymmetry()
#> Warning: ! 9 column in cdm_source do not match expected column type:
#> • `cdm_source_abbreviation` is logical but expected character
#> • `cdm_holder` is logical but expected character
#> • `source_description` is logical but expected character
#> • `source_documentation_reference` is logical but expected character
#> • `cdm_etl_reference` is logical but expected character
#> • `source_release_date` is logical but expected date
#> • `cdm_release_date` is logical but expected date
#> • `cdm_version` is numeric but expected character
#> • `vocabulary_version` is logical but expected character
#> Warning: ! 3 column in concept do not match expected column type:
#> • `concept_id` is numeric but expected integer
#> • `valid_start_date` is character but expected date
#> • `valid_end_date` is character but expected date
#> Warning: ! 1 column in vocabulary do not match expected column type:
#> • `vocabulary_concept_id` is numeric but expected integer
#> Warning: ! 5 column in concept_relationship do not match expected column type:
#> • `concept_id_1` is numeric but expected integer
#> • `concept_id_2` is numeric but expected integer
#> • `valid_start_date` is logical but expected date
#> • `valid_end_date` is logical but expected date
#> • `invalid_reason` is logical but expected character
#> Warning: ! 2 column in concept_synonym do not match expected column type:
#> • `concept_id` is numeric but expected integer
#> • `language_concept_id` is numeric but expected integer
#> Warning: ! 4 column in concept_ancestor do not match expected column type:
#> • `ancestor_concept_id` is numeric but expected integer
#> • `descendant_concept_id` is numeric but expected integer
#> • `min_levels_of_separation` is numeric but expected integer
#> • `max_levels_of_separation` is numeric but expected integer
#> Warning: ! 9 column in drug_strength do not match expected column type:
#> • `drug_concept_id` is numeric but expected integer
#> • `ingredient_concept_id` is numeric but expected integer
#> • `amount_unit_concept_id` is numeric but expected integer
#> • `numerator_unit_concept_id` is numeric but expected integer
#> • `denominator_value` is logical but expected numeric
#> • `denominator_unit_concept_id` is numeric but expected integer
#> • `box_size` is numeric but expected integer
#> • `valid_start_date` is character but expected date
#> • `valid_end_date` is character but expected date
#> Warning: There are observation period end dates after the current date: 2024-11-15
#> ℹ The latest max observation period end date found is 2026-10-26
#> Note: method with signature ‘DBIConnection#Id’ chosen for function ‘dbExistsTable’,
#> target signature ‘duckdb_connection#Id’.
#> "duckdb_connection#ANY" would also be valid
#> Warning: There are observation period end dates after the current date: 2024-11-15
#> ℹ The latest max observation period end date found is 2026-10-26
cdm <- generateSequenceCohortSet(
cdm = cdm,
name = "joined_cohorts",
indexTable = "cohort_1",
markerTable = "cohort_2"
)
cdm$joined_cohorts
#> # Source: table<main.joined_cohorts> [?? x 6]
#> # Database: DuckDB v1.1.2 [unknown@Linux 6.5.0-1025-azure:R 4.4.2/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date index_date
#> <int> <int> <date> <date> <date>
#> 1 2 1 2020-04-01 2021-01-01 2020-04-01
#> 2 3 1 2019-05-25 2020-04-01 2020-04-01
#> 3 5 2 2022-05-22 2022-05-31 2022-05-22
#> 4 6 2 2022-05-22 2022-05-25 2022-05-22
#> 5 2 5 2019-08-01 2020-05-25 2019-08-01
#> 6 3 5 2019-08-01 2020-02-29 2019-08-01
#> 7 2 4 2021-05-25 2021-06-01 2021-06-01
#> 8 3 4 2021-06-01 2022-05-25 2021-06-01
#> 9 1 1 2020-04-01 2020-12-30 2020-04-01
#> 10 9 5 2019-04-07 2020-02-29 2019-04-07
#> # ℹ more rows
#> # ℹ 1 more variable: marker_date <date>
CDMConnector::cdmDisconnect(cdm = cdm)
# }