admiral icon indicating copy to clipboard operation
admiral copied to clipboard

Enhancing `derive_var_trtemfl()` to deal with AEs recorded on multiple lines

Open manciniedoardo opened this issue 1 year ago • 20 comments

Background Information

(Courtesy of @kaz462)

Currently, derive_var_trtemfl derives TEAE flag with the assumption that AEs are recorded as a single line for each event (one record in the database). But some studies record one episode of AE with multiple lines using a grouping variable - could we take the grouping variable into consideration when AE data is collected this way e.g., the following subject ABC-1 has two episodes of AE:

  1. AEGRPID = 1, ASEQ = 1,2,3
  2. AEGRPID = 2, ASEQ = 4,5,6

image

Some other examples with a grouping variable:

Definition of Done

derive_var_trtemfl() enhanced to deal with these cases also, without breaking backwards compatibility.

manciniedoardo avatar Jan 19 '24 09:01 manciniedoardo

Hi @ashachakma - how is this one going? any questions? Do you think you will be able to finish before our "other works" gets busy or do you want to hold off until afterwards?

bms63 avatar Feb 02 '24 19:02 bms63

@ashachakma @bms63 thanks for picking up this issue and following up @pharmaverse/admiral What do you think of adding a new argument for grouping variable - derive_var_trtemfl(..., group_var)?

  • if group_var is missing, the function will remain the same as the current derivation, assuming AE data collection method as single record per AE

  • if group_var is populated, we assume AE data collection involves multiple records per AE. In this case, we flag TEAE with two scenarios below: 1. new AE: records with missing AEITOXGR 2. if an AE exists before TRTSDT, any records after the 1st worsen date post-TRTSDT and within TEAE window

kaz462 avatar Feb 02 '24 19:02 kaz462

@ashachakma @bms63 thanks for picking up this issue and following up @pharmaverse/admiral What do you think of adding a new argument for grouping variable - derive_var_trtemfl(..., group_var)?

  • if group_var is missing, the function will remain the same as the current derivation, assuming AE data collection method as single record per AE
  • if group_var is populated, we assume AE data collection involves multiple records per AE. In this case, we flag TEAE with two scenarios below:
    1. new AE: records with missing AEITOXGR
    2. if an AE exists before TRTSDT, any records after the 1st worsen date post-TRTSDT and within TEAE window

I like this idea as it doesn't impact the function's original purpose. Do you mind putting on the agenda for Wednesday and we can make final decision? Others please add thoughts too!!

bms63 avatar Feb 02 '24 20:02 bms63

Hi @ashachakma - how is this one going? any questions? Do you think you will be able to finish before our "other works" gets busy or do you want to hold off until afterwards?

Hi Ben, this is my first time working on a function enhancement so, I might take some time to finish it. Till now, I looked into the document and, trying to understand how the function is working. My study has SAC work from next week so, I will try to finish it by this week else I will continue after my study work finishes.
I also liked @kaz462 suggestion but I will wait till the final decision on Wednesday.

ashachakma avatar Feb 05 '24 04:02 ashachakma

Awesome!! It is a good one for you. We can help - so don't hesitate on asking questions!!

bms63 avatar Feb 05 '24 16:02 bms63

Awesome!! It is a good one for you. We can help - so don't hesitate on asking questions!!

Sure Ben, thanks. As I progress I will have more questions, for now, @gg106046 is helping me with the basic ones.

ashachakma avatar Feb 06 '24 05:02 ashachakma

Hi @manciniedoardo @kaz462 @bms63 , can you provide me with an example of how the AEITOXGR will look if the grouping variable is present in the AE data? The above example shows without AEITOXGR, it's quite puzzling how to consider the worsening condition if both AEITOXGR and AETOXGR are present. Thanks!

ashachakma avatar Feb 07 '24 06:02 ashachakma

Is my understanding correct?- once a record within a grouped AE is flagged as a TEAE within the window, then any subsequent record should also be a TEAE regardless of the severity and when it starts relative to the window.

ashachakma avatar Feb 07 '24 10:02 ashachakma

@kaz462 I have not heard any grumblings about this enhancement - so I think we can go ahead with your proposal. Is it possible to supply Asha with some additional examples?

bms63 avatar Feb 07 '24 18:02 bms63

Is my understanding correct?- once a record within a grouped AE is flagged as a TEAE within the window, then any subsequent record should also be a TEAE regardless of the severity and when it starts relative to the window.

@ashachakma thanks for looking into it! Your understanding is correct, we assign ASEQ =6 as TEAE at Bayer in the example below, I'm not sure if Roche/GSK have the same handling

Example with AEITOXGR added: (Initial severity with grouping variable can be derived as last AE severity before TRTSDT)

# A tibble: 6 × 10
  USUBJID AEGRPID ASEQ  AETERM   ASTDT      TRTSDT     TRTEDT     AETOXGR TRTEMFL AEITOXGR
  <chr>   <chr>   <chr> <chr>    <chr>      <chr>      <chr>      <chr>   <chr>   <chr>   
1 ABC-1   1       1     Headache 2020-01-01 2020-01-05 2020-03-05 2       NA      2       
2 ABC-1   1       2     Headache 2020-01-15 2020-01-05 2020-03-05 1       NA      2       
3 ABC-1   1       3     Headache 2020-02-15 2020-01-05 2020-03-05 2       Y       2       
4 ABC-1   2       4     Fever    2020-01-01 2020-01-05 2020-03-05 2       NA      2       
5 ABC-1   2       5     Fever    2020-01-15 2020-01-05 2020-03-05 3       Y       2       
6 ABC-1   2       6     Fever    2020-02-15 2020-01-05 2020-03-05 1       Y       2    

I summarized our internal spec into the following workflow, do you think we can apply it when enhance this function?

flowchart TB

AEITOXGR["AEITOXGR"] -->|"missing AEITOXGR: \n AE not exist before TRTSDT"| arise1["New AE records \n within TEAE window"] --> |New|TEAE[Step 3: Flag records identified above as TEAE]

AEITOXGR -->|"non-missing AEITOXGR:  \n AE exist before TRTSDT"|Worsen1["Step 1: Identify worsened records \n (compare with the previous record) \nafter TRTSDT"]--> Worsen2["Step 2: Get the first worsen date \n after TRTSDT"]-->worsen3["All records after \n the 1st worsen date \n and within TEAE window"]--> |Worsen|TEAE

style TEAE fill:#b3ffb3,stroke:#4CAF50,stroke-width:2px
style Worsen1 fill:#b3ffb3,stroke:#4CAF50,stroke-width:2px
style Worsen2 fill:#b3ffb3,stroke:#4CAF50,stroke-width:2px

kaz462 avatar Feb 09 '24 17:02 kaz462

Hi @kaz462, thanks for your response and the flowchart, this is very helpful. Yeah, I think this can be applied while enhancing the function. Thanks!

ashachakma avatar Feb 13 '24 12:02 ashachakma

I am facing this issue while running pkgdown::build_site()-

Capture_1

ashachakma avatar Mar 05 '24 12:03 ashachakma

Umm...we have seen this issue in another PR. https://github.com/pharmaverse/admiral/pull/2350

@sheramin did this ever get resolved?

bms63 avatar Mar 05 '24 15:03 bms63

@ashachakma I am able to rebuild the site from your branch

bms63 avatar Mar 05 '24 15:03 bms63

Umm...we have seen this issue in another PR. #2350

@sheramin did this ever get resolved?

@bms63 nope, we discussed it a little bit on Slack, but those solution didn't work either. It's interesting that it works on your end. It looks like the problem is on our end, not the branch. I removed it a few times and downloaded everything from scratch, but no luck. I'll do it again. Can it be R version issue? My R is 4.2.1

sheramin avatar Mar 05 '24 15:03 sheramin

Can you do a session info dump here please. @ashachakma be nice for you to do as well

bms63 avatar Mar 05 '24 15:03 bms63

Can you do a session info dump here please. @ashachakma be nice for you to do as well

Sure, here it is: image

sheramin avatar Mar 05 '24 16:03 sheramin

Can you do a session info dump here please. @ashachakma be nice for you to do as well

Sure- image

ashachakma avatar Mar 06 '24 06:03 ashachakma

I have the same situation as #2350 .Rmd file do not have analysis_var but I see this parameter in .R file.

ashachakma avatar Mar 06 '24 11:03 ashachakma

I restarted my laptop and tried again running pkgdown::build_site(), it ran successfully :) but other checks are failing so, checking those issues now.

ashachakma avatar Mar 06 '24 12:03 ashachakma