Comments (4)
CohortGenerator's generateCohortSet
requires a cohortDefintionSet
object as mentioned (ref) which is defined as:
cohortDefinitionSet
The cohortDefinitionSet argument must be a data frame with the following columns:cohortId
The unique integer identifier of the cohortcohortName
The cohort's namesql
The OHDSI-SQL used to generate the cohortOptionally, this data frame may contain:
json
The Circe JSON representation of the cohort
The cohortDefintionSet
was meant to be an encapsulation of the elements that define the cohort, specifically the identifier, the name and SQL used to create the cohort. The name seemed like an important element for this object so that's why it is included. The json
part is optional and while the documentation notes that it would hold Circe JSON, it could hold CAPR JSON. Alternatively, a different column could exist in the cohortDefinitionSet
data.frame for the CAPR JSON (CohortGenerator simply ignores those extra columns).
So if CAPR could create the cohortDefinitionSet
it may make plugging into CohortGenerator easier. Is this what you are thinking @schuemie ?
from capr.
Comments on Issue
Thanks for your issue @schuemie and for your comment @anthonysena.
I view Capr
as only being responsible for developing the json object which I then save in a folder that contains all cohort definitions for a study. Once my folder of json cohort definitions is complete (whether built via Capr or copy and pasted from ATLAS), I point that folder as my input for CohortGenerator
, following some manipulation to arrive at the cohortDefinitionSet
object as @anthonysena mentioned above. I don't usually feed the Capr
output straight into CohortGenerator
because in a study there is all sorts of review required for multiple cohort definitions. An analysis pipeline works a bit smoother if I have the final jsons on disk rather than building them on the fly each time with Capr
.
This being said, your use case seems to be a bit more dynamic. You seem to want the cohorts to be generated on the fly and continue to leverage within a script as oppose to a complex study pipeline. I use to have a function like this in Capr
v1. It has not made it into Capr
v2 because I hadn't used it in this style lately. Happy to add it back in though to match the version 2 updates if this is something you will use.
Additional Thoughts
I will say it is interesting that the way I use OHDSI software is a little different when I am doing exploration to when I am piecing together a pipeline. Capr
to me works as an auxiliary step to a study pipeline. But Capr
also works well when I want to make a couple of simple cohorts and do some quick things in R. Since I have been doing more pipelining work at my day job I have been focusing on that.
For examples of how I use Capr within a study pipeline take a look at this public study we have been putting together. Capr Scripts feed the 01_buildCohort module whose internals pre-process the json from the cohortsToCreate folder. For the record, this would all be cleaner with strategus we just haven't matured the codebase to it yet.
from capr.
@schuemie and @anthonysena sorry for the delay I was catching up on some stuff following the labor day weekend.
I have added a new function to Capr called makeCohortSet
that you can pipe into CohortGenerator
. It works as such:
library(Capr)
#make concept set for celecoxib
celecoxib <- cs(descendants(1118084), name = "celecoxib")
#make cohort for celecoxib
celecoxibCohort <- cohort(
entry = entry(
drugExposure(celecoxib)
),
exit = exit(
observationExit()
)
)
#make concept set for diclofenac
diclofenac <- cs(descendants(1124300), name = "diclofenac")
#make cohort for diclofenac
diclofenacCohort <- cohort(
entry = entry(
drugExposure(diclofenac)
),
exit = exit(
observationExit()
)
)
makeCohortSet(celecoxibCohort, diclofenacCohort)
#> # A tibble: 2 x 4
#> cohortId cohortName sql json
#> <int> <chr> <chr> <chr>
#> 1 1 celecoxibCohort "CREATE TABLE #Codesets (\r\n codeset_id int~ "{\n~
#> 2 2 diclofenacCohort "CREATE TABLE #Codesets (\r\n codeset_id int~ "{\n~
Created on 2023-09-06 with reprex v2.0.2
This is currently in the develop branch...I am fixing a few more things before doing a release to v2.0.6. Let me know if this is what you are looking for. If so I will close the issue
from capr.
Awesome! Thank you @mdlavallee92 , that was exactly what I was looking for.
from capr.
Related Issues (20)
- Executing writeCohort() leads to Error: 'list_flatten' is not an exported object from 'namespace:purrr' HOT 3
- align with circe-be changes HOT 1
- procedure() not working HOT 3
- Add labelling to cohort elements
- What's the right way to get json from Capr code object? HOT 3
- Setting observational start date for cohort HOT 4
- Typos using "-" instead of "-" in some documentation HOT 1
- Is there Capr support for Health Economics Data Tables HOT 4
- Support updates to Circe v1.11.0 HOT 5
- Possible bug in Example vignette code for applying inclusion criteria HOT 2
- Example (or tips) for using age() in defining a cohort within atttrition()? HOT 5
- R6 v S3/S4 in HADES HOT 4
- Released version failing R Check HOT 2
- Tips for using calendar date range requirement in defining entry (or attrition)? HOT 3
- Add Device exposure as an entry option HOT 1
- Are examples for unit() out of date due to a breaking change? HOT 1
- how to retrieve conceptid HOT 1
- How do I specify a date range? HOT 6
- Allow numeric as `offsetDays` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from capr.