-
Notifications
You must be signed in to change notification settings - Fork 12
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 #864 - QTL Pipeline Updates #873
Conversation
@jwildfire this one just needs unit tests which I'm working on now - feel free to review if you have the chance. I'll convert to PR and approve once everything looks good. |
R/Flag_QTL.R
Outdated
dfFlagged <- dfAnalyzed %>% | ||
mutate( | ||
Flag = case_when( | ||
(.data$LowCI > vThreshold) ~ 2, | ||
(.data$Score > vThreshold) ~ 1, | ||
TRUE ~ 0 | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add some NA
handling here?
Either stopifnot()
for is.na(Score)
or handle within case_when()
?
dfAnalyzed <- tibble::tribble(
~GroupID, ~Numerator, ~Denominator, ~Metric, ~Method, ~ConfLevel, ~Estimate, ~LowCI, ~UpCI, ~Score,
"AA-AA-000-0000", 122, 1301, 0.0937, "Exact binomial test", 0.95, 0.0937, 0.0784, 0.1109, 0.0784
)
# returns Flag == 0
dfAnalyzed %>%
mutate(Score = NA) %>%
Flag_QTL(vThreshold = 1)
# returns Flag == 2
dfAnalyzed %>%
mutate(Score = NA) %>%
Flag_QTL(vThreshold = 0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not needed. I think as long as denominator >=1
, there won't be NA
in Estimate
, Score
or LowCI
.
Also, need to update Score
in Analyze_QTL()
to be the Estimate
for flagging 1. LowerCI
is used for flagging 2.
} | ||
|
||
flag_function_name <- switch(strMethod, | ||
NormalApprox = "Flag_NormalApprox", | ||
identity = "Flag", | ||
fisher = "Flag_Fisher", | ||
qtl = "Flag" | ||
qtl = "Flag_QTL" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a qtl strMethod? this sections differs between AE and Disp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're only running QTLs for Disp and PD right now - should we add the QTL method to AE + others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh you're right, that's correct
R/Make_Snapshot.R
Outdated
select(GroupID, | ||
LowCI, | ||
UpCI, | ||
Score) %>% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we need to pass through more - eg., whether the datapoint was flagged and the corresponding threshold - in order to allow for changes to QTL thresholds through the study. As long as we can get this elsewhere then we are fine. Also, given that we are only using an upper threshold for QTLs currently, UpCI actually technically doesn't need to be surfaced (but okay to include for now). In general, it'd probably be better to allow for lower and upper QTL thresholds in our Flag_QTL function (although I don't see us using the lower QTL in the recent release, so it can be something saved for later.)
@@ -200,10 +200,40 @@ bQuiet = TRUE | |||
flag = "Flag" | |||
) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not able to run the example in Make_Snapshot:
"Error in select()
:
! Can't subset columns that don't exist.
✖ Column lpfv
doesn't exist.
Run rlang::last_error()
to see where the error occurred."
Backtrace:
▆
- ├─gsm::Make_Snapshot()
- │ └─status_study %>% ... at gsm/R/Make_Snapshot.R:93:2
- ├─dplyr::select(...)
- └─dplyr:::select.data.frame(...)
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you might need to update to the latest {clindata}
release because lpfv
was recently added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I approve (but I can't officially approve, since I started the PR).
@mattroumaya I think you're good to approve/merge.
# Also need to make sure we're capturing WorkflowID here ... | ||
|
||
hasQTL <- grep("qtl", names(lResults)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A+ data munging. 💯
R/Make_Snapshot.R
Outdated
} else { | ||
results_analysis <- tibble( | ||
studyid = NA, | ||
workflowid = NA, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add workflowid and studyid if QTL fails
@jwildfire - had to tweak the logic a little bit for a failed QTL, and also updated |
Also added in failsafe logic for the case when none of the workflows contain lAssessments <- MakeWorkflowList(strNames = c("kri0001", "qtl0003", "qtl0007"))
lAssessments$kri0001$steps[[2]]$inputs <- "dfAA"
a <- Make_Snapshot(lAssessments = lAssessments) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updates look good
Overview
Updates to QTL pipelines for v1.3.1 release.
Fix #864
Fix #849
Fix #863
Test Notes/Sample Code
Notes: