Laboratory Test A: Drug X B: Placebo C: Combination
Direction of Abnormality (N=134) (N=134) (N=132)
———————————————————————————————————————————————————————————————————————————————————
Alanine Aminotransferase Measurement (n) 125 120 125
Low
Single, not last 3 (2.4%) 5 (4.2%) 5 (4%)
Last or replicated 52 (41.6%) 59 (49.2%) 44 (35.2%)
Any Abnormality 55 (44%) 64 (53.3%) 49 (39.2%)
High
Any Abnormality 0 0 0
C-Reactive Protein Measurement (n) 129 130 121
Low
Single, not last 3 (2.3%) 7 (5.4%) 6 (5%)
Last or replicated 59 (45.7%) 50 (38.5%) 49 (40.5%)
Any Abnormality 62 (48.1%) 57 (43.8%) 55 (45.5%)
High
Single, not last 5 (3.9%) 4 (3.1%) 2 (1.7%)
Last or replicated 49 (38%) 54 (41.5%) 45 (37.2%)
Any Abnormality 54 (41.9%) 58 (44.6%) 47 (38.8%)
Immunoglobulin A Measurement (n) 129 122 121
Low
Any Abnormality 0 0 0
High
Single, not last 4 (3.1%) 6 (4.9%) 3 (2.5%)
Last or replicated 48 (37.2%) 47 (38.5%) 55 (45.5%)
Any Abnormality 52 (40.3%) 53 (43.4%) 58 (47.9%)
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
Laboratory Test A: Drug X B: Placebo C: Combination
Direction of Abnormality (N=134) (N=134) (N=132)
———————————————————————————————————————————————————————————————————————————————————
Alanine Aminotransferase Measurement (n) 125 120 125
Low
Single, not last 3 (2.4%) 5 (4.2%) 5 (4%)
Last or replicated 52 (41.6%) 59 (49.2%) 44 (35.2%)
Any Abnormality 55 (44%) 64 (53.3%) 49 (39.2%)
High
Single, not last 0 0 0
Last or replicated 0 0 0
Any Abnormality 0 0 0
C-Reactive Protein Measurement (n) 129 130 121
Low
Single, not last 3 (2.3%) 7 (5.4%) 6 (5%)
Last or replicated 59 (45.7%) 50 (38.5%) 49 (40.5%)
Any Abnormality 62 (48.1%) 57 (43.8%) 55 (45.5%)
High
Single, not last 5 (3.9%) 4 (3.1%) 2 (1.7%)
Last or replicated 49 (38%) 54 (41.5%) 45 (37.2%)
Any Abnormality 54 (41.9%) 58 (44.6%) 47 (38.8%)
Immunoglobulin A Measurement (n) 129 122 121
Low
Single, not last 0 0 0
Last or replicated 0 0 0
Any Abnormality 0 0 0
High
Single, not last 4 (3.1%) 6 (4.9%) 3 (2.5%)
Last or replicated 48 (37.2%) 47 (38.5%) 55 (45.5%)
Any Abnormality 52 (40.3%) 53 (43.4%) 58 (47.9%)
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
Code
# This variant reflects user modifications made to the laboratory analysis data set related to# Safety Lab Standardization metadata.# There is no unique layout level variation.
lyt <-basic_table(show_colcounts =TRUE) %>%split_cols_by("ACTARM") %>%split_rows_by("PARAM",label_pos ="topleft",split_label ="Laboratory Test",split_fun =trim_levels_in_group("abn_dir", drop_outlevs =TRUE) ) %>%summarize_num_patients(var ="USUBJID", .stats ="unique_count") %>%split_rows_by("abn_dir") %>%count_abnormal_by_marked(var ="AVALCAT1",variables =list(id ="USUBJID", param ="PARAM", direction ="abn_dir") ) %>%append_topleft(" Direction of Abnormality")result <-build_table(lyt, df = adlb_f, alt_counts_df = adsl)result <- result %>%prune_table()result
Laboratory Test A: Drug X B: Placebo C: Combination
Direction of Abnormality (N=134) (N=134) (N=132)
———————————————————————————————————————————————————————————————————————————————————
Alanine Aminotransferase Measurement (n) 125 120 125
Low
Single, not last 3 (2.4%) 5 (4.2%) 5 (4%)
Last or replicated 52 (41.6%) 59 (49.2%) 44 (35.2%)
Any Abnormality 55 (44%) 64 (53.3%) 49 (39.2%)
C-Reactive Protein Measurement (n) 129 130 121
Low
Single, not last 3 (2.3%) 7 (5.4%) 6 (5%)
Last or replicated 59 (45.7%) 50 (38.5%) 49 (40.5%)
Any Abnormality 62 (48.1%) 57 (43.8%) 55 (45.5%)
High
Single, not last 5 (3.9%) 4 (3.1%) 2 (1.7%)
Last or replicated 49 (38%) 54 (41.5%) 45 (37.2%)
Any Abnormality 54 (41.9%) 58 (44.6%) 47 (38.8%)
Immunoglobulin A Measurement (n) 129 122 121
High
Single, not last 4 (3.1%) 6 (4.9%) 3 (2.5%)
Last or replicated 48 (37.2%) 47 (38.5%) 55 (45.5%)
Any Abnormality 52 (40.3%) 53 (43.4%) 58 (47.9%)
Code
# Another approach would be to create an empirical map by removing the ALT records# and use it in `trim_levels_to_map`.# this is an a posteriori approach, though.
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
Code
library(dplyr)library(tern)adsl <- random.cdisc.data::cadsladlb <- random.cdisc.data::cadlb# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.adsl <-df_explicit_na(adsl)adlb <-df_explicit_na(adlb)qntls <- adlb %>%group_by(PARAMCD) %>%summarise(as_tibble(t(quantile(AVAL, probs =c(0.1, 0.9)))), .groups ="drop_last") %>%rename(q1 =2, q2 =3)adlb <- adlb %>%left_join(qntls, by ="PARAMCD")set.seed(1)# Modify ANRIND and create AVALCAT1/PARCAT2# PARCAT2 is just used for filtering, but in order to be the# filtering as realistic as possible, will create the variable.adlb <- adlb %>%mutate(ANRIND =factor(case_when( ANRIND =="LOW"& AVAL <= q1 ~"LOW LOW", ANRIND =="HIGH"& AVAL >= q2 ~"HIGH HIGH",TRUE~as.character(ANRIND) ),levels =c("", "HIGH", "HIGH HIGH", "LOW", "LOW LOW", "NORMAL") ),AVALCAT1 =factor(case_when( ANRIND %in%c("HIGH HIGH", "LOW LOW") ~sample(x =c("LAST", "REPLICATED", "SINGLE"), size =n(), replace =TRUE, prob =c(0.3, 0.6, 0.1)),TRUE~"" ),levels =c("", c("LAST", "REPLICATED", "SINGLE")) ),PARCAT2 =factor(ifelse(ANRIND %in%c("HIGH HIGH", "LOW LOW"), "LS",sample(c("SI", "CV", "LS"), size =n(), replace =TRUE) )) ) %>%select(-q1, -q2)# Pre-processing stepsadlb_f <- adlb %>%filter(ONTRTFL =="Y"& PARCAT2 =="LS"& SAFFL =="Y"&!is.na(AVAL)) %>%mutate(abn_dir =factor(case_when( ANRIND =="LOW LOW"~"Low", ANRIND =="HIGH HIGH"~"High",TRUE~"" ), levels =c("Low", "High", ""))) %>%df_explicit_na()# Construct analysis mapmap <-expand.grid(PARAM =levels(adlb$PARAM),abn_dir =c("Low", "High"),stringsAsFactors =FALSE) %>%arrange(PARAM, desc(abn_dir))