aou_atlas_cohort {allofus} | R Documentation |
Retrieve a cohort from ATLAS for use in All of Us
Description
Retrieves a cohort definition from ATLAS and generates the cohort in All of
Us. Observation periods are first generated for each subject using the
aou_observation_period()
function.The resulting cohort is a table with the
cohort start and end dates for each person_id.
Usage
aou_atlas_cohort(
cohort_definition,
cohort_sql,
debug = FALSE,
collect = FALSE,
...,
con = getOption("aou.default.con")
)
Arguments
cohort_definition |
A cohort definition generated using
|
cohort_sql |
The cohort_sql generated using |
debug |
Print the query to the console; useful for debugging. |
collect |
Whether to bring the resulting table into local memory
( |
... |
Further arguments passed along to |
con |
Connection to the allofus SQL database. Defaults to
getOption("aou.default.con"), which is set automatically if you use
|
Details
The function is based on a similar function in https://github.com/cmayer2/r4aou with some tweaks to generate the appropriate observation periods and incorporate other package functions. Please see the online vignette for additional details.
Value
A dataframe if collect = TRUE
; a reference to a remote database
table if not. The SQL query used to generate the cohort is stored as an
attribute.
Examples
# generate a simple stroke cohort
# see https://atlas-demo.ohdsi.org/#/cohortdefinition/1788061
# If this cohort is not available, you can create one, or choose one already made.
# aou_cohort_example contains the results of
# cd <- ROhdsiWebApi::getCohortDefinition(1788061, "https://atlas-demo.ohdsi.org/WebAPI")
# cd_sql <- ROhdsiWebApi::getCohortSql(cd, "https://atlas-demo.ohdsi.org/WebAPI")
cohort <- aou_atlas_cohort(
cohort_definition = aou_cohort_example$cd,
cohort_sql = aou_cohort_example$cd_sql
)
# print query that was executed
cat(attr(cohort, "query"))