Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cohort subset to allow custom windowing #197

Merged
merged 4 commits into from
Dec 11, 2024

Conversation

azimov
Copy link
Collaborator

@azimov azimov commented Nov 14, 2024

This is designed to resolve Issue #175

@azimov azimov requested a review from anthonysena November 14, 2024 01:22
@azimov azimov changed the base branch from main to develop November 14, 2024 01:22
@azimov azimov requested a review from chrisknoll November 14, 2024 01:23

# Start and end windows must always have subset anchor values set to support backwards compatibility
if (!is.null(startWindow)){
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THis section forces the old logic upon the user, which I dislike, but it also preseves the exact logic of the previous implementation. To me there is no perfect solution here...

cohortWindowLogic <- lapply(private$operator$windows, function(window) {
lsql <- " AND (S.@s_cohort_anchor >= DATEADD(d, @window_start_day, T.@window_anchor) AND S.@s_cohort_anchor <= DATEADD(d, @window_end_day, T.@window_anchor))"
SqlRender::render(lsql,
window_anchor = ifelse(window$targetAnchor == "cohortStart",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're inclined, in the CI package the choice of start/end is simply 'start' or 'end' seen here:https://github.com/OHDSI/CohortIncidence/blob/09cf6aa3a6f4cfdbe99d04e38b61a85441fa3925/R/Classes.R#L547. If we want to adopt that moniker for choosing a start or end date to those choices instead of 'cohortStart' or 'cohortEnd'. I origionally had CI using same thing (with cohort in the label) but switched it out to be not cohort-specific but just simply a choice of start/end. Just pointing out where we might be consistent across packages.

Copy link

@chrisknoll chrisknoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, aside for a minor label tweak which can either stay or go. Thank you for this work.

@anthonysena anthonysena linked an issue Dec 11, 2024 that may be closed by this pull request
Copy link
Collaborator

@anthonysena anthonysena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @azimov - I made a small change in 46d5903 to guide users towards using the newly implemented windows parameter and that we'd deprecate the startWindow and endWindow parameters. Let me know if you have any objections.

I'm also going to open a new issue that will focus on the documentation of cohort subsetting, inclusive of these changes, to provide more working examples and details on how to use the various subset operators in the package.

@anthonysena anthonysena merged commit 5f94575 into develop Dec 11, 2024
8 checks passed
@anthonysena anthonysena deleted the cohort-subset-allow-custom-windowing branch December 11, 2024 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to subset cohort based on 'during target cohort'
3 participants