SafetyGraphics / safetyGraphics

Clinical Trial Safety Graphics with R
https://safetygraphics.github.io/safetyGraphics/
Other
93 stars 24 forks source link

aetimelines custom mapping not plotting? #696

Closed MayaGans closed 2 years ago

MayaGans commented 2 years ago

Hi! Looking at safetyCharts for aeTimelines in data_raw it looks like I can leverage severity_col and serious_col in my mapping in order to plot the colors and highlighting but running the code below it looks like these two yaml specs are just ignored [I can see AETimelines but it's all blue, and no highlighting]

Do I need to call the init_AETimelines function before running safetyGraphicsApp? My mental model was that because the chart requires the init in it's yaml startup I wouldn't need to do that?

Any help appreciated!

library(safetyData)
sdtm <- list(
  dm=safetyData::sdtm_dm,
  aes=safetyData::sdtm_ae,
  labs=safetyData::sdtm_lb
)

safetyGraphics::safetyGraphicsApp(
  mapping = list(aes = list(
    id_col = 'USUBJID',
    seq_col = 'AESEQ',
    stdy_col = 'AESTDY',
    endy_col = 'AEENDY',
    term_col = 'AEDECOD',
    bodsys_col = 'AEBODSYS',
    severity_col = 'AESEV', # ???
    serious_col = 'AESER' # ???
  )),
  domainData=sdtm
)
MayaGans commented 2 years ago

OKAY FIXED IT!

Looks like supplying the columns in the mapping is only step 1 and you also need to add it to your meta (in the default below it looks like severity and serious are not included and without having them in the meta they have nothing to map to? Yay!

library(safetyData)
library(purrr)

sdtm <- list(
   dm=safetyData::sdtm_dm,
   aes=safetyData::sdtm_ae,
   labs=safetyData::sdtm_lb
)

custom_meta <- read.csv("https://raw.githubusercontent.com/SafetyGraphics/safetyCharts/dev/data-raw/meta_aes.csv") %>%
   dplyr::filter(text_key == "serious_col" | text_key == "severity_col") %>%
   dplyr::bind_rows(safetyGraphics::meta)

safetyGraphics::safetyGraphicsApp(
   mapping = list(aes = list(
      id_col = 'USUBJID',
      seq_col = 'AESEQ',
      stdy_col = 'AESTDY',
      endy_col = 'AEENDY',
      term_col = 'AEDECOD',
      bodsys_col = 'AEBODSYS',
      severity_col = 'AESEV', # ???
      serious_col = 'AESER' # ???
   )),
   meta = custom_meta,
   domainData=sdtm
)