8000 Fix #475 - add flowchart by mattroumaya · Pull Request #545 · Gilead-BioStats/gsm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix #475 - add flowchart #545

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

Merged
merged 25 commits into from
Jul 14, 2022
Merged

Fix #475 - add flowchart #545

merged 25 commits into from
Jul 14, 2022

Conversation

mattroumaya
Copy link
Contributor

Overview

Initial bare bones implementation for flowchart

Test Notes/Sample Code

myStudy <- Study_Assess()

print(myStudy$pd$lResults$flowchart)

@mattroumaya
Copy link
Contributor Author

@jwildfire - added a possible implementation but looking for any additional specs you can provide for what you'd like to see here.

@mattroumaya mattroumaya changed the title Fix 475 - add flowchart Fix #475 - add flowchart Jun 14, 2022
Merge branch 'dev' of github.com:Gilead-BioStats/gsm into fix-475

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
Merge branch 'dev' of github.com:Gilead-BioStats/gsm into fix-475

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
Merge branch 'dev' of github.com:Gilead-BioStats/gsm into fix-475

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
@mattroumaya mattroumaya marked this pull request as ready for review June 18, 2022 22:31
Copy link
Contributor
@jwildfire jwildfire left a comment

Choose a reason for hiding this comment

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

Sample code isn't running for me :( No error thrown, but nothing rendering. Maybe add some examples/tests that call Visualize_Workflow directly?

@samussiah
Copy link
Contributor

It's running for me, and it looks really nice! It would be a lot more intuitive if we had consistent verbiage. For instance, RunAssessment is actually running the entire workflow and its lResults is the output of the assessment step/function.

@mattroumaya
Copy link
Contributor Author

@jwildfire - the code to create a single flowchart is pretty nested inside RunAssessment(), but this should work for you to see the results of AE:

library(DiagrammeR)

lAssessments <- MakeAssessmentList()
lData <- list(
  dfSUBJ = clindata::rawplus_subj,
  dfAE = clindata::rawplus_ae,
  dfPD = clindata::rawplus_pd,
  dfCONSENT = clindata::rawplus_consent,
  dfIE = clindata::rawplus_ie
)
lTags <- list(
  Study = "myStudy"
)
lMapping <- clindata::mapping_rawplus

ae_assessment <- RunAssessment(lAssessments$ae, lData = lData, lMapping = lMapping, lTags = lTags)


ae_assessment$lResults$flowchart

@ge-li
Copy link
Contributor
ge-li commented Jun 21, 2022

It's running for me, too, but I have to install.packages("DiagrammeR") first.

@jwildfire jwildfire linked an issue Jun 21, 2022 that may be closed by this pull request
@jwildfire
Copy link
Contributor

Running fine in RStudio - sorry for confusion! Will continue to a full review soon.

Comment on lines 59 to 72
node_df <- bind_rows(node_df,
map_df(step$inputs, ~tibble(
assessment = lAssessment$name,
n_step = stepCount,
name = step$name,
inputs = .x,
n_row = nrow(lData[[.x]]),
n_col = ncol(lData[[.x]]))) %>%
mutate(checks = result$lChecks$status,
from = stepCount,
to = length(lAssessment$workflow[[stepCount]]$inputs) + stepCount,
n_row_end = ifelse(!is.null(result$newRows), result$newRows, NA))
)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'd vote to move this to Visualize_Workflow if possible ...

Comment on lines 100 to 104
lAssessment$lResults$flowchart <- Visualize_Workflow(
lAssessment = lAssessment,
lResult = result,
dfNode = node_df
)
Copy link
Contributor

Choose a reason for hiding this comment

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

result is already embedded in lAssessment, no? Seems like we can just pass lAssessment and then have Visualize_Workflow calculate node_df

if (bReturnChecks) {
return(list(df = df, lChecks = checks))
if(!exists("newRows")) newRows <- NA
Copy link
Contributor

Choose a reason for hiding this comment

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

A little bit confused about the need for this ... can we not just use nrow() on the dataset that is returned.

stepCount <- stepCount + 1
}
} else {
cli::cli_alert_warning("Workflow not found for {lAssessment$name} assessment - Skipping remaining steps")
lAssessment$bStatus <- FALSE
}

if(lAssessment$bStatus) {
lAssessment$lResults$flowchart <- Visualize_Workflow(
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a super strong opinion, but in my mind the flowchart fits better under lChecks than lResults. It's really more of a debugging/workflow tool than a part of the core KRI workflow.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or better yet attached to workflow:

image

Also should checks be in lChecks?

Copy link
Contributor
@jwildfire jwildfire left a comment

Choose a reason for hiding this comment

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

Looks great!

Let's discuss process for partial workflows after scrum.

@mattroumaya
Copy link
Contributor Author

Add to RunAssessment() in lChecks

@mattroumaya
Copy link
Contributor Author

@jwildfire - I think this is as far as it makes sense to take things for now. Feel free to review again, wait to discuss further, or merge if it looks good.

To run with complete data:

study <- Study_Assess()

study$ae$lChecks$flowchart

Error for subject-level data:

lData <- list(
  dfSUBJ = clindata::rawplus_subj %>% select(-SubjectID),
  dfAE = clindata::rawplus_ae
)

x <- Study_Assess(lData = lData)

x$ae$lChecks$flowchart

Error for domain-level/missing data:

lAssessments <- MakeAssessmentList()
lData <- list(
  dfSUBJ = clindata::rawplus_subj,
  dfAE = clindata::rawplus_ae %>% select(1)
)
lTags <- list(
  Study = "myStudy"
)
lMapping <- clindata::mapping_rawplus

sae_assessment <- RunAssessment(lAssessments$sae, lData = lData, lMapping = lMapping, lTags = lTags)

sae_assessment$lChecks$flowchart

@mattroumaya
Copy link
Contributor Author

More code to test if helpful:

dfAE <- clindata::rawplus_ae
dfCONSENT <- clindata::rawplus_consent
dfIE <- clindata::rawplus_ie
dfPD <- clindata::rawplus_pd
dfSUBJ <- clindata::rawplus_subj


# AE missing SubjectID column
dfAE$SubjectID <- NULL

# Consent column CONSENT_VALUE has NA
dfCONSENT$CONSENT_VALUE[1:10] <- NA

# IE column IE_VALUE missing
dfIE$IE_VALUE <- NULL

lData <- list(
  dfAE = dfAE,
  dfCONSENT = dfCONSENT,
  dfIE = dfIE,
  dfPD = dfPD,
  dfSUBJ = dfSUBJ
)


x <- Study_Assess(lData = lData)

x$ae$lChecks$flowchart

x$consent$lChecks$flowchart

x$ie$lChecks$flowchart

@samussiah samussiah merged commit 80f7b6f into dev Jul 14, 2022
@samussiah samussiah deleted the fix-475 branch July 14, 2022 14:12
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.

Feature: Flowchart for data flow
4 participants
0