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 #864 - QTL Pipeline Updates #873

Merged
merged 13 commits into from
Nov 15, 2022
Merged

Fix #864 - QTL Pipeline Updates #873

merged 13 commits into from
Nov 15, 2022

Conversation

jwildfire
Copy link
Contributor

@jwildfire jwildfire commented Nov 10, 2022

Overview

Updates to QTL pipelines for v1.3.1 release.

Fix #864
Fix #849
Fix #863

Test Notes/Sample Code

Notes:

@mattroumaya
Copy link
Contributor

@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
Comment on lines 46 to 53
dfFlagged <- dfAnalyzed %>%
mutate(
Flag = case_when(
(.data$LowCI > vThreshold) ~ 2,
(.data$Score > vThreshold) ~ 1,
TRUE ~ 0
)
)
Copy link
Contributor

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)

Copy link
Contributor

@Zhongkai-Wang Zhongkai-Wang Nov 11, 2022

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.

Merge remote-tracking branch 'origin/dev' into fix-864

# Conflicts:
#	R/Disp_Assess.R
#	R/LB_Assess.R
#	R/PD_Assess.R
#	man/Disp_Assess.Rd
#	man/LB_Assess.Rd
#	man/PD_Assess.Rd
@mattroumaya mattroumaya marked this pull request as ready for review November 14, 2022 16:34
@mattroumaya mattroumaya requested a review from gwu05 November 14, 2022 16:46
R/Flag_QTL.R Show resolved Hide resolved
}

flag_function_name <- switch(strMethod,
NormalApprox = "Flag_NormalApprox",
identity = "Flag",
fisher = "Flag_Fisher",
qtl = "Flag"
qtl = "Flag_QTL"
Copy link
Contributor

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

Copy link
Contributor

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?

Copy link
Contributor

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

select(GroupID,
LowCI,
UpCI,
Score) %>%
Copy link
Contributor

@gwu05 gwu05 Nov 14, 2022

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"
)

Copy link
Contributor

@gwu05 gwu05 Nov 14, 2022

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:

  1. ├─gsm::Make_Snapshot()
  2. │ └─status_study %>% ... at gsm/R/Make_Snapshot.R:93:2
  3. ├─dplyr::select(...)
  4. └─dplyr:::select.data.frame(...)
    ...

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 you might need to update to the latest {clindata} release because lpfv was recently added

R/PD_Assess.R Outdated Show resolved Hide resolved
Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A+ data munging. 💯

} else {
results_analysis <- tibble(
studyid = NA,
workflowid = NA,
Copy link
Contributor

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

@mattroumaya
Copy link
Contributor

@jwildfire - had to tweak the logic a little bit for a failed QTL, and also updated rbm_data_spec. Let me know if this all looks good and then I'll merge!

@mattroumaya
Copy link
Contributor

Also added in failsafe logic for the case when none of the workflows contain dfBounds:

lAssessments <- MakeWorkflowList(strNames = c("kri0001", "qtl0003", "qtl0007"))

lAssessments$kri0001$steps[[2]]$inputs <- "dfAA"

a <- Make_Snapshot(lAssessments = lAssessments)

Copy link
Contributor Author

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

Updates look good

@mattroumaya mattroumaya merged commit 2149c90 into dev Nov 15, 2022
@mattroumaya mattroumaya deleted the fix-864 branch November 15, 2022 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants