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

update egt05 #535

Merged
merged 13 commits into from
Jul 14, 2023
Merged

update egt05 #535

merged 13 commits into from
Jul 14, 2023

Conversation

clarkliming
Copy link
Contributor

@clarkliming clarkliming commented Jun 9, 2023

close #413

in preprocessing, remove filter of PARAMCD == "QT" (users could use filters or in pre function to modify it)

also split parameter by page
found bug and raised at

insightsengineering/rtables#653

also blocked by

insightsengineering/rtables#651

@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2023

🧪 $Test coverage: 98.38%$

Code Coverage Summary

Filename                     Stmts    Miss  Cover    Missing
-------------------------  -------  ------  -------  ----------------
R/ael01_nollt.R                 17       1  94.12%   61
R/aet01_aesi.R                 147       1  99.32%   209
R/aet01.R                       92       1  98.91%   156
R/aet02.R                       57       0  100.00%
R/aet03.R                       76       0  100.00%
R/aet04.R                       88       0  100.00%
R/aet10.R                       42       0  100.00%
R/assertions.R                  99       6  93.94%   88-93
R/cfbt01.R                     116       0  100.00%
R/checks.R                      14       0  100.00%
R/chevron_tlg-S4class.R         21       0  100.00%
R/chevron_tlg-S4methods.R      109       0  100.00%
R/cmt01a.R                      76       0  100.00%
R/coxt02.R                      40       1  97.50%   114
R/dmt01.R                       26       0  100.00%
R/dst01.R                       94       0  100.00%
R/dtht01.R                     102       6  94.12%   48, 52-56
R/egt02.R                       36       0  100.00%
R/egt03.R                       61       1  98.36%   127
R/egt05_qtcat.R                 60       0  100.00%
R/ext01.R                       46       4  91.30%   110-111, 115-116
R/fstg01.R                      42       1  97.62%   95
R/kmg01.R                       28       1  96.43%   69
R/lbt04.R                       69       0  100.00%
R/lbt05.R                       66       5  92.42%   125-130
R/lbt06.R                       63       3  95.24%   132-135
R/lbt07.R                       93       0  100.00%
R/lbt14.R                       57       0  100.00%
R/mht01.R                       71       0  100.00%
R/mng01.R                      113       1  99.12%   128
R/pdt01.R                       59       0  100.00%
R/pdt02.R                       66       0  100.00%
R/rmpt01.R                      46       2  95.65%   90, 110
R/rspt01.R                      73       3  95.89%   156-159
R/rtables_utils.R              161       2  98.76%   41, 98
R/standard_rules.R              11       0  100.00%
R/ttet01.R                     126       3  97.62%   226-229
R/utils.R                       50       0  100.00%
R/vst02.R                       46       1  97.83%   106
TOTAL                         2659      43  98.38%

Diff against main

Filename           Stmts    Miss  Cover
---------------  -------  ------  --------
R/egt05_qtcat.R       -3       0  +100.00%
TOTAL                 -3       0  -0.00%

Results for commit: 18e64a932a384a95c9da4b3a50d97d7d39fe3368

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2023

Unit Tests Summary

    1 files    49 suites   3m 16s ⏱️
216 tests 159 ✔️   57 💤 0
436 runs  303 ✔️ 133 💤 0

Results for commit ea7fcab.

♻️ This comment has been updated with latest results.

@clarkliming clarkliming changed the title remove filter of egt05 update egt05 Jun 9, 2023
Copy link
Contributor

@barnett11 barnett11 left a comment

Choose a reason for hiding this comment

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

I'm getting the below immediate error,
Error:
! adam_db$adeg$AVALCAT1 is not of type factor

@clarkliming
Copy link
Contributor Author

I'm getting the below immediate error, Error: ! adam_db$adeg$AVALCAT1 is not of type factor

this means that AVALCAT1 has to be of type factor, so after converting it to factor it will work. The reason to only allow factor is that the order is very important and we can't specify order for each parameter (if there is split_rows_by(PARAMCD)). we must make sure the order is correct (at least within each subgroup of data) and prune the 0 rows)

@barnett11
Copy link
Contributor

I'm getting the below immediate error, Error: ! adam_db$adeg$AVALCAT1 is not of type factor

this means that AVALCAT1 has to be of type factor, so after converting it to factor it will work. The reason to only allow factor is that the order is very important and we can't specify order for each parameter (if there is split_rows_by(PARAMCD)). we must make sure the order is correct (at least within each subgroup of data) and prune the 0 rows)

Thanks @clarkliming , yes I understand this, but this should be within egt05_pre shouldn't it? Otherwise this will fail everytime for every user unless they update their data?

@clarkliming
Copy link
Contributor Author

I'm getting the below immediate error, Error: ! adam_db$adeg$AVALCAT1 is not of type factor

this means that AVALCAT1 has to be of type factor, so after converting it to factor it will work. The reason to only allow factor is that the order is very important and we can't specify order for each parameter (if there is split_rows_by(PARAMCD)). we must make sure the order is correct (at least within each subgroup of data) and prune the 0 rows)

Thanks @clarkliming , yes I understand this, but this should be within egt05_pre shouldn't it? Otherwise this will fail everytime for every user unless they update their data?

this is really study specific: if we convert it to factor in pre, it is likely that the order is totally wrong. In my design, users should create script for this egt05, and they should update the pre after finding this error message. Once updated the script works. Is that ok?

@barnett11
Copy link
Contributor

Hi @clarkliming - this is the only template I've seen where we expect it to fail every time until the user does a step that is not automatic/instructed. Is this correct? Can we not set to a factor so the template runs, and then the user can determine the order after review? Of apply the order based on what we know already in standards (ie. '<=450 msec', '>450<=480 msec', '>480<=500 msec', '>500 msec')

@clarkliming
Copy link
Contributor Author

Hi @clarkliming - this is the only template I've seen where we expect it to fail every time until the user does a step that is not automatic/instructed. Is this correct? Can we not set to a factor so the template runs, and then the user can determine the order after review? Of apply the order based on what we know already in standards (ie. '<=450 msec', '>450<=480 msec', '>480<=500 msec', '>500 msec')

retriction has been loosen so it should work by default

@barnett11
Copy link
Contributor

Thanks @clarkliming , I now get the below error which is due to CHGCAT1 not present for BASELINE

Error in run(egt05_qtcat, adam_db = db, arm_var = "TRT01A") : 
  1 assertions failed:
 * Variable 'adam_db$adeg$CHGCAT1': All elements must have at least 1 characters.```

@clarkliming
Copy link
Contributor Author

Thanks @clarkliming , I now get the below error which is due to CHGCAT1 not present for BASELINE

Error in run(egt05_qtcat, adam_db = db, arm_var = "TRT01A") : 
  1 assertions failed:
 * Variable 'adam_db$adeg$CHGCAT1': All elements must have at least 1 characters.```

oh this reminds me why I add this restriction. AVALCAT1 and CHGCAT1 are needed to be valid values but rtables is not taking "" as valid values, and in SAS data it has to be "". We need to add a step of converting "" to NA in pre functions

@clarkliming
Copy link
Contributor Author

please note that there are still issues in rtables so the page_by is not correct right now

@barnett11
Copy link
Contributor

Thanks @clarkliming . A couple of observations,

  • I was expecting prune_0 as F to show all categories, but this does not happen? It only works if the user has set AVALCAT1 to factor prior to template?
  • I do not think the options for visitvar are meant to be AVISIT or ATPTN - could we update documentation to be AVISIT or user-defined visit incorporating ATPT?

@clarkliming
Copy link
Contributor Author

Thanks @clarkliming . A couple of observations,

  • I was expecting prune_0 as F to show all categories, but this does not happen? It only works if the user has set AVALCAT1 to factor prior to template?

it should return all levels; could you please provide your example and expected output?

  • I do not think the options for visitvar are meant to be AVISIT or ATPTN - could we update documentation to be AVISIT or user-defined visit incorporating ATPT?

will be fixed

@barnett11
Copy link
Contributor

Example using prune_0, I was thinking all levels for AVALCAT1 and CHGCAT1 would appear for every visit?

run(egt05_qtcat, adam_db = db, arm_var="TRT01A", prune_0=F)

    Analysis Visit                                  Placebo     RO12345678 10mg
    Category                                        (N=438)         (N=452)    
  —————————————————————————————————————————————————————————————————————————————
  QTcF - Fridericia's Correction Formula (msec)                                
    BASELINE                                                                   
      Analysis Value Category 1                                                
        n                                             438             452      
        <=450 msec                                438 (100%)      452 (100%)   
      Change from Baseline Category 1                                          
        n                                              0               0       
    Day 2                                                                      
      Analysis Value Category 1                                                
        n                                             438             452      
        <=450 msec                                430 (98.2%)     437 (96.7%)  
        >450<=480 msec                             8 (1.8%)        15 (3.3%)   
      Change from Baseline Category 1                                          
        n                                             438             452      
        <=30 msec                                 430 (98.2%)     437 (96.7%)  
        >60 msec                                   8 (1.8%)        15 (3.3%)   
    Day 3                                                                      
      Analysis Value Category 1                                                
        n                                             438             452      
        <=450 msec                                390 (89.0%)     409 (90.5%)  
        >450<=480 msec                            48 (11.0%)       43 (9.5%)   
      Change from Baseline Category 1                                          
        n                                             438             452      
        <=30 msec                                 390 (89.0%)     409 (90.5%)  
        >60 msec                                  48 (11.0%)       43 (9.5%)   
    Day 4                                                                      
      Analysis Value Category 1                                                
        n                                             426             441      
        <=450 msec                                416 (97.7%)     429 (97.3%)  
        >500 msec                                  10 (2.3%)       12 (2.7%)   
      Change from Baseline Category 1                                          
        n                                             426             441      
        <=30 msec                                 416 (97.7%)     429 (97.3%)  
        >60 msec                                   10 (2.3%)       12 (2.7%)   
    Follow Up Day 14                                                           
      Analysis Value Category 1                                                
        n                                             438             452      
        <=450 msec                                413 (94.3%)     432 (95.6%)  
        >450<=480 msec                             11 (2.5%)       12 (2.7%)   
        >500 msec                                  14 (3.2%)       8 (1.8%)  

@clarkliming
Copy link
Contributor Author

hi @barnett11 this is what I get

image

could you please reinstall latest and restart session and try again?

(and I think this table with prune_0=F is not correct, it may display other categories that is not for the parameter)

@barnett11
Copy link
Contributor

Indeed @clarkliming , it doesn't work very well for what the user may intend. I still cannot get every category displaying, the below is what I get currently,

> db <- data
> # Treatment group formatting
> db$adsl <- db$adsl %>% 
+   filter(SAFFL=="Y") %>%
+   mutate(TRT01A = factor(case_when(
+     TRT01A=="PLACEBO" ~ "Placebo",
+     TRT01A=="MPDL3280A" ~ "RO12345678 10mg"
+   )))
> db$adeg <- db$adeg %>% 
+   filter(SAFFL=="Y") %>% 
+   filter(PARAMCD=="QTCF") %>% 
+   mutate(TRT01A = factor(case_when(
+     TRT01A=="PLACEBO" ~ "Placebo",
+     TRT01A=="MPDL3280A" ~ "RO12345678 10mg"
+   ))) 
> run(egt05_qtcat, adam_db = db, arm_var="TRT01A", prune_0=F)
    Analysis Visit                                  Placebo     RO12345678 10mg
    Category                                        (N=438)         (N=452)    
  —————————————————————————————————————————————————————————————————————————————
  QTcF - Fridericia's Correction Formula (msec)                                
    BASELINE                                                                   
      Analysis Value Category 1                                                
        n                                             438             452      
        <=450 msec                                438 (100%)      452 (100%)   
      Change from Baseline Category 1                                          
        n                                              0               0       
    Day 2                                                                      
      Analysis Value Category 1                                                
        n                                             438             452      
        <=450 msec                                430 (98.2%)     437 (96.7%)  
        >450<=480 msec                             8 (1.8%)        15 (3.3%)   
      Change from Baseline Category 1                                          
        n                                             438             452      
        <=30 msec                                 430 (98.2%)     437 (96.7%)  
        >60 msec                                   8 (1.8%)        15 (3.3%)   
    Day 3                                                                      
      Analysis Value Category 1                                                
        n                                             438             452      
        <=450 msec                                390 (89.0%)     409 (90.5%)  
        >450<=480 msec                            48 (11.0%)       43 (9.5%)   
      Change from Baseline Category 1                                          
        n                                             438             452      
        <=30 msec                                 390 (89.0%)     409 (90.5%)  
        >60 msec                                  48 (11.0%)       43 (9.5%)   
    Day 4                                                                      
      Analysis Value Category 1                                                
        n                                             426             441      
        <=450 msec                                416 (97.7%)     429 (97.3%)  
        >500 msec                                  10 (2.3%)       12 (2.7%)   
      Change from Baseline Category 1                                          
        n                                             426             441      
        <=30 msec                                 416 (97.7%)     429 (97.3%)  
        >60 msec                                   10 (2.3%)       12 (2.7%)   
    Follow Up Day 14                                                           
      Analysis Value Category 1                                                
        n                                             438             452      
        <=450 msec                                413 (94.3%)     432 (95.6%)  
        >450<=480 msec                             11 (2.5%)       12 (2.7%)   
        >500 msec                                  14 (3.2%)       8 (1.8%)    
      Change from Baseline Category 1                                          
        n                                             438             452      
        <=30 msec                                 413 (94.3%)     432 (95.6%)  
        >60 msec                                   25 (5.7%)       20 (4.4%)   

and then with applying factor myself it works better,

> db$adeg <- db$adeg %>% 
+   filter(SAFFL=="Y") %>% 
+   filter(PARAMCD=="QTCF") %>% 
+   mutate(TRT01A = factor(case_when(
+     TRT01A=="PLACEBO" ~ "Placebo",
+     TRT01A=="MPDL3280A" ~ "RO12345678 10mg"
+   ))) %>% 
+   mutate(AVALCAT1 = factor(AVALCAT1)) %>% 
+   mutate(CHGCAT1 = factor(CHGCAT1))
> run(egt05_qtcat, adam_db = db, arm_var="TRT01A", prune_0=F)
    Analysis Visit                                  Placebo     RO12345678 10mg
    Category                                        (N=438)         (N=452)    
  —————————————————————————————————————————————————————————————————————————————
  QTcF - Fridericia's Correction Formula (msec)                                
    BASELINE                                                                   
      AVALCAT1                                                                 
        n                                             438             452      
        <=450 msec                                438 (100%)      452 (100%)   
        >450<=480 msec                                 0               0       
        >500 msec                                      0               0       
      CHGCAT1                                                                  
        n                                              0               0       
        <=30 msec                                      0               0       
        >60 msec                                       0               0       
    Day 2                                                                      
      AVALCAT1                                                                 
        n                                             438             452      
        <=450 msec                                430 (98.2%)     437 (96.7%)  
        >450<=480 msec                             8 (1.8%)        15 (3.3%)   
        >500 msec                                      0               0       
      CHGCAT1                                                                  
        n                                             438             452      
        <=30 msec                                 430 (98.2%)     437 (96.7%)  
        >60 msec                                   8 (1.8%)        15 (3.3%)   
    Day 3                                                                      
      AVALCAT1                                                                 
        n                                             438             452      
        <=450 msec                                390 (89.0%)     409 (90.5%)  
        >450<=480 msec                            48 (11.0%)       43 (9.5%)   
        >500 msec                                      0               0       
      CHGCAT1                                                                  
        n                                             438             452      
        <=30 msec                                 390 (89.0%)     409 (90.5%)  
        >60 msec                                  48 (11.0%)       43 (9.5%)   
    Day 4                                                                      
      AVALCAT1                                                                 
        n                                             426             441      
        <=450 msec                                416 (97.7%)     429 (97.3%)  
        >450<=480 msec                                 0               0       
        >500 msec                                  10 (2.3%)       12 (2.7%)   
      CHGCAT1                                                                  
        n                                             426             441      
        <=30 msec                                 416 (97.7%)     429 (97.3%)  
        >60 msec                                   10 (2.3%)       12 (2.7%)   

@clarkliming
Copy link
Contributor Author

@barnett11 I get your point. Actually, I did not convert anything to factor. characters are allowed here. I totally understand your concern that the rows are not printed( and if you may run into issues if a level is only owned by a arm, which I think is not so good).

I wonder, shall we provide some documentation to say that, please use 'factors' if custom sorting is needed? and we still allow the variables to be in character?

@barnett11
Copy link
Contributor

@barnett11 I get your point. Actually, I did not convert anything to factor. characters are allowed here. I totally understand your concern that the rows are not printed( and if you may run into issues if a level is only owned by a arm, which I think is not so good).

I wonder, shall we provide some documentation to say that, please use 'factors' if custom sorting is needed? and we still allow the variables to be in character?

Yes, as long as the user knows how to achieve this then that's fine, documentation would suffice

@clarkliming
Copy link
Contributor Author

@barnett11 documentation added; and let's don't wait for tern's bug (anyway we can, by default don't use page by)

@github-actions
Copy link
Contributor

github-actions bot commented Jul 11, 2023

🧪 $Test coverage: 97.72%$

Code Coverage Summary

Filename                     Stmts    Miss  Cover    Missing
-------------------------  -------  ------  -------  -------------------------------------------------
R/ael01_nollt.R                 17       1  94.12%   61
R/aet01_aesi.R                 149       1  99.33%   211
R/aet01.R                       94       1  98.94%   158
R/aet02.R                       60       0  100.00%
R/aet03.R                       77       0  100.00%
R/aet04.R                       89       0  100.00%
R/aet05_all.R                   11       0  100.00%
R/aet05.R                       36       1  97.22%   101
R/aet10.R                       43       0  100.00%
R/assertions.R                  99       6  93.94%   88-93
R/cfbt01.R                     104       0  100.00%
R/checks.R                      14       0  100.00%
R/chevron_tlg-S4class.R         18       0  100.00%
R/chevron_tlg-S4methods.R      103       0  100.00%
R/cmt01a.R                      77       0  100.00%
R/coxt01.R                      48       1  97.92%   126
R/dmt01.R                       27       0  100.00%
R/dst01.R                       95       0  100.00%
R/dtht01.R                     103       6  94.17%   48, 52-56
R/egt02.R                       37       0  100.00%
R/egt03.R                       61       1  98.36%   127
R/egt05_qtcat.R                 77       0  100.00%
R/ext01.R                       61       1  98.36%   40
R/fstg01.R                      42       1  97.62%   95
R/kmg01.R                       28       1  96.43%   69
R/lbt04.R                       69       0  100.00%
R/lbt05.R                       67       5  92.54%   125-130
R/lbt06.R                       63       3  95.24%   131-134
R/lbt07.R                       94       0  100.00%
R/lbt14.R                       57       0  100.00%
R/mht01.R                       72       0  100.00%
R/mng01.R                       97       1  98.97%   110
R/pdt01.R                       61       0  100.00%
R/pdt02.R                       69       0  100.00%
R/rmpt01.R                      65      11  83.08%   91-100, 143
R/rspt01.R                      73       3  95.89%   156-159
R/rtables_utils.R              246      17  93.09%   41, 98, 210, 230, 416, 431-433, 435, 453-459, 469
R/standard_rules.R              11       0  100.00%
R/ttet01.R                     129       3  97.67%   229-232
R/utils.R                       65       0  100.00%
R/vst02.R                       47       1  97.87%   107
TOTAL                         2855      65  97.72%

Diff against main

Filename           Stmts    Miss  Cover
---------------  -------  ------  --------
R/egt05_qtcat.R      +13       0  +100.00%
TOTAL                +13       0  +0.01%

Results for commit: b85463c627d3140d308312a9d3b90431cc956fd6

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

Copy link
Contributor

@BFalquet BFalquet left a comment

Choose a reason for hiding this comment

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

Please see related PR: insightsengineering/dunlin#106
Nice to see this template being finalized

R/standard_rules.R Show resolved Hide resolved
R/egt05_qtcat.R Outdated Show resolved Hide resolved
R/egt05_qtcat.R Outdated Show resolved Hide resolved
clarkliming and others added 4 commits July 11, 2023 13:21
Co-authored-by: b_falquet <64274616+BFalquet@users.noreply.github.com>
Signed-off-by: Liming <36079400+clarkliming@users.noreply.github.com>
Copy link
Contributor

@barnett11 barnett11 left a comment

Choose a reason for hiding this comment

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

Lovely, that's looking really good now thanks

@clarkliming clarkliming merged commit 24717f7 into main Jul 14, 2023
23 checks passed
@clarkliming clarkliming deleted the 413_qtcat@main branch July 14, 2023 09:06
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.

EGT05_QTCAT bug with real data
3 participants