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

253 egt05 qtcat@main #346

Merged
merged 33 commits into from
Feb 16, 2023
Merged

253 egt05 qtcat@main #346

merged 33 commits into from
Feb 16, 2023

Conversation

JiaLiu0001
Copy link
Contributor

close insightsengineering/chevron-tasks#50

@github-actions
Copy link
Contributor

github-actions bot commented Dec 29, 2022

🧪 $Test coverage: 87.96%$

Code Coverage Summary

Filename                     Stmts    Miss  Cover    Missing
-------------------------  -------  ------  -------  ------------------------------------------------------------------------
R/aet01_aesi.R                 188       8  95.74%   39, 41-45, 272, 285
R/aet01.R                      330       6  98.18%   38, 240, 253, 316, 322, 554
R/aet02.R                      222       2  99.10%   136, 489
R/aet03.R                       84       0  100.00%
R/aet04.R                       93       0  100.00%
R/assertions.R                  36       0  100.00%
R/checks.R                      20       0  100.00%
R/chevron_tlg-S4class.R         21       0  100.00%
R/chevron_tlg-S4methods.R      123      17  86.18%   35, 94-102, 137-145, 396-468
R/cmt01a.R                     191       0  100.00%
R/cmt02_pt.R                    52       0  100.00%
R/dmt01.R                       40       0  100.00%
R/dst01.R                      287       0  100.00%
R/dtht01.R                     104       0  100.00%
R/egt01.R                       46       0  100.00%
R/egt02.R                       60       0  100.00%
R/egt03.R                      132      91  31.06%   32-52, 120-243, 290-326
R/egt05_qtcat.R                 57      33  42.11%   38-57, 119-142
R/ext01.R                       81       8  90.12%   238-241, 245-248
R/gen_args.R                     1       1  0.00%    30
R/lbt01.R                       95       0  100.00%
R/lbt04.R                       52       1  98.08%   127
R/lbt05.R                       76      10  86.84%   33-41, 152
R/lbt07.R                       81       2  97.53%   33, 163
R/lbt14.R                      202      34  83.17%   57, 59, 107-110, 112-120, 150, 181, 268, 270, 318-321, 323-331, 361, 392
R/mht01.R                       72       2  97.22%   33-34
R/mng01.R                       93      12  87.10%   113, 117-120, 129-137, 182
R/pdt01.R                       61      38  37.70%   35-52, 108-150
R/pdt02.R                       68       0  100.00%
R/utils.R                      188     130  30.85%   70, 83-235, 396
R/vst01.R                       48       0  100.00%
R/vst02.R                      102       3  97.06%   42, 120, 257
TOTAL                         3306     398  87.96%

Results for commit: 9ba6e1b51364000d41e0fbd78c1f372d1e790dc8

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@github-actions
Copy link
Contributor

github-actions bot commented Dec 29, 2022

Unit Tests Summary

    1 files    26 suites   1m 27s ⏱️
121 tests   86 ✔️ 35 💤 0
270 runs  182 ✔️ 88 💤 0

Results for commit e5233d5.

♻️ This comment has been updated with latest results.

R/egt05_qtcat.R Outdated Show resolved Hide resolved
R/egt05_qtcat.R Outdated
PARAMCD == "QT"
) %>%
mutate(
AVALCAT1 = case_when(
Copy link
Contributor

Choose a reason for hiding this comment

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

please consider only derive the AVALCAT1 if there is no variable available? if it is already derived, then I think it is not necessary to derived it again here

Copy link
Contributor

Choose a reason for hiding this comment

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

and unit should come from AVALU? although the chance that avalu is not "msec" is small

Copy link
Contributor

Choose a reason for hiding this comment

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

@JiaLiu0001 is AVALU considered here? whether we should use AVALU as the unit, instead of "msec"?

R/egt05_qtcat.R Outdated
#'
#' @note
#' * `adam_db` object must contain an `adeg` table with a `"PARAM"` column contains 'QT' as well as columns
#' specified in `summaryvars` and `visitvar`.
Copy link
Contributor

Choose a reason for hiding this comment

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

please consider making the algorithm clear: visit var is needed in adeg, while summaryvars does not. it is derived in preprocess (at least for the default one)

R/egt05_qtcat.R Outdated
egt05_qtcat_1_main <- function(adam_db,
armvar = "ACTARM",
summaryvars = c("Value at Visit" = "AVALCAT1", "Change from Baseline" = "CHGCAT1"),
visitvar = "AVISIT", # or ATPTN
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove the comment here

R/egt05_qtcat.R Outdated
lbl_avisit,
deco,
...) {
# TODE solve the problem of the overall column
Copy link
Contributor

Choose a reason for hiding this comment

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

please clean up comments here

"<Missing>"
)
)
AVALCAT1 = factor(AVALCAT1),
Copy link
Contributor

Choose a reason for hiding this comment

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

this can lead to strange order factors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @clarkliming factor updated

R/egt05_qtcat.R Outdated
#' * `adam_db` object must contain an `adeg` table with a `"PARAM"` column contains 'QT' as well as column
#' specified in `visitvar`.
#' For `summaryvars`, if `AVALCAT1` and `CHGCAT1` columns are already existed in input data sets, no need to
#' specify `AVAL` or `CHG`. If not, `AVAL` and `CHG` columns must be contained.
Copy link
Contributor

Choose a reason for hiding this comment

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

no matther if AVALCAT1 exist, we don't specify "AVAL" or "CHG" in data; we only re-derive the "AVALCAT1" if it does not exist in data right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sentence updated

R/egt05_qtcat.R Outdated
@@ -86,7 +92,8 @@ egt05_qtcat_1_lyt <- function(armvar,
vars = summaryvars,
var_labels = summaryvars_lbls
) %>%
append_topleft(" Category")
append_topleft("Analysis Visit") %>%
Copy link
Contributor

Choose a reason for hiding this comment

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

please use an argument instead of hard coding

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hard coding updated

@clarkliming
Copy link
Contributor

I think it looks good now, but let's wait for @barnett11 for a final review

@edelarua edelarua added the sme label Jan 6, 2023
@barnett11 barnett11 self-requested a review January 10, 2023 13:54
R/egt05_qtcat.R Outdated Show resolved Hide resolved
R/egt05_qtcat.R Outdated
#'
egt05_qtcat_1_pre <- function(adam_db, paramcdvar = "QT", ...) {
checkmate::assert_class(adam_db, "dm")
unit <- adam_db$adeg %>% filter(PARAMCD == paramcdvar) %>% select(AVALU) %>% unique()
Copy link
Contributor

Choose a reason for hiding this comment

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

please follow style guide that after %>% always start a new line; in addition, we also need to check unit is length 1 otherwise there will be issues in follow up code; in addition we can use pull instead of select to get the value

Copy link
Contributor

Choose a reason for hiding this comment

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

@JiaLiu0001 how is this going?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The update is not pushed yet. I'm wondering 'do we need different cut-offs for "QT", "QTCF", etc' like you mentioned in the above comment? If so, I prefer to update them in one push. @clarkliming

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 update the formats and merge; for the testing part let's track in another issue and Tim will take over then

R/egt05_qtcat.R Outdated
AVAL <= 450 ~ paste0("<=450 ", unit),
AVAL <= 480 ~ paste0(">450 to <=480 ", unit),
AVAL <= 500 ~ paste0(">480 to <= 500 ", unit),
AVAL > 500 ~ paste0(">500 ", unit),
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need different cut-offs for "QT", "QTCF", etc? @barnett11

Copy link
Contributor

Choose a reason for hiding this comment

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

These thresholds should not be derived in the TLG code, they should come directly from AVALCAT1 and CHGCAT1

Copy link
Contributor

Choose a reason for hiding this comment

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

ok @JiaLiu0001 maybe we just remove this preprocessing, and add AVALCAT1 and CHGCAT1 in data to make sure the example works

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @clarkliming
Pre-defines of AVALCAT1 and CHGCAT1 are removed, and warnings will return if AVALCAT1 and CHGCAT1 do not exist. However, I'm not sure how to update the data here to add AVALCAT1 and CHGCAT1 to the dataset. Could you please help with this?

Copy link
Contributor

Choose a reason for hiding this comment

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

in get_syn_data function, add appropriate derivations of AVALCAT1 and CHGCAT1. In addition, we should give errors instead of warnings when the variables do not exist

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @clarkliming I didn't find the function get_syn_data in https://github.com/insightsengineering. Could you please point me to the function you mentioned?

DESCRIPTION Outdated
@@ -54,7 +54,7 @@ Config/testthat/edition: 3
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.2.3.9000
Copy link
Contributor

Choose a reason for hiding this comment

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

are you using a develop version of Roxygen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I'm. Looks like it should be switched to 7.2.3?

R/egt05_qtcat.R Outdated
#' @param ... not used.
#'
#' @export
egt05_qtcat_1_lyt <- function(armvar,
Copy link
Contributor

Choose a reason for hiding this comment

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

please double check if the arguments of egt05_qtcat_1_lyt are also exposed in egt05_qtcat_1_main

R/egt05_qtcat.R Outdated
) %>%
mutate(
AVALCAT1 = if ("AVALCAT1" %in% colnames(.)) factor(AVALCAT1) else
stop("Please make sure 'AVALCAT1' is existed")
Copy link
Contributor

Choose a reason for hiding this comment

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

please use assert_colnames to check if variables are valid

@clarkliming
Copy link
Contributor

@JiaLiu0001 are you still working on this?

@JiaLiu0001
Copy link
Contributor Author

@JiaLiu0001 are you still working on this?
Hi @clarkliming, Once I replaced fct_explicit_na by tern::explicit_na in utils.R, looks like in CMD check, ext01_2 has been impected. Should I just recover this fct_explicit_na change?

@clarkliming
Copy link
Contributor

@JiaLiu0001 are you still working on this?
Hi @clarkliming, Once I replaced fct_explicit_na by tern::explicit_na in utils.R, looks like in CMD check, ext01_2 has been impected. Should I just recover this fct_explicit_na change?

Also convert the variable to factor

@JiaLiu0001
Copy link
Contributor Author

@JiaLiu0001 are you still working on this?
Hi @clarkliming, Once I replaced fct_explicit_na by tern::explicit_na in utils.R, looks like in CMD check, ext01_2 has been impected. Should I just recover this fct_explicit_na change?

Also convert the variable to factor

Hi @clarkliming Even though fct_explicit_na is replaced by explicit_na, still got Warning in CMD. Do you have any idea about it?

@clarkliming
Copy link
Contributor

it is in dunlin and I have open issues to address it

R/utils.R Outdated
# Add AVALCAT1 CHGCAT1 for adeg
sd$adeg <- sd$adeg %>%
mutate(
AVALCAT1 = if ("AVALCAT1" %in% colnames(.)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. in synthetic_data, whether AVALCAT1 exists has a clear answer, yes or no. No need to check if it exists. It is not user input.
  2. For baseline visits, where CHG is NA, please do not derive values; Do not keep "NA msec" here
  3. Please derive CHGCAT /AVALCAT only for QT (for now)

Copy link
Contributor Author

@JiaLiu0001 JiaLiu0001 Feb 10, 2023

Choose a reason for hiding this comment

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

Thank you @clarkliming, the utils is updated as your comments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @clarkliming, the utils is updated as your comments

Hi @clarkliming Have this PR passed review?

Copy link
Contributor

@clarkliming clarkliming 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 to me; please resolve the conflict and merge.

After merged, you can open a new issue and tag Tim for a final review

@JiaLiu0001 JiaLiu0001 merged commit 9a8ee91 into main Feb 16, 2023
@JiaLiu0001 JiaLiu0001 deleted the 253_EGT05_QTCAT@main branch February 16, 2023 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants