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

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

Closed
manciniedoardo opened this issue Jan 19, 2024 · 20 comments · Fixed by #2362
Closed

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

manciniedoardo opened this issue Jan 19, 2024 · 20 comments · Fixed by #2362
Assignees
Labels

Comments

@manciniedoardo
Copy link
Collaborator

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.

@bms63
Copy link
Collaborator

bms63 commented Feb 2, 2024

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?

@kaz462
Copy link
Collaborator

kaz462 commented Feb 2, 2024

@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

@bms63
Copy link
Collaborator

bms63 commented Feb 2, 2024

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

@ashachakma
Copy link
Collaborator

ashachakma commented Feb 5, 2024

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.

@bms63
Copy link
Collaborator

bms63 commented Feb 5, 2024

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

@ashachakma
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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.

@bms63
Copy link
Collaborator

bms63 commented Feb 7, 2024

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

@kaz462
Copy link
Collaborator

kaz462 commented Feb 9, 2024

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

@ashachakma
Copy link
Collaborator

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 pushed a commit that referenced this issue Mar 5, 2024
@ashachakma
Copy link
Collaborator

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

Capture_1

@bms63
Copy link
Collaborator

bms63 commented Mar 5, 2024

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

@sheramin did this ever get resolved?

@bms63
Copy link
Collaborator

bms63 commented Mar 5, 2024

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

@sheramin
Copy link

sheramin commented Mar 5, 2024

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

@bms63
Copy link
Collaborator

bms63 commented Mar 5, 2024

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

@sheramin
Copy link

sheramin commented Mar 5, 2024

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

Sure, here it is:
image

@ashachakma
Copy link
Collaborator

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

Sure-
image

@ashachakma
Copy link
Collaborator

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

@ashachakma ashachakma linked a pull request Mar 6, 2024 that will close this issue
15 tasks
@ashachakma
Copy link
Collaborator

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 pushed a commit that referenced this issue Mar 6, 2024
ashachakma pushed a commit that referenced this issue Mar 7, 2024
@bms63 bms63 changed the title Enhancing derive_var_trtemfl() to deal with AEs recorded on multiple lies Enhancing derive_var_trtemfl() to deal with AEs recorded on multiple lines Mar 8, 2024
ashachakma pushed a commit that referenced this issue May 24, 2024
ashachakma pushed a commit that referenced this issue May 27, 2024
…re created using `get_new_tmp_var()`, other changes updated suggested in the review comment
kaz462 added a commit that referenced this issue Jun 1, 2024
kaz462 added a commit that referenced this issue Jun 1, 2024
bms63 added a commit that referenced this issue Jun 4, 2024
* #2302 New argument, group_var added

* #2302 Fixed spelcheck and styler error

* #2302 Fixed lintr and roxygen related issues

* #2302 Fixed styler issue

* #2302 Updated new global variables, added `lag()` in NAMESPACE

* #2302 Fixed lintr and styler issue

* #2302 Fixed issue related to roxygen check

* #2302 header updated with group_var details and temporary variables are created using `get_new_tmp_var()`, other changes updated suggested in the review comment

* Update R/derive_var_trtemfl.R

Co-authored-by: Stefan Bundfuss <80953585+bundfussr@users.noreply.github.com>

* Update R/derive_var_trtemfl.R

Co-authored-by: Stefan Bundfuss <80953585+bundfussr@users.noreply.github.com>

* Update R/derive_var_trtemfl.R

Co-authored-by: Stefan Bundfuss <80953585+bundfussr@users.noreply.github.com>

* Update R/derive_var_trtemfl.R

Co-authored-by: Stefan Bundfuss <80953585+bundfussr@users.noreply.github.com>

* #2302: add subject_keys, update check for initial_intensity

* #2302: update new AE derivation/get_new_tmp_var

* #2302: devtools::document()

* #2302: upversion roxygen2

* #2302: update group_var/subject_key description, check, and example

* #2302 enhance_derive_var_trtemfl: update subject_keys argument

* #2302 enhance_derive_var_trtemfl: fix example

---------

Co-authored-by: Jerry Johnson <jerry@gmail.com>
Co-authored-by: Ben Straub <ben.x.straub@gsk.com>
Co-authored-by: Kangjie Zhang <47867131+kaz462@users.noreply.github.com>
Co-authored-by: Stefan Bundfuss <80953585+bundfussr@users.noreply.github.com>
Co-authored-by: Kangjie Zhang <kangjie.zhang@bayer.com>
Co-authored-by: Stefan Bundfuss <stefan.bundfuss@roche.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

5 participants