Coder Social home page Coder Social logo

Comments (4)

anthonysena avatar anthonysena commented on July 17, 2024 1

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 cohort

cohortName
The cohort's name

sql
The OHDSI-SQL used to generate the cohort

Optionally, 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.

mdlavallee92 avatar mdlavallee92 commented on July 17, 2024

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.

mdlavallee92 avatar mdlavallee92 commented on July 17, 2024

@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.

schuemie avatar schuemie commented on July 17, 2024

Awesome! Thank you @mdlavallee92 , that was exactly what I was looking for.

from capr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.