Skip to content
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7fedefc
step 1
Feb 19, 2025
8fd0d70
Create Adverse Event (AE grade) .Rmd
Feb 19, 2025
bc6b3a1
Delete Adeverse event (AE grade).Rmd
Feb 19, 2025
e50d185
part 1
Feb 19, 2025
4b0b379
part 2
Feb 19, 2025
410704a
part 3
Feb 19, 2025
ae6ff7f
delete KM
Feb 19, 2025
f1cbd4b
rename the RMD
Feb 19, 2025
dbd4c63
Update ae_grade.Rmd
Jun 2, 2025
1a0a3e3
Merge branch 'main' into AE
DanChaltiel Jun 2, 2025
88b6689
Discard changes to grstat.Rproj
DanChaltiel Jun 2, 2025
7771a36
Update ae_grade.Rmd
Jun 20, 2025
64c0f47
change title
Jun 30, 2025
a61f006
not All AE
Jun 30, 2025
063a711
format
Jun 30, 2025
32cefa0
rename
Lpierott Jun 30, 2025
aeec73e
Update adverse_events.Rmd
Lpierott Jul 2, 2025
9d341bc
correction for the variant=eq
Lpierott Jul 2, 2025
710118a
bits and bos
Lpierott Jul 2, 2025
8fecd74
add table of max grade per arm
Lpierott Jul 2, 2025
8fb973c
bits and bobs
Lpierott Jul 2, 2025
ea3a4bc
ae_table_grade
Lpierott Jul 2, 2025
1482801
Update adverse_events.Rmd
Lpierott Jul 18, 2025
893d51a
Create ORR.Rmd
Lpierott Jul 18, 2025
0258e4f
Update grstat.Rproj
Lpierott Sep 15, 2025
46e68fc
Updates of the very long time pendings comments
Lpierott Oct 8, 2025
6dcfba1
work in pogress des table SOC
Lpierott Oct 8, 2025
93ca35c
back ticks + comment on grade's tables
Lpierott Oct 9, 2025
e8a9d3b
Update adverse_events.Rmd
Lpierott Oct 9, 2025
dfa6942
SOC tables
Lpierott Oct 9, 2025
2dd1e4a
parenthese au functions
Lpierott Oct 31, 2025
0121783
ctrl-I
Nov 4, 2025
a9cc7c0
petit problem de crtl I
Lpierott Nov 12, 2025
3a530dd
Revert "Update grstat.Rproj"
Lpierott Nov 12, 2025
20428cc
parentheses
Lpierott Nov 12, 2025
b498c91
change the date
Lpierott Dec 12, 2025
bed5520
commentaire de charlotte part 1
Lpierott Dec 12, 2025
8e25589
esplain what is the variant in here
Lpierott Dec 15, 2025
c77dd91
CTCAE
Lpierott Dec 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion grstat.Rproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Version: 1.0
ProjectId: d350bac8-4795-42a0-a32d-ccb93a467950

RestoreWorkspace: No
SaveWorkspace: No
Expand Down
115 changes: 115 additions & 0 deletions vignettes/adverse_events.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
title: "Adverse Events (AE)"
output:
rmarkdown::html_vignette:
number_sections: true
vignette: >
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
date: "2025-01-30"
---
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the date, can we change the one in KM too and remove my name? I did not realise that when we done it!

Copy link
Member

Choose a reason for hiding this comment

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

Not sure what I think about having the date, as different parts may have different update times.
However, I like that author's names are written, it gives credit where its due, why removing it?


<!-- https://oncostat.github.io/grstat/articles/adverse_events_sas.html -->

# Introduction

This tutorial demonstrates how to generate adverse event (AE) summary tables in R using the `grstat` package. AE tables are a standard tool in clinical research for evaluating the severity (grade) of events and identifying specific AE terms.

In this tutorial, it is demonstrated how to use two key functions:

- `ae_table_grade`, which creates table(s) summarising AE grades overall.

- `ae_table_soc`, which summarises adverse events by System Organ Class (SOC) and by grades. It reports the number and proportion of patients experiencing at least one event within each SOC, based on their maximum recorded AE grade.

First, install packages if needed and load them.

```{r setup, message=FALSE, warning=FALSE}
library(grstat)
library(flextable)
library(dplyr)
```

# Data Overview

The function `grstat_example()` is used as an example dataset to illustrate the data usage.

This analysis focuses on two datasets:

- `ae`, which contains data on adverse events.

- `enrolres`, which includes all patients and their respective treatment arms.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Charlotte's comment:
On n’a pas de précision sur la table ae : il faudrait dire qu’à chaque fois qu’un adverse event est reporté, il y a des informations comme le grade, le terme, le SOC (les définir), le fait que cet AE soit relié au traitement, s’il est considéré comme SAE (définitions)… qui sont représentées sur une seule ligne pour chaque AE. Un patient peut avoir plusieurs AEs et aura donc autant de ligne que d’AEs dans cette table. Un patient peut ne pas avoir d’AEs et ne pas être dans la table.

Answer:
J'ai fait une head ae et enrolres pour avoir une idee du dataset.
Alors oui et non. C’est pas un cour non plus de Clinical trial sur les AE mais c’est comment présenter les AE dans un rapport stats.

Copy link
Member

Choose a reason for hiding this comment

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

Faire head ae est suffisant, je suis d'accord.
Si on décrit trop, la vignette est trop longue et personne ne la lit.

```{r}

tm = grstat_example()
attach(tm)

head(ae, 4)

head(enrolres,4)

```

# Grade Tables only: `ae_table_grade`

Create adverse event (AE) grade tables using `ae_table_grade()`.

By default, the function `ae_table_grade` produces three table variants within a single output.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have changed the writting as Charlotte said few times that the word "variant" is very confusing, and the reader do not know what it is about. I agree!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Commentaire de Charlotte: "On manque de précision sur le rendu global de cette fonction avant d’entrer dans les détails des « variants ». C’est une fonction qui va donner comme statistique un effectif et un pourcentage d’apparition de tel type d’AE, à tel grade, pour tel bras de traitement … "

Reponse: Not sure if it needs more writing that there is already.

Copy link
Member

@DanChaltiel DanChaltiel Dec 17, 2025

Choose a reason for hiding this comment

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

C'est vrai que le terme "variant" est confusing, et du coup je suis d'accord qu'il faut plutôt d'abord décrire ce que fait la fonction par défaut.
Genre : "la fonction décrit 3 estimates: le grade max et l'ocurrence de grade égal ou sup ou égal blablabla. On peut contrôler l'output avec l'argument variant"
Pas forcément besoin de détailler plus, normalement le lecteur devrait vite comprendre le principe.

- The most common variant is **`variant = "max"`**, which generates the table of maximum AE grade per patient, where N = total number of patients.

- The second variant, **`variant = "sup"`**, summarises the grades greater than or equal to a specified grade per patient, where n is the number of patients having experienced at least one AE of grade higher or equal to X.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

J ai rajoute " ≥ X, where X ∈ {1, 2, 3, 4, 5}." parce que charlotte le suggereait plus ou moins dans une de ces commentaire; "Quel argument permet de fixer le X d’intérêt? ". le max grade en oncology c est bien 5?

Copy link
Member

Choose a reason for hiding this comment

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

Le max c'est 5 partout, pas juste en oncologie.
C'est vraiment difficile de décrire ce truc de "égal versus sup/égal", mais je n'ai pas l'impression que ce soit plus clair avec une notation plus math. En tout cas moi ça me perdrait plus qu'autre chose.

BTW, je ne suis pas sûr de "most common", ça dépend des pratiques des uns et des autres, des journaux, etc.

- The third variant, **`variant = "eq"`**, presents all grades for all patients. In this table, each proportion represents the number of patients who experienced a given grade at least once, where n is the number of patients having experienced at least one AE of grade equal to X.

## Default AE Table Grades - incuding All Variants (Max, Sup, Eq)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Charlotte Commentaires: Ok sur le rendu par défaut mais mérite d’être plus clair avant. Par ailleurs, est-ce qu’il n’y a pas un moyen d’avoir des noms de colonne plus jolis et standards que « label », « variable », « treatment arm » tout en ayant « all patients » juste en dessous… dans les MACRO SAS les majuscules/minuscules et noms de colonnes étaient un peu plus soignés. Il faut voir comment modifier ces noms de colonnes de tableaux voir les supprimer sauf quand il y a les bras de traitements et des effectifs.

Copy link
Member

@DanChaltiel DanChaltiel Dec 17, 2025

Choose a reason for hiding this comment

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

C'est une bonne remarque !
A la base ces tables venaient de crosstable donc les noms de colonnes viennent de là. C'est vrai qu'ils ne sont pas du tout adaptés dans ce contexte.
On peut les modifier, ce n'est pas très compliqué à faire, il faudrait le mettre dans une nouvelle issue avec une suggestion de nom.

```{r}
ae_table_grade(df_ae=ae, df_enrol=enrolres) %>%
as_flextable(header_show_n=TRUE) %>%
fontsize(size = 8, part = "all") %>%
padding(padding.top=0, padding.bottom=0)
```

## Custom table of maximum AE grade per patient per arm

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Charlotte comment: Préciser que arm = “arm” signifie que le bras de traitement a pour nom de variable “arm” et est issu du data frame “enrolres”.
Answer:Not quite sure every single things should be explain

Copy link
Member

Choose a reason for hiding this comment

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

not sure either

As an extra example of AE grade table, a table of maximum grade per patient and per arm (i.e. variant = "max") is also presented.

```{r}
ae_table_grade(df_ae=ae, df_enrol=enrolres, arm="arm", variant="max") %>%
as_flextable(header_show_n=TRUE) %>%
add_footer_lines("Percentages reflect the proportion of patients whose maximum AE grade was as indicated per given arm.") %>%
fontsize(size = 8, part = "all") %>%
padding(padding.top=0, padding.bottom=0)
```

# SOC's tables: `ae_table_soc`

The function ae_table_soc() creates a summary table of AE grades for each patient according to AE term and SOC CTCAE. The resulting dataframe can be piped to as_flextable() to get a nicely formatted flextable.

## Table of AE grades by SOC

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Charlotte: La colonne s’appelle “Total” (texte) ou “Tot » (sur la sortie R) ?
On n’explique pas pourquoi on a ajouté les arguments « term = NULL » et sort_by_count = FALSE. D’ailleurs le sort_by_count n’est jamais à TRUE dans un exemple de ctet vignette.

Answer: pour montrer la difference entre la table 4.1 et table 4.2

Copy link
Member

Choose a reason for hiding this comment

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

A la base, j'avais mis Tot pour que ce soit aussi court que "G5", surtout dans les tables très larges.
Mais c'est vrai que c'est moche en fait, et ça ne fait pas gagner tant de place vu les nombres dans la colonne.
Idem, à mettre dans une issue, c'est un problème de la fonction ae_table_soc(), pas de la vignette.

This table summarises the distribution of adverse event grades by System Organ Class (SOC). You can add total = FALSE to remove the “Total” column.

```{r}
ae_table_soc(df_ae=ae, df_enrol=enrolres, arm=NULL, term=NULL,
sort_by_count=FALSE) %>%
head(10) %>%
as_flextable() %>%
add_footer_lines("In the header, N represents the number of patients.") %>%
add_footer_lines("Percentages reflect the proportion of patients whose maximum AE grade was as indicated.")
```


## Table of SOC and AE terms, all grades combined, stratified by arm

Presents SOC and Preferred Term frequencies with all AE grades combined, stratified by treatment arm. Provides an overall summary of event occurrence per arm, regardless of grade.

```{r}
ae_table_soc(df_ae=ae, df_enrol=enrolres, arm="arm", term="aeterm",
sort_by_count=FALSE) %>%
head(10) %>%
as_flextable() %>%
add_footer_lines("In the header, N represents the number of patients.") %>%
add_footer_lines("Percentages reflect the proportion of patients whose maximum AE grade was as indicated.")
```
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Charlotte's comment:  Pas d’indication sur les autres manières de reporter les AEs ? Filtre sur les SAEs ? Filtre sur les AEs reliés au traitement ?
 Il manque une partie avec la liste des arguments des fonctions et ce à quoi ils correspondent, sous quels formats ils doivent être, s’ils sont obligatoires ou optionnels, quelles sont leurs valeurs par défaut, comment ils sont utilisés pour faire les sorties des tableaux…

Answer: je suis pas sur qu on devrait rallonger la vignette peu etre mais pas pour le moment, comme on avait dit pour les TEAE. enssuite le fait de faire la liste de tout les elments de la function ca c est dan la help, right?

Copy link
Member

Choose a reason for hiding this comment

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

Oui c'est dans le help.
Tu peux peut-être écrire "pour plus d'exemples (genre filtrer), aller voir la doc avec ce lien" ?

Loading