Generarea automată a diapozitivelor cu autoslider.core

URMĂREȘTE-NE
16,065FaniÎmi place
1,142CititoriConectați-vă

(Acest articol a fost publicat pentru prima dată pe Blog farmaceutși a contribuit cu drag la R-Bloggers). (Puteți raporta problema despre conținutul de pe această pagină aici)


Doriți să vă împărtășiți conținutul pe R-Bloggers? Faceți clic aici dacă aveți un blog sau aici dacă nu.


Procesul normal de creare a diapozitivelor de studiu clinic este acela că un statisticist tipărește manual numere de ieșiri și un statistician separat, apoi verifică dublu numerele de tipărit. Acest proces consumă mult timp, intensiv în resurse și predispus la erori. Acest pachet permite utilizatorilor să creeze diapozitive cu ieșiri specifice studiului într-un mod automat și reproductibil-fără a fi nevoie să copieze-paste. Reduce cantitatea de muncă și timpul necesar la crearea de diapozitive și reduce riscul erorilor de la tastarea manuală sau copierea numerelor de la ieșire la diapozitive. De asemenea, îi ajută pe utilizatori să evite stresul inutil atunci când creează cantități mari de punți de diapozitive într -un fereastră de timp scurt. Este deosebit de util pentru diapozitive care trebuie create continuu cu date actualizate, cum ar fi diapozitive necesare pentru ședințele de escaladare a dozei.

  1. Funcții pentru a crea ieșiri standard cu (unele) capacitatea de personalizare încorporată
  • Construit mai ales pe cod din catalogul TLG
  • Puteți crea și propriile funcții
  1. utilaje back-end pentru a gestiona fluxul de lucru. Aceasta include:
  • Crearea de ieșiri dintr -un fișier de specificații
  • Filtrarea datelor în conformitate cu un fișier de specificații
  • Decorare ieșiri (gândiți -vă: note de subsol și titluri)
  • Adăugarea acestor ieșiri la o punte de diapozitive PowerPoint, inclusiv paginarea.

Cerințe

library(autoslider.core)
Registered S3 method overwritten by 'tern':
  method   from 
  tidy.glm broom
library(dplyr)
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

Flux de lucru

Pentru a începe, structura folderului pentru proiectul dvs. ar putea arăta așa ceva:

Copy code
├── programs
│   ├── run_script.R
│   ├── R
│   │   ├── helping_functions.R
│   │   ├── output_functions.R
├── outputs
├── specs.yml
├── filters.yml

Specificații (specs.yml)

Acest fișier conține specificațiile tuturor rezultatelor pe care doriți să le creați. Fiecare ieșire include detalii precum numele programului, notele de subsol și titlurile, orientarea pe hârtie și dimensiunea fontului, sufixul și argumente suplimentare.

Următorul exemplu specs.yml Conținutul ar crea două ieșiri bazate pe două funcții de șablon, t_ds_slide () și t_dm_slide ():

- program: t_ds_slide
  titles: Patient Disposition ({filter_titles("adsl")})
  footnotes: 't_ds footnotes'
  paper: L6
  suffix: ITT
- program: t_dm_slide
  titles: Patient Demographics and Baseline Characteristics
  footnotes: 't_dm_slide footnote'
  paper: L6
  suffix: ITT
  args:
    arm: "TRT01A"
    vars: ("SEX", "AGE", "RACE", "ETHNIC", "COUNTRY")

Filtre (filtre.yml)

În fișierul Filters.yml, sunt specificate numele filtrelor utilizate la ieșiri. Fiecare filtru include un nume, titlu, condiție de filtrare, set de date țintă și tip.

Următorul exemplu filters.yml Fișierul specifică patru filtre utilizate frecvent:

ITT:
  title: Intent to Treat Population
  condition: ITTFL =='Y'
  target: adsl
  type: slref
SAS:
  title: Secondary Analysis Set
  condition: SASFL == 'Y'
  target: adsl
  type: slref
SE:
  title: Safety Evaluable Population
  condition: SAFFL=='Y'
  target: adsl
  type: slref
SER:
  title: Serious Adverse Events
  condition: AESER == 'Y'
  target: adae
  type: anl

Funcții

Mașini de backend

Un flux de lucru tipic implică definirea căilor către fișierele YAML, încărcarea filtrelor, citirea datelor, crearea de ieșiri pe baza specificațiilor și decorarea rezultatelor cu titluri și note de subsol. Exemplu de cod pentru configurarea fluxului de lucru:

# define path to the yml files
spec_file <- "spec.yml"
filters <- "filters.yml"
library("dplyr")
# load all filters
filters::load_filters(filters, overwrite = TRUE)
# read data
data <- list(
  "adsl" = eg_adsl %>%
    mutate(
      FASFL = SAFFL, # add FASFL for illustrative purpose for t_pop_slide
      # DISTRTFL is needed for t_ds_slide but is missing in example data
      DISTRTFL = sample(c("Y", "N"), size = length(TRT01A), replace = TRUE, prob = c(.1, .9))
    ) %>%
    preprocess_t_ds(), # this preproccessing is required by one of the autoslider.core functions
  "adae" = eg_adae,
  "adtte" = eg_adtte,
  "adrs" = eg_adrs,
  "adlb" = eg_adlb
)

# create outputs based on the specs and the functions
outputs <- spec_file %>%
  read_spec() %>%
  filter_spec(., program %in% c("t_ds_slide", "t_dm_slide")) %>%
  generate_outputs(datasets = data) %>%
  decorate_outputs(version_label = NULL)
✔ 2/3 outputs matched the filter condition `program %in% c("t_ds_slide", "t_dm_slide")`.
❯ Running program `t_ds_slide` with suffix 'ITT'.
Filter 'ITT' matched target ADSL.
400/400 records matched the filter condition `ITTFL == 'Y'`.
❯ Running program `t_dm_slide` with suffix 'ITT'.
Filter 'ITT' matched target ADSL.
400/400 records matched the filter condition `ITTFL == 'Y'`.

Exemplu de salvare a ieșirilor la un diapozitiv:

# Output to slides with template and color theme
outputs %>%
  generate_slides(
    outfile = tempfile(fileext = ".pptx"),
    template = file.path(system.file(package = "autoslider.core"), "/theme/basic.pptx"),
    table_format = autoslider_format
  )
(1) " Patient Disposition (Intent to Treat Population)"
(1) " Patient Disposition (Intent to Treat Population) (cont.)"
(1) " Patient Demographics and Baseline Characteristics, Intent to Treat Population"
(1) " Patient Demographics and Baseline Characteristics, Intent to Treat Population (cont.)"
(1) " Patient Demographics and Baseline Characteristics, Intent to Treat Population (cont.)"
(1) " Patient Demographics and Baseline Characteristics, Intent to Treat Population (cont.)"

Scrierea funcțiilor personalizate

Exemplu funcție personalizată:

lbt06 <- function(datasets) {
  adsl <- datasets$adsl %>% tern::df_explicit_na()
  adlb <- datasets$adlb %>% tern::df_explicit_na()

  adlb_f <- adlb %>%
    dplyr::filter(ABLFL != "Y") %>%
    dplyr::filter(!(AVISIT %in% c("SCREENING", "BASELINE"))) %>%
    dplyr::mutate(AVISIT = droplevels(AVISIT)) %>%
    formatters::var_relabel(AVISIT = "Visit")

  adlb_f_crp <- adlb_f %>% dplyr::filter(PARAMCD == "CRP")

  split_fun <- rtables::drop_split_levels

  lyt <- rtables::basic_table(show_colcounts = TRUE) %>%
    rtables::split_cols_by("ARM") %>%
    rtables::split_rows_by("AVISIT", split_fun = split_fun, label_pos = "topleft", split_label = formatters::obj_label(adlb_f_crp$AVISIT)) %>%
    tern::count_abnormal_by_baseline("ANRIND", abnormal = c(Low = "LOW", High = "HIGH"), .indent_mods = 4L) %>%
    tern::append_varlabels(adlb_f_crp, "ANRIND", indent = 1L) %>%
    rtables::append_topleft("    Baseline Status")

  result <- rtables::build_table(lyt = lyt, df = adlb_f_crp, alt_counts_df = adsl) %>%
    rtables::trim_rows()

  result
}

Testarea funcției personalizate:

lbt06(data)
Visit                                                                                  
  Analysis Reference Range Indicator     A: Drug X        B: Placebo     C: Combination
    Baseline Status                       (N=134)          (N=134)          (N=132)    
———————————————————————————————————————————————————————————————————————————————————————
WEEK 1 DAY 8                                                                           
  Low                                                                                  
            Not low                    16/119 (13.4%)   22/113 (19.5%)   24/112 (21.4%)
            Low                         2/15 (13.3%)     2/21 (9.5%)       7/20 (35%)  
            Total                      18/134 (13.4%)   24/134 (17.9%)   31/132 (23.5%)
  High                                                                                 
            Not high                   21/114 (18.4%)   20/112 (17.9%)   17/115 (14.8%)
            High                         2/20 (10%)      4/22 (18.2%)     3/17 (17.6%) 
            Total                      23/134 (17.2%)   24/134 (17.9%)   20/132 (15.2%)
WEEK 2 DAY 15                                                                          
  Low                                                                                  
            Not low                    26/119 (21.8%)   20/113 (17.7%)   12/112 (10.7%)
            Low                         2/15 (13.3%)     3/21 (14.3%)      4/20 (20%)  
            Total                      28/134 (20.9%)   23/134 (17.2%)   16/132 (12.1%)
  High                                                                                 
            Not high                   15/114 (13.2%)   17/112 (15.2%)    15/115 (13%) 
            High                         2/20 (10%)      4/22 (18.2%)     4/17 (23.5%) 
            Total                      17/134 (12.7%)   21/134 (15.7%)   19/132 (14.4%)
WEEK 3 DAY 22                                                                          
  Low                                                                                  
            Not low                    15/119 (12.6%)   21/113 (18.6%)   18/112 (16.1%)
            Low                             0/15         3/21 (14.3%)         0/20     
            Total                      15/134 (11.2%)   24/134 (17.9%)   18/132 (13.6%)
  High                                                                                 
            Not high                   22/114 (19.3%)   18/112 (16.1%)   17/115 (14.8%)
            High                         2/20 (10%)      5/22 (22.7%)     1/17 (5.9%)  
            Total                      24/134 (17.9%)   23/134 (17.2%)   18/132 (13.6%)
WEEK 4 DAY 29                                                                          
  Low                                                                                  
            Not low                    30/119 (25.2%)   13/113 (11.5%)   16/112 (14.3%)
            Low                          3/15 (20%)      2/21 (9.5%)       5/20 (25%)  
            Total                      33/134 (24.6%)   15/134 (11.2%)   21/132 (15.9%)
  High                                                                                 
            Not high                   17/114 (14.9%)   11/112 (9.8%)    16/115 (13.9%)
            High                         2/20 (10%)      6/22 (27.3%)     3/17 (17.6%) 
            Total                      19/134 (14.2%)   17/134 (12.7%)   19/132 (14.4%)
WEEK 5 DAY 36                                                                          
  Low                                                                                  
            Not low                    17/119 (14.3%)   19/113 (16.8%)   16/112 (14.3%)
            Low                         2/15 (13.3%)     3/21 (14.3%)      5/20 (25%)  
            Total                      19/134 (14.2%)   22/134 (16.4%)   21/132 (15.9%)
  High                                                                                 
            Not high                   19/114 (16.7%)   17/112 (15.2%)   11/115 (9.6%) 
            High                         4/20 (20%)      6/22 (27.3%)     2/17 (11.8%) 
            Total                      23/134 (17.2%)   23/134 (17.2%)   13/132 (9.8%) 
source("programs/output_functions.R")

Cu corect specs.yml şi filters.ymlintegrați funcția personalizată în fluxul de lucru general:

filters <- "filters.yml"
spec_file <- "specs.yml"
filters::load_filters(filters, overwrite = TRUE)
outputs <- spec_file %>%
  read_spec() %>%
  generate_outputs(data) %>%
  decorate_outputs()

outputs$lbt06_ITT_LBCRP_LBNOBAS
outputs <- spec_file %>%
  read_spec() %>%
  generate_outputs(data) %>%
  decorate_outputs()
❯ Running program `t_ds_slide` with suffix 'ITT'.
Filter 'ITT' matched target ADSL.
400/400 records matched the filter condition `ITTFL == 'Y'`.
❯ Running program `t_dm_slide` with suffix 'ITT'.
Filter 'ITT' matched target ADSL.
400/400 records matched the filter condition `ITTFL == 'Y'`.
❯ Running program `lbt06` with suffix 'ITT_LBCRP_LBNOBAS'.
Filter 'ITT' matched target ADSL.
400/400 records matched the filter condition `ITTFL == 'Y'`.
Filters 'LBCRP', 'LBNOBAS' matched target ADLB.
2000/8400 records matched the filter condition `PARAMCD == 'CRP' & (ABLFL != 'Y' & !(AVISIT %in% c('SCREENING', 'BASELINE')))`.
outputs$lbt06_ITT_LBCRP_LBNOBAS
An object of class "dVTableTree"
Slot "tbl":
 Patient Disposition (Intent to Treat Population)

———————————————————————————————————————————————————————————————————————————————————————
Visit                                                                                  
  Analysis Reference Range Indicator     A: Drug X        B: Placebo     C: Combination
    Baseline Status                       (N=134)          (N=134)          (N=132)    
———————————————————————————————————————————————————————————————————————————————————————
WEEK 1 DAY 8                                                                           
  Low                                                                                  
            Not low                    16/119 (13.4%)   22/113 (19.5%)   24/112 (21.4%)
            Low                         2/15 (13.3%)     2/21 (9.5%)       7/20 (35%)  
            Total                      18/134 (13.4%)   24/134 (17.9%)   31/132 (23.5%)
  High                                                                                 
            Not high                   21/114 (18.4%)   20/112 (17.9%)   17/115 (14.8%)
            High                         2/20 (10%)      4/22 (18.2%)     3/17 (17.6%) 
            Total                      23/134 (17.2%)   24/134 (17.9%)   20/132 (15.2%)
WEEK 2 DAY 15                                                                          
  Low                                                                                  
            Not low                    26/119 (21.8%)   20/113 (17.7%)   12/112 (10.7%)
            Low                         2/15 (13.3%)     3/21 (14.3%)      4/20 (20%)  
            Total                      28/134 (20.9%)   23/134 (17.2%)   16/132 (12.1%)
  High                                                                                 
            Not high                   15/114 (13.2%)   17/112 (15.2%)    15/115 (13%) 
            High                         2/20 (10%)      4/22 (18.2%)     4/17 (23.5%) 
            Total                      17/134 (12.7%)   21/134 (15.7%)   19/132 (14.4%)
WEEK 3 DAY 22                                                                          
  Low                                                                                  
            Not low                    15/119 (12.6%)   21/113 (18.6%)   18/112 (16.1%)
            Low                             0/15         3/21 (14.3%)         0/20     
            Total                      15/134 (11.2%)   24/134 (17.9%)   18/132 (13.6%)
  High                                                                                 
            Not high                   22/114 (19.3%)   18/112 (16.1%)   17/115 (14.8%)
            High                         2/20 (10%)      5/22 (22.7%)     1/17 (5.9%)  
            Total                      24/134 (17.9%)   23/134 (17.2%)   18/132 (13.6%)
WEEK 4 DAY 29                                                                          
  Low                                                                                  
            Not low                    30/119 (25.2%)   13/113 (11.5%)   16/112 (14.3%)
            Low                          3/15 (20%)      2/21 (9.5%)       5/20 (25%)  
            Total                      33/134 (24.6%)   15/134 (11.2%)   21/132 (15.9%)
  High                                                                                 
            Not high                   17/114 (14.9%)   11/112 (9.8%)    16/115 (13.9%)
            High                         2/20 (10%)      6/22 (27.3%)     3/17 (17.6%) 
            Total                      19/134 (14.2%)   17/134 (12.7%)   19/132 (14.4%)
WEEK 5 DAY 36                                                                          
  Low                                                                                  
            Not low                    17/119 (14.3%)   19/113 (16.8%)   16/112 (14.3%)
            Low                         2/15 (13.3%)     3/21 (14.3%)      5/20 (25%)  
            Total                      19/134 (14.2%)   22/134 (16.4%)   21/132 (15.9%)
  High                                                                                 
            Not high                   19/114 (16.7%)   17/112 (15.2%)   11/115 (9.6%) 
            High                         4/20 (20%)      6/22 (27.3%)     2/17 (11.8%) 
            Total                      23/134 (17.2%)   23/134 (17.2%)   13/132 (9.8%) 
———————————————————————————————————————————————————————————————————————————————————————

t_ds footnotes
Confidential and for internal use only
GitHub repository: NA
Git hash: d90795d2a97abda810205d7fd0f0fc335200e9fc

Slot "titles":
 Patient Disposition (Intent to Treat Population)

Slot "footnotes":
(1) "t_ds footnotes"                        
(2) "Confidential and for internal use only"

Slot "paper":
(1) "L6"

Slot "width":
(1) 36 14 14 14

Generați diapozitivele:

filepath <- tempfile(fileext = ".pptx")
generate_slides(outputs, outfile = filepath)
(1) " Patient Disposition (Intent to Treat Population)"
(1) " Patient Disposition (Intent to Treat Population) (cont.)"
(1) " Patient Demographics and Baseline Characteristics, Intent to Treat Population"
(1) " Patient Demographics and Baseline Characteristics, Intent to Treat Population (cont.)"
(1) " Patient Demographics and Baseline Characteristics, Intent to Treat Population (cont.)"
(1) " Patient Demographics and Baseline Characteristics, Intent to Treat Population (cont.)"
(1) " Patient Disposition (Intent to Treat Population)"
(1) " Patient Disposition (Intent to Treat Population) (cont.)"
(1) " Patient Disposition (Intent to Treat Population) (cont.)"
(1) " Patient Disposition (Intent to Treat Population) (cont.)"
(1) " Patient Disposition (Intent to Treat Population) (cont.)"
(1) " Patient Disposition (Intent to Treat Population) (cont.)"
(1) " Patient Disposition (Intent to Treat Population) (cont.)"
(1) " Patient Disposition (Intent to Treat Population) (cont.)"
(1) " Patient Disposition (Intent to Treat Population) (cont.)"
(1) " Patient Disposition (Intent to Treat Population) (cont.)"


Ultima actualizare

2025-03-17 09: 30: 58.01543

Detalii

Reutilizați

Citare

Citarea Bibtex:

@online{p._thoma,_joe_zhu2025,
  author = {P. Thoma, Joe Zhu, Stefan},
  title = {Automatic Slide Generation with Autoslider.core},
  date = {2025-03-14},
  url = {https://pharmaverse.github.io/blog/posts/2025-03-14_automatic_s.../automatic_slide_generation_with_{autoslide_r}.html},
  langid = {en}
}

Pentru atribuire, vă rugăm să citați această lucrare ca:

P. Thoma, Joe Zhu, Stefan. 2025. „Generarea automată a diapozitivelor cu autoslider.core.” 14 martie 2025.

Dominic Botezariu
Dominic Botezariuhttps://www.noobz.ro/
Creator de site și redactor-șef.

Cele mai noi știri

Pe același subiect

LĂSAȚI UN MESAJ

Vă rugăm să introduceți comentariul dvs.!
Introduceți aici numele dvs.