Cohort2Trajectory
a07_Cohort2Trajectory.Rmd
Introduction
R-package Cohort2Trajectory creates patient orientated treatment trajectories from cohorts defined in OHDSI ATLAS. The package can be used with access to OMOP CDM database. The package creates discrete and continuous time trajectories (and outputs them as .csv file) which describe patients’ treatment through time.
Usage
We have created wrappers to use the CohortContrast
output for creating trajectories in Cohort2Trajectory
.
NOTE! It will use only the concepts which are inside the
data_feature
dataframe and reported in
trajectoryDataList
object. The same features are shown on
plots if you load the CohortContrast
object in the
graphical user interface.
Firstly, we have to initiate the database connection and load (or
create) the CohortContrast
object.
# Initiate database connection & load data
pathToResults <- "./inst/example"
db <- DBI::dbConnect(duckdb::duckdb(), dbdir = CDMConnector::eunomia_dir("GiBleed"))
cdm <- CDMConnector::cdm_from_con(db , cdm_name = "eunomia", cdm_schema = "main", write_schema = "main")
data <- readRDS("./inst/example/example.rds")
Secondly, we have to import the data for the trajectories from the database.
# Import raw data for trajectory creation
data <- CohortContrast::createC2TInput(data, cdm)
Thirdly, we will call Cohort2Trajectory
execution
function. It has many parameters, but an easy example is given here, for
more info check references.
# Create trajectories
trajectories <- CohortContrast::C2TCaller(
data,
pathToResults
)
This will output a trajectory dataframe as well as save this a a csv
file to the pathToResults
path.