-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path05_CustomDomain.R
83 lines (69 loc) · 3.3 KB
/
05_CustomDomain.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Example 5.1 - Make a vital signs domain based on the existing labs domain ... with no charts?!
vitalsMeta <- safetyGraphics::meta %>%
filter(domain == 'labs') %>%
mutate(domain='vitals')
newMeta <- rbind(safetyGraphics::meta, vitalsMeta)
sdtm <- list(
dm=safetyData::sdtm_dm,
aes=safetyData::sdtm_ae,
labs=safetyData::sdtm_lb,
vitals= safetyData::sdtm_vs
)
safetyGraphics::safetyGraphicsApp(domainData=sdtm, meta=newMeta)
# Example 5.2 - Add brand new Hello World data domain ... with an awesome custom chart!!
helloMeta <- tribble(
~text_key, ~domain, ~label, ~standard_hello, ~description,
"x_col", "hello", "x position", "x", "x position for points in hello world chart",
"y_col", "hello", "y position", "y", "y position for points in hello world chart"
) %>% mutate(
col_key = text_key,
type="column"
)
detectStandard(domain='hello', data = iris, meta=helloMeta)
helloData<-data.frame(x=runif(50, -1,1), y=runif(50, -1,1))
helloWorld <- function(data, settings){
plot(-1:1, -1:1)
text(data[[settings$x_col]], data[[settings$y_col]], "Custom Hello Domain!")
}
helloChart<-prepareChart(
list(
env="safetyGraphics",
name="HelloWorld",
label="Hello World!",
type="plot",
domain="hello",
workflow=list(
main="helloWorld"
)
)
)
safetyGraphicsApp(
meta=helloMeta,
domainData=list(hello=helloData),
charts=list(helloChart)
)
# Example 5.3 - Define an ECG data ... and adapt an existing chart for usage there.
# See this PR for a full implementation of the ECG domain in safetyCharts - https://github.com/SafetyGraphics/safetyCharts/pull/90
adeg <- readr::read_csv("https://physionet.org/files/ecgcipa/1.0.0/adeg.csv?download")
ecg_meta <-tibble::tribble(
~text_key, ~domain, ~label, ~description, ~standard_adam, ~standard_sdtm,
"id_col", "ecg", "ID column", "Unique subject identifier variable name.", "USUBJID", "USUBJID",
"value_col", "ecg", "Value column", "QT result variable name.", "AVAL", "EGSTRESN",
"measure_col", "ecg", "Measure column", "QT measure variable name", "PARAM", "EGTEST",
"studyday_col", "ecg", "Study Day column", "Visit day variable name", "ADY", "EGDY",
"visit_col", "ecg", "Visit column", "Visit variable name", "ATPT", "EGTPT",
"visitn_col", "ecg", "Visit number column", "Visit number variable name", "ATPTN", NA,
"period_col", "ecg", "Period column", "Period variable name", "APERIOD", NA,
"unit_col", "ecg", "Unit column", "Unit of measure variable name", "AVALU", "EGSTRESU"
) %>% mutate(
col_key = text_key,
type="column"
)
qtOutliers<-read_yaml('https://raw.githubusercontent.com/SafetyGraphics/safetyCharts/dev/inst/config/safetyOutlierExplorer.yaml')
qtOutliers$label <- "QT Outlier explorer"
qtOutliers$domain <- "ecg"
safetyGraphicsApp(
meta=ecg_meta,
domainData=list(ecg=adeg),
charts=list(prepareChart(qtOutliers))
)