Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
63521d9
Update dev version (Github Actions)
github-actions[bot] Sep 23, 2024
15f314a
validation functions added for ae_table_grade
BaptisteArchambaud Sep 23, 2024
b3c2fb8
Merge branch 'baptiste-validation' of https://github.com/Oncostat/grs…
BaptisteArchambaud Sep 23, 2024
2af87f8
Update dev version (Github Actions)
github-actions[bot] Sep 23, 2024
6a4b9e7
updating structure of AE_table_grade validation files
BaptisteArchambaud Oct 29, 2024
c39b6fd
Merge branch 'main' into baptiste-nusaibah-validation
BaptisteArchambaud Oct 30, 2024
7d743c5
Update outputs_ae_table_grade.R
BaptisteArchambaud Nov 4, 2024
e5d6c1a
ae_table_soc validation - formatting SAS and R outputs
BaptisteArchambaud Nov 6, 2024
99e08ff
compare_grade output table
NusaibahIbr Nov 19, 2024
dcb1467
sortie des 2 tables concordantes
NusaibahIbr Nov 21, 2024
e5447f8
create compare_soc (copy compare_grade)
NusaibahIbr Nov 21, 2024
d8c1d68
modification according AE output with SOC & PT
NusaibahIbr Nov 25, 2024
cc6e7fa
correction
NusaibahIbr Nov 25, 2024
60b5318
Nettoyer le script et compatibilité avec les tables avec bras de trt
NusaibahIbr Dec 26, 2024
e272d83
improve and finish compare_soc function
NusaibahIbr Dec 26, 2024
3d6074c
work in progress
NusaibahIbr Jan 2, 2025
09a1057
Merge branch 'main' into baptiste-nusaibah-validation
NusaibahIbr Jan 2, 2025
632809c
end to major modifications
NusaibahIbr Jan 16, 2025
eca9df5
formatting with flextable package
NusaibahIbr Feb 3, 2025
4115b8a
change to make the comparison more exhaustive
NusaibahIbr Apr 2, 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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: grstat
Type: Package
Title: Clinical Research Tools
Version: 0.1.0.9004
Version: 0.1.0.9006
Authors@R: c(
person("Dan", "Chaltiel", role = c("aut", "cre"),
email = "dan.chaltiel@gustaveroussy.fr",
Expand Down
24 changes: 24 additions & 0 deletions R/validation fonctions AE_table_grade/compair_grade.R
Copy link
Member

Choose a reason for hiding this comment

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

ce seront des fonctions de testing, elles ne doivent pas aller dans R/
Utilise usethis::use_test_helper()
Tu peux aussi aller voir la doc de testthat: https://cran.r-project.org/web/packages/testthat/vignettes/special-files.html

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

compair_grade <- function(tabR,tabSAS){

if (nrow(tabR)!=nrow(tabSAS)){stop("Different number of grade levels")
}
Copy link
Member

Choose a reason for hiding this comment

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

soit sur une ligne, sans les {},
soit sur 3 lignes
jamais sur 2


if (ncol(tabR)!=ncol(tabSAS)){stop("Different number of arm")}
if (all(dim(tabR)==dim(tabSAS))){
print("Check: same dimension of tables")
Copy link
Member

Choose a reason for hiding this comment

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

programmation défensive: on ne print pas si tout va bien, on warn s'il y a un problème

df=tabR%>%arrange(grade)%>%full_join(tabSAS,by="grade",suffix = c(".r",".sas"))
indice=which(df[,paste0(tabR%>%select(-grade)%>%colnames(),paste=".r")]!=df[,paste0(tabSAS%>%select(-grade)%>%colnames(),paste=".sas")],
Copy link
Member

Choose a reason for hiding this comment

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

je n'aime vraiment pas les indices, je trouve que c'est à risque d'erreur
Cf mon commentaire sur Teams

arr.ind=TRUE)
indice[,"col"]=indice[,"col"]+1 # parce qu'on avait retiré le grade
}
if (nrow(indice)!=0){
print(indice)
warning(paste0("Comparison result: Warning! Different outputs.\n",
nrow(indice)," mismatching between the two tables. Above, the indices."))

}else{
warning("Comparison result: same outputs")
}

}
23 changes: 23 additions & 0 deletions R/validation fonctions AE_table_grade/group_grades_zeroNA.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#fonction grouping figures of missing grades and grades 0 for R function ae_table_grade
group_grades_zeroNA <- function(data, round = 0){

#suming N of missing grades and grades 0
data <- data %>%
mutate(grade = replace_na(grade, 0)) %>%
group_by(grade) %>%
Copy link
Member

Choose a reason for hiding this comment

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

mutate(.by=grade), plus concis et ne nécessite pas de ungroup()

mutate(across(starts_with("N"), ~sum(., na.rm = T))) %>%
distinct(grade, .keep_all = T) %>%
Copy link
Member

Choose a reason for hiding this comment

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

On ne peut pas remplacer mutate+distinct par summarise ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

je crois que c'est parce que je n'arrivais pas à keep toutes les variables dans la base avec summarize(.by=) quand il y avait plusieurs bras

ungroup()

#recalculating pct
ngroups <- (ncol(data) - 1) / 2
for(i in 1:ngroups){
npatients <- sum(data[, paste0("N", i)])
data[data$grade == 0, paste0("pct", i)] <- round(data[data$grade == 0, paste0("N", i)] * 100 / npatients, round)
}
Copy link
Member

Choose a reason for hiding this comment

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

Je vais avoir besoin de lancer le code pour trouver comment appliquer purrr


data <- data %>% arrange(grade)

return(data)

}
20 changes: 20 additions & 0 deletions R/validation fonctions AE_table_grade/separate_n_pct.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#fonction separating each column N(pct) into 2 columns N and pct
separate_n_pct <- function(data){

#separation of 1 character column into 2 character columns
data <- colnames(data) %>%
imap(
~data %>% select(all_of(.x)) %>%
separate(.x, into = c(paste0("N", .y), paste0("pct", .y)), sep = "\\(")
) %>%
bind_cols()
Copy link
Member

Choose a reason for hiding this comment

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

https://tidyr.tidyverse.org/reference/separate_wider_delim.html
On doit pouvoir s'en sortir sans boucle avec separate_wider_regex(), pas évident mais l'exemple aide beaucoup.


#extraction of figures into numeric columns
data <- data %>%
mutate(
across(everything(), ~as.numeric(str_extract(.x, "\\d+\\.?\\d*")))
)

return(data)

}
31 changes: 31 additions & 0 deletions R/validation fonctions AE_table_grade/validate_ae_table_grade.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#fonction comparing R and SAS outputs
validate_ae_table_grade <- function(R_output,
SAS_output,
round = 0 #rounding of recalculated percentages in group_grades_zeroNA()
){

#formatting grade from character to numeric
R_output <- R_output %>%
mutate(grade = ifelse(variable == "No declared AE", 0, as.numeric(str_extract(variable, "\\d"))))
SAS_output <- SAS_output %>%
mutate(grade = as.numeric(str_extract(max_aegr1, "\\d")))

#separating each column N(pct) into 2 columns N and pct
R_separated <- R_output %>% select(grade) %>%
bind_cols(
separate_n_pct(R_output %>% select(-c(.id, label, variable, grade)))
)
SAS_separated <- SAS_output %>% select(grade) %>%
bind_cols(
separate_n_pct(SAS_output %>% select(-c(max_aegr1, grade)))
)

#missing figure with macro SAS <=> 0 with R package
SAS_separated <- SAS_separated %>%
replace(is.na(.), 0)

#grouping figures of missing grades and grades 0 for R function
R_separated <- group_grades_zeroNA(R_separated, round = round)

return(list(R = R_separated, SAS = SAS_separated))
}
Loading