Title: | Sequence Symmetry Analysis Using the Observational Medical Outcomes Partnership Common Data Model |
---|---|
Description: | Calculating crude sequence ratio, adjusted sequence ratio and confidence intervals using data mapped to the Observational Medical Outcomes Partnership Common Data Model. |
Authors: | Xihang Chen [aut, cre] , Tyman Stanford [aut] , Berta Raventós [aut] , Nicole Pratt [aut] , Ed Burn [aut] , Marti Català [aut] , Danielle Newby [aut] , Núria Mercadé-Besora [aut] , Mike Du [aut] , Yuchen Guo [aut] , Kim Lopez [aut] , Marta Alcalde-Herraiz [aut] |
Maintainer: | Xihang Chen <[email protected]> |
License: | Apache License (>= 2) |
Version: | 0.1.4 |
Built: | 2024-11-15 13:38:25 UTC |
Source: | https://github.com/ohdsi/cohortsymmetry |
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.
generateSequenceCohortSet( cdm, indexTable, markerTable, name, indexId = NULL, markerId = NULL, cohortDateRange = as.Date(c(NA, NA)), daysPriorObservation = 0, washoutWindow = 0, indexMarkerGap = Inf, combinationWindow = c(0, 365), movingAverageRestriction = 548 )
generateSequenceCohortSet( cdm, indexTable, markerTable, name, indexId = NULL, markerId = NULL, cohortDateRange = as.Date(c(NA, NA)), daysPriorObservation = 0, washoutWindow = 0, indexMarkerGap = Inf, combinationWindow = c(0, 365), movingAverageRestriction = 548 )
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. |
A table within the cdm reference.
library(CohortSymmetry) cdm <- mockCohortSymmetry() cdm <- generateSequenceCohortSet( cdm = cdm, name = "joined_cohorts", indexTable = "cohort_1", markerTable = "cohort_2" ) cdm$joined_cohorts CDMConnector::cdmDisconnect(cdm = cdm)
library(CohortSymmetry) cdm <- mockCohortSymmetry() cdm <- generateSequenceCohortSet( cdm = cdm, name = "joined_cohorts", indexTable = "cohort_1", markerTable = "cohort_2" ) cdm$joined_cohorts CDMConnector::cdmDisconnect(cdm = cdm)
Creates a mock cdm with two default synthetic cohorts, one is the index cohort and the other one is the marker cohort. However the users could specify them should they wish.
mockCohortSymmetry( seed = 1, indexCohort = NULL, markerCohort = NULL, con = DBI::dbConnect(duckdb::duckdb(), ":memory:"), schema = "main" )
mockCohortSymmetry( seed = 1, indexCohort = NULL, markerCohort = NULL, con = DBI::dbConnect(duckdb::duckdb(), ":memory:"), schema = "main" )
seed |
The seed to be inputted. |
indexCohort |
The tibble of your index cohort. Default is NULL, which means the default indexCohort is being used. |
markerCohort |
The tibble of your marker cohort. Default is NULL, which means the default markerCohort is being used. |
con |
Connection detail. |
schema |
Name of your write schema. |
A mock cdm object contains your index and marker cohort
library(CohortSymmetry) cdm <- mockCohortSymmetry() cdm CDMConnector::cdmDisconnect(cdm = cdm)
library(CohortSymmetry) cdm <- mockCohortSymmetry() cdm CDMConnector::cdmDisconnect(cdm = cdm)
It provides a ggplot of the sequence ratios of index and marker cohorts.
plotSequenceRatios( result, onlyaSR = FALSE, plotTitle = NULL, labs = c("SR", "Drug Pairs"), colours = c("red", "blue") )
plotSequenceRatios( result, onlyaSR = FALSE, plotTitle = NULL, labs = c("SR", "Drug Pairs"), colours = c("red", "blue") )
result |
Table output from summariseSequenceRatios. |
onlyaSR |
If the only SR to be plotted is the adjusted SR. |
plotTitle |
Title of the plot, if NULL no title will be plotted. |
labs |
Axis labels for the plot. |
colours |
Colours for both parts of the plot, pre- and post- time 0. |
A plot for the sequence ratios of index and marker cohorts.
library(CohortSymmetry) cdm <- mockCohortSymmetry() cdm <- generateSequenceCohortSet(cdm = cdm, indexTable = "cohort_1", markerTable = "cohort_2", name = "joined_cohort") sequence_ratio <- summariseSequenceRatios(cohort = cdm$joined_cohort, minCellCount = 0) plotSequenceRatios(result = sequence_ratio) CDMConnector::cdmDisconnect(cdm = cdm)
library(CohortSymmetry) cdm <- mockCohortSymmetry() cdm <- generateSequenceCohortSet(cdm = cdm, indexTable = "cohort_1", markerTable = "cohort_2", name = "joined_cohort") sequence_ratio <- summariseSequenceRatios(cohort = cdm$joined_cohort, minCellCount = 0) plotSequenceRatios(result = sequence_ratio) CDMConnector::cdmDisconnect(cdm = cdm)
It provides a ggplot of the temporal symmetry of two or more cohorts.
plotTemporalSymmetry( result, plotTitle = NULL, labs = c("Time (months)", "Individuals (N)"), xlim = c(-12, 12), colours = c("blue", "red"), scales = "free" )
plotTemporalSymmetry( result, plotTitle = NULL, labs = c("Time (months)", "Individuals (N)"), xlim = c(-12, 12), colours = c("blue", "red"), scales = "free" )
result |
Table output from summariseTemporalSymmetry. |
plotTitle |
Title of the plot, if NULL no title will be plotted. |
labs |
Axis labels for the plot. |
xlim |
Limits for the x axis of the plot. |
colours |
Colours for both parts of the plot, pre- and post- time 0. |
scales |
Whether to set free y scales for the facet wrap when there are multiple plots (i.e. each plot has its own scaled y axis) or set them equal for all. Only accepts "free" for the former and "fixed" for the latter. |
A plot for the temporal symmetry of cohorts.
library(CohortSymmetry) cdm <- mockCohortSymmetry() cdm <- generateSequenceCohortSet(cdm = cdm, indexTable = "cohort_1", markerTable = "cohort_2", name = "joined_cohort") temporal_symmetry <- summariseTemporalSymmetry(cohort = cdm$joined_cohort, minCellCount = 0) plotTemporalSymmetry(result = temporal_symmetry) CDMConnector::cdmDisconnect(cdm = cdm)
library(CohortSymmetry) cdm <- mockCohortSymmetry() cdm <- generateSequenceCohortSet(cdm = cdm, indexTable = "cohort_1", markerTable = "cohort_2", name = "joined_cohort") temporal_symmetry <- summariseTemporalSymmetry(cohort = cdm$joined_cohort, minCellCount = 0) plotTemporalSymmetry(result = temporal_symmetry) CDMConnector::cdmDisconnect(cdm = cdm)
Using generateSequenceCohortSet to obtain sequence ratios for the desired outcomes.
summariseSequenceRatios( cohort, cohortId = NULL, confidenceInterval = 95, minCellCount = 5 )
summariseSequenceRatios( cohort, cohortId = NULL, confidenceInterval = 95, minCellCount = 5 )
cohort |
A cohort table in the cdm. |
cohortId |
The Ids in the cohort that are to be included in the analyses. |
confidenceInterval |
Default is 95, indicating the central 95% confidence interval. |
minCellCount |
The minimum number of events to reported, below which results will be obscured. If 0, all results will be reported. |
A local table with all the analyses.
library(CohortSymmetry) cdm <- mockCohortSymmetry() cdm <- generateSequenceCohortSet(cdm = cdm, name = "joined_cohorts", indexTable = "cohort_1", markerTable = "cohort_2") pssa_result <- summariseSequenceRatios(cohort = cdm$joined_cohorts, minCellCount = 0) pssa_result CDMConnector::cdmDisconnect(cdm)
library(CohortSymmetry) cdm <- mockCohortSymmetry() cdm <- generateSequenceCohortSet(cdm = cdm, name = "joined_cohorts", indexTable = "cohort_1", markerTable = "cohort_2") pssa_result <- summariseSequenceRatios(cohort = cdm$joined_cohorts, minCellCount = 0) pssa_result CDMConnector::cdmDisconnect(cdm)
Using generateSequenceCohortSet to obtain temporal symmetry (aggregated counts) of two cohorts.
summariseTemporalSymmetry( cohort, cohortId = NULL, timescale = "month", minCellCount = 5 )
summariseTemporalSymmetry( cohort, cohortId = NULL, timescale = "month", minCellCount = 5 )
cohort |
A cohort table in the cdm. |
cohortId |
The Ids in the cohort that are to be included in the analyses. |
timescale |
Timescale for the x axis of the plot (month, day, year). |
minCellCount |
The minimum number of events to reported, below which results will be obscured. If 0, all results will be reported. |
An aggregated table with difference in time (marker - index) and the relevant counts.
library(CohortSymmetry) cdm <- mockCohortSymmetry() cdm <- generateSequenceCohortSet(cdm = cdm, name = "joined_cohorts", indexTable = "cohort_1", markerTable = "cohort_2") temporal_symmetry <- summariseTemporalSymmetry(cohort = cdm$joined_cohorts) CDMConnector::cdmDisconnect(cdm)
library(CohortSymmetry) cdm <- mockCohortSymmetry() cdm <- generateSequenceCohortSet(cdm = cdm, name = "joined_cohorts", indexTable = "cohort_1", markerTable = "cohort_2") temporal_symmetry <- summariseTemporalSymmetry(cohort = cdm$joined_cohorts) CDMConnector::cdmDisconnect(cdm)
It provides a formatted table with the contents of the summariseSequenceRatios output.
tableSequenceRatios( result, type = "gt", estimateNameFormat = c(`N (%)` = "<count> (<percentage> %)", `SR (CI)` = "<point_estimate> (<lower_CI> - <upper_CI>)"), style = "default", studyPopulation = TRUE, cdmName = TRUE, .options = NULL )
tableSequenceRatios( result, type = "gt", estimateNameFormat = c(`N (%)` = "<count> (<percentage> %)", `SR (CI)` = "<point_estimate> (<lower_CI> - <upper_CI>)"), style = "default", studyPopulation = TRUE, cdmName = TRUE, .options = NULL )
result |
A sequence_symmetry object. |
type |
Type of desired formatted table, possibilities: "gt", "flextable", "tibble". |
estimateNameFormat |
The columns that the user wishes to see for the formatted table, by default it would display both the counts and sequence ratios. |
style |
Named list that specifies how to style the different parts of a gt table or flextable. See visOmopResults package for more information on how to define a style. Alternatively, use "default" to get visOmopResults style, or NULL for gt/flextable default styling. |
studyPopulation |
whether to report the study population. |
cdmName |
whether to report database names. |
.options |
named list with additional formatting options. tableSequenceRatiosOptions() shows allowed arguments and their default values. |
A formatted version of the sequence_symmetry object.
library(CohortSymmetry) cdm <- mockCohortSymmetry() cdm <- generateSequenceCohortSet(cdm = cdm, indexTable = "cohort_1", markerTable = "cohort_2", name = "joined_cohort") res <- summariseSequenceRatios(cohort = cdm$joined_cohort) gtResult <- tableSequenceRatios(res) CDMConnector::cdmDisconnect(cdm = cdm)
library(CohortSymmetry) cdm <- mockCohortSymmetry() cdm <- generateSequenceCohortSet(cdm = cdm, indexTable = "cohort_1", markerTable = "cohort_2", name = "joined_cohort") res <- summariseSequenceRatios(cohort = cdm$joined_cohort) gtResult <- tableSequenceRatios(res) CDMConnector::cdmDisconnect(cdm = cdm)
It provides a list of allowed inputs for .option argument in tableSequenceRatios and their given default value.
tableSequenceRatiosOptions()
tableSequenceRatiosOptions()
The default .options named list.
{ tableSequenceRatiosOptions() }
{ tableSequenceRatiosOptions() }