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

Fix #462 - capture KRI and other associated metadata #527

Merged
merged 37 commits into from
Jun 13, 2022
Merged

Conversation

mattroumaya
Copy link
Contributor

Overview

Only ready for a preliminary review to make sure things are going as planned:

  • Tested passing KRILabel in Study_Assess() with ae.yaml
  • Can also pass custom KRILabel via lTags if running single assessment (see below)

Test Notes/Sample Code

# run multiple (this branch is only currently testing ae)
myStudy <- Study_Assess()
View(myStudy$ae$lResults$dfSummary)

# can pass custom KRILabel via lTags by using explicit "KRILabel" name:
ae <- AE_Map_Raw()
ae_assess <- AE_Assess(ae, lTags = list(KRILabel = "AEs/Site per Month for West Coast"))

Merge branch 'dev' into fix-462

# 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
Copy link
Contributor Author

@jwildfire - This should be good for your preliminary review to make sure the new skeleton is as intended. Definitely happy to schedule a time to run through everything if that's more convenient.

R/Analyze_Wilcoxon.R Outdated Show resolved Hide resolved
R/Analyze_Wilcoxon.R Outdated Show resolved Hide resolved
R/AE_Assess.R Outdated
@@ -127,13 +127,13 @@ AE_Assess <- function(
)
}

lAssess$dfAnalyzed <- gsm::Analyze_Wilcoxon(lAssess$dfTransformed, "Rate", bQuiet = bQuiet)
lAssess$dfAnalyzed <- gsm::Analyze_Wilcoxon(lAssess$dfTransformed, "KRI", bQuiet = bQuiet)
Copy link
Contributor

Choose a reason for hiding this comment

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

As noted below, we can update the default to KRI and remove here.

R/Analyze_Poisson.R Outdated Show resolved Hide resolved
R/Analyze_Poisson.R Outdated Show resolved Hide resolved
R/Consent_Assess.R Outdated Show resolved Hide resolved
R/Consent_Assess.R Outdated Show resolved Hide resolved
R/Flag.R Outdated Show resolved Hide resolved
R/IE_Assess.R Outdated
@@ -14,6 +14,7 @@
#' @param dfInput `data.frame` Input data, a data frame with one record per subject.
#' @param nThreshold `numeric` Threshold specification. Default: `0.5`
#' @param lTags `list` Assessment tags, a named list of tags describing the assessment that defaults to `list(Assessment="IE")`. `lTags` is returned as part of the assessment (`lAssess$lTags`) and each tag is added as a column in `lAssess$dfSummary`.
#' @param strScoreLabel Optional. `character` vector to describe the `Score` column. Default: `Total Event Count`
Copy link
Contributor

Choose a reason for hiding this comment

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

Should standarize across assessments.

R/Summarize.R Outdated Show resolved Hide resolved
@jwildfire
Copy link
Contributor

jwildfire commented Jun 8, 2022

@mattroumaya This looks good so far. Added a bunch of minor comments, but not 100% sure about a few of the details.

I want to think a bit more about the best way to define KRILabel and ScoreLabel as part of each assessment. I think I like the logic using lTags from your example above:

# can pass custom KRILabel via lTags by using explicit "KRILabel" name:
ae <- AE_Map_Raw()
ae_assess <- AE_Assess(ae, lTags = list(KRILabel = "AEs/Site per Month for West Coast"))

Not quite sure how this works right now looking at the code though ... I'm also debating if there's a compelling reason to bury these parameters in lTags instead of just defining them directly in the Assess parameters (like you did in Consent_Assess and IE_Assess ... So maybe I'm talking my self out of the lTags approach ...

Also thinking ScoreLabel might just be hardcoded in the Analyze functions, while KRI label might be more variable (and thus defined as part of the assessment workflow.

Long story short, we should probably find another 30 minutes to discuss. I'll try to block a time tomorrow. Thanks for getting the draft PR moving, it's definitely helping us get to the needed level of detail.

@jwildfire
Copy link
Contributor

@mattroumaya I just updated #462 and created #528 to outline my proposed approach. Feel free to add comments/questions in those issues. Or if the proposal in the issues is all fairly clear and makes sense to you feel free to try a draft implementation here.

Consider all of my comments from the code review as loose suggestions and lower priority than the comments in the issues.

mattroumaya and others added 13 commits June 8, 2022 13:56
Co-authored-by: Jeremy Wildfire <jwildfire@gmail.com>
Co-authored-by: Jeremy Wildfire <jwildfire@gmail.com>
Co-authored-by: Jeremy Wildfire <jwildfire@gmail.com>
Co-authored-by: Jeremy Wildfire <jwildfire@gmail.com>
Co-authored-by: Jeremy Wildfire <jwildfire@gmail.com>
Co-authored-by: Jeremy Wildfire <jwildfire@gmail.com>
Co-authored-by: Jeremy Wildfire <jwildfire@gmail.com>
@mattroumaya
Copy link
Contributor Author

mattroumaya commented Jun 8, 2022

@kodesiba - I hope this is now ready for you to branch off of to update qualification tests. Feel free to branch off and of course let me know if you have any questions. Still some updates needed for documentation and non-quali unit tests, but shouldn't affect your updates.

R/Analyze_Chisq.R Outdated Show resolved Hide resolved
R/Analyze_Fisher.R Outdated Show resolved Hide resolved
R/Analyze_Identity.R Outdated Show resolved Hide resolved
rename(
Residuals = .data$.resid,
PredictedCount = .data$.fitted,
mutate(
Copy link
Contributor

Choose a reason for hiding this comment

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

@gwu05 Do we want to add a strScoreCol parameter here? We can set default to ".resid", but could also allow users to set up assessments that use pvalue (or another parameter) as the Score column for use in flagging.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's leave this hardcoded for now. Can revisit as needed if a new use case comes up.

R/Analyze_Wilcoxon.R Outdated Show resolved Hide resolved
R/Flag.R Outdated Show resolved Hide resolved
#'
#' @export

Analyze_Identity <- function(dfTransformed, strValueCol = 'KRI', strLabelCol = "KRIColumn"){
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add bQuiet just to be thorough. Will likely add some reporting in analyze functions in future releases.

@@ -27,18 +27,19 @@
#' @param dfInput A data.frame with one record per person.
#' @param strCountCol Required. Numerical or logical. Column to be counted.
#' @param strExposureCol Optional. Numerical `Exposure` column.
#' @param strKRILabel Optional. Character vector to describe the `KRI` column.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to have this optional? Does anything in StudyAssess break when KRILabel/ScoreLabel is missing.

I think I'd lean towards giving it a placeholder default like strKRILabel = "[Not Specified]"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one actually isn't optional - every *_Assess() function has its own default strKRILabel, so if not specified in a workflow mapping, Study_Assess() will use the default for *_Assess().

Do you feel good about this setup? Or would you prefer putting a placeholder in Transform_EventCount() (like above), and removing default strKRILabel from Assess?

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 we should do both. Pretty unlikely this will be called outside an _Assess function, but would be good to have a reasonable default just in case.

@@ -0,0 +1,3 @@
test_that("multiplication works", {
Copy link
Contributor

Choose a reason for hiding this comment

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

Reminder to update

@@ -65,10 +66,10 @@ test_that("incorrect lTags throw errors", {

# custom tests ------------------------------------------------------------
test_that("dfAnalyzed has appropriate model output regardless of statistical method", {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth adding a test to insure that Score/ScoreLabel populate as expected as well.

@@ -70,3 +71,8 @@ test_that("bReturnChecks works as intended", {
"lChecks" %in% names(Consent_Assess(consentInput, bReturnChecks = TRUE))
)
})

test_that("strKRILabel works as intended", {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add test for Score/ScoreLabel

Copy link
Contributor

Choose a reason for hiding this comment

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

applies to all Assess functions

@jwildfire
Copy link
Contributor

jwildfire commented Jun 9, 2022

@mattroumaya Core structure looks good! Suggested lots of minor tweaks/cleanup in latest review.

mattroumaya and others added 3 commits June 9, 2022 10:36
Co-authored-by: Jeremy Wildfire <jwildfire@gmail.com>
Co-authored-by: Jeremy Wildfire <jwildfire@gmail.com>
Co-authored-by: Jeremy Wildfire <jwildfire@gmail.com>
mattroumaya and others added 11 commits June 9, 2022 10:37
Co-authored-by: Jeremy Wildfire <jwildfire@gmail.com>
Co-authored-by: Jeremy Wildfire <jwildfire@gmail.com>
Co-authored-by: Jeremy Wildfire <jwildfire@gmail.com>
Co-authored-by: Jeremy Wildfire <jwildfire@gmail.com>
Co-authored-by: Jeremy Wildfire <jwildfire@gmail.com>
Merge branch 'dev' of github.com:Gilead-BioStats/gsm into fix-462

# 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
Copy link
Contributor Author

@kodesiba giving the go ahead to update qualification tests. I think everything else is covered.

@jwildfire feel free to give this another review if you have the chance, or feel free to wait until Nathan's PR is merged.

Nathan Kosiba and others added 5 commits June 10, 2022 16:45
Merge branch 'dev' of github.com:Gilead-BioStats/gsm into fix-462

# 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.
update qualification tests for KRI update
@mattroumaya mattroumaya requested a review from jwildfire June 10, 2022 18:06
@jwildfire jwildfire marked this pull request as ready for review June 13, 2022 11:46
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.

💯

R/Analyze_Fisher.R Outdated Show resolved Hide resolved
@jwildfire
Copy link
Contributor

@mattroumaya Looks great. Will leave merge to you.

Co-authored-by: Jeremy Wildfire <jwildfire@gmail.com>
@mattroumaya mattroumaya merged commit bbdb37e into dev Jun 13, 2022
@mattroumaya mattroumaya deleted the fix-462 branch June 13, 2022 13:23
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.

2 participants