Skip to content

Commit 83f863c

Browse files
authored
Merge pull request #29 from SafetyGraphics/IZ_dev
Iz dev
2 parents 29a9699 + 5ca0136 commit 83f863c

File tree

12 files changed

+2227
-1722
lines changed

12 files changed

+2227
-1722
lines changed

GetStatistics.R

Lines changed: 283 additions & 593 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# volcano-plot
22

3-
Original Developers
3+
![image](https://user-images.githubusercontent.com/62663896/90043322-efd45b00-dc99-11ea-834c-5633c91ea41d.png)
44

5-
- Ke Xiao (Boehringer Ingelheim)
6-
- Hong Wang (Boehringer Ingelheim)
7-
- Dennis o'Brien (Boehringer Ingelheim)
5+
Thanks to the team at Boehringer Ingelheim for developing and releasing the initial code for this tool. In particular, thanks to, Hong Wang, Ke Xiao and Dennis O'Brien.

data/Get Test Data.Rmd

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
2+
3+
```{r}
4+
5+
setwd("~/Desktop/volcano-plot")
6+
library(scales); library(dplyr); library(tidyr); library(tibble); library(stringr); library(ggplot2); library(cowplot); library(ggpubr)
7+
select <- dplyr::select; rename <- dplyr::rename; mutate <- dplyr::mutate;
8+
summarize <- dplyr::summarize; arrange <- dplyr::arrange; slice <- dplyr::slice; filter <- dplyr::filter; recode<-dplyr::recode
9+
style <- plotly::style
10+
```
11+
12+
13+
Make test dataset
14+
```{r}
15+
# https://github.com/SafetyGraphics/volcano-plot/issues/7
16+
ae_vars = c("USUBJID", "AESEQ", "AESTDT", "AESTDY", "AEENDT", "AEENDY", "AETERM", "AEDECOD", "AEBODSYS", "AESER", "AEONGO", "AESEV", "AEREL", "AEOUT", "STUDYFL", "TRTEMFL")
17+
dm_vars = c("SITE", "SITEID", "AGE", "SEX", "RACE", "ARM", "ARMCD", "SBJTSTAT", "RFSTDTC", "RFENDTC", "RFENDY", "SAFFL")
18+
all_vars = c(ae_vars,dm_vars)
19+
20+
# https://github.com/phuse-org/phuse-scripts/tree/master/data/sdtm/TDF_SDTM_v1.0
21+
library(haven)
22+
library(readr)
23+
adae <- haven::read_xpt("https://github.com/phuse-org/phuse-scripts/raw/master/data/adam/cdisc/adae.xpt") %>% select(USUBJID, TRTEMFL, SAFFL)
24+
adsl <- haven::read_xpt("https://github.com/phuse-org/phuse-scripts/raw/master/data/adam/cdisc/adsl.xpt")
25+
ae = read_xpt("data/ae.xpt") %>% select(-STUDYID, -DOMAIN )
26+
dm = read_xpt("data/dm.xpt")%>% select(-STUDYID, -DOMAIN )
27+
ds = read_xpt("data/ds.xpt")%>% select(-STUDYID, -DOMAIN ) %>% filter(EPOCH=="TREATMENT" & DSCAT=="DISPOSITION EVENT") %>% select(USUBJID,DSDECOD)
28+
29+
test_data = ae %>%
30+
inner_join(dm,by="USUBJID") %>%
31+
inner_join(adae, by="USUBJID") %>%
32+
left_join(ds, by="USUBJID") %>%
33+
rename(AESTDT = AESTDTC, AEENDT = AEENDTC) %>%
34+
mutate(AEONGO = ifelse(AEENDT=="","Y","N"),
35+
STUDYFL = TRTEMFL,
36+
SITE = SITEID,
37+
RFENDTC = as.Date(RFENDTC),
38+
AEENDT = as.Date(ifelse(AEENDT=="",NA,AEENDT)),
39+
RFENDY = as.Date(RFENDTC) - AEENDT,
40+
RFENDY = ifelse(AEENDT<RFENDTC, RFENDY+1, RFENDY),
41+
SBJTSTAT = case_when(DSDECOD=="COMPLETED"~"TREATMENT COMPLETED",
42+
!is.na(DSDECOD) & DSDECOD!="COMPLETED"~"DISCONTINUED",
43+
TRUE~"ONGOING"),
44+
AEREL = recode(AEREL,"PROBABLE"="Y","REMOTE"="Y","POSSIBLE"="Y","NONE"="N"),
45+
AEREL = ifelse(AEREL=="",NA,AEREL))
46+
47+
match_vars = all_vars[which(all_vars %in% colnames(test_data))]
48+
match_vars
49+
no_vars = all_vars[which(!all_vars %in% colnames(test_data))]
50+
no_vars
51+
52+
test_data2 = test_data %>% select(match_vars) %>% group_by_all() %>% slice(1) %>% group_by() %>% as.data.frame() %>%
53+
mutate(AESTDT = as.Date(AESTDT), AEENDT = as.Date(AEENDT), RFSTDTC = as.Date(RFSTDTC), RFENDTC = as.Date(RFENDTC))
54+
write_csv(test_data2, path="data/test_data.csv")
55+
56+
57+
```
58+
59+
60+
61+
Load test data
62+
```{r}
63+
64+
setwd("~/Desktop/volcano-plot")
65+
library(scales); library(dplyr); library(tidyr); library(tibble); library(stringr); library(ggplot2); library(cowplot); library(ggpubr)
66+
select <- dplyr::select; rename <- dplyr::rename; mutate <- dplyr::mutate;
67+
summarize <- dplyr::summarize; arrange <- dplyr::arrange; slice <- dplyr::slice; filter <- dplyr::filter; recode<-dplyr::recode
68+
style <- plotly::style
69+
```
70+
71+
72+
```{r}
73+
library(data.table)
74+
75+
test_data = fread("data/test_data.csv") %>% as.data.frame() %>%
76+
mutate(AESTDT = as.Date(AESTDT), AEENDT = as.Date(AEENDT), RFSTDTC = as.Date(RFSTDTC), RFENDTC = as.Date(RFENDTC))
77+
```

data/ae.xpt

463 KB
Binary file not shown.

data/dm.xpt

77.4 KB
Binary file not shown.

data/ds.xpt

130 KB
Binary file not shown.

data/test_data.csv

Lines changed: 1156 additions & 0 deletions
Large diffs are not rendered by default.

global.R

Lines changed: 53 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,53 @@
1-
################################################################################
2-
# global.R
3-
# This R Script declares the required packages for loading the Shiny App, links
4-
# other R Scripts with global objects and defines global variables and functions.
5-
################################################################################
6-
7-
### Declaration of required packages for running the Shiny App smoothly --------
8-
library(shiny) # version: 1.4.0
9-
library(shinyjs) # version: 1.1
10-
library(data.table) # version: 1.12.8
11-
library(DT) # version: 0.12
12-
library(ggplot2) # version: 3.2.1
13-
library(plotly) # version: 4.9.1
14-
library(scales) # version: 1.1.0
15-
library(shinycssloaders) # version: 0.3
16-
library(conflicted) # version: 1.0.4
17-
library(dplyr) # version: 0.8.3
18-
library(tidyr) # version: 1.0.2
19-
library(survival) # version: 3.1-8
20-
library(survminer) # version: 0.4.6
21-
library(fmsb) # version: 0.7.0
22-
23-
conflict_prefer("first", "dplyr")
24-
conflict_prefer("filter", "dplyr")
25-
# conflict_prefer("layout", "plotly")
26-
# conflict_prefer("hidden", "shinyjs")
27-
# conflict_prefer("dataTableOutput", "DT")
28-
29-
30-
### Source any R Scripts other than ui.R, server.R and global.R ----------------
31-
source("volcano_plot.R")
32-
source("GetStatistics.R")
33-
34-
35-
### Definitions of global variables and functions ------------------------------
36-
# Check that it doesn't match any non-number
37-
numbers_only <- function(x) !grepl("\\D", x)
38-
39-
fmt_dcimals <- function(decimals = 0) {
40-
function(x) format(x, nsmall = decimals, scientific = FALSE)
41-
}
42-
43-
reverselog_trans <- function(base = exp(1)) {
44-
trans <- function(x) -log(x, base)
45-
inv <- function(x) base^(-x)
46-
trans_new(paste0("reverselog-", format(base)), trans, inv,
47-
log_breaks(base = base),
48-
domain = c(1e-100, Inf))
49-
}
50-
51-
1+
################################################################################
2+
# global.R
3+
# This R Script declares the required packages for loading the Shiny App, links
4+
# other R Scripts with global objects and defines global variables and functions.
5+
################################################################################
6+
7+
### Declaration of required packages for running the Shiny App smoothly --------
8+
library(shiny) # version: 1.4.0
9+
library(shinyjs) # version: 1.1
10+
library(data.table) # version: 1.12.8
11+
library(DT) # version: 0.12
12+
library(ggplot2) # version: 3.2.1
13+
library(plotly) # version: 4.9.1
14+
library(scales) # version: 1.1.0
15+
library(shinycssloaders) # version: 0.3
16+
library(conflicted) # version: 1.0.4
17+
library(dplyr) # version: 0.8.3
18+
library(tidyr) # version: 1.0.2
19+
library(survival) # version: 3.1-8
20+
library(survminer) # version: 0.4.6
21+
library(fmsb) # version: 0.7.0
22+
library(shinyWidgets)
23+
library(cowplot)
24+
# if function conflicts, default dplyr
25+
conflict_prefer("first", "dplyr")
26+
select <- dplyr::select; rename <- dplyr::rename; mutate <- dplyr::mutate; summarize <- dplyr::summarize; arrange <- dplyr::arrange; slice <- dplyr::slice; filter <- dplyr::filter; recode<-dplyr::recode
27+
style <- plotly::style
28+
# conflict_prefer("layout", "plotly")
29+
# conflict_prefer("hidden", "shinyjs")
30+
# conflict_prefer("dataTableOutput", "DT")
31+
32+
33+
### Source any R Scripts other than ui.R, server.R and global.R ----------------
34+
source("volcano_plot.R")
35+
source("GetStatistics.R")
36+
37+
38+
### Definitions of global variables and functions ------------------------------
39+
# Check that it doesn't match any non-number
40+
numbers_only <- function(x) !grepl("\\D", x)
41+
42+
# fmt_dcimals <- function(decimals = 0) {
43+
# function(x) format(x, nsmall = decimals, scientific = FALSE)
44+
# }
45+
46+
reverselog_trans <- function(base = exp(1)) {
47+
trans <- function(x) -log(x, base)
48+
inv <- function(x) base^(-x)
49+
trans_new(paste0("reverselog-", format(base)), trans, inv,
50+
log_breaks(base = base),
51+
domain = c(1e-100, Inf))
52+
}
53+

0 commit comments

Comments
 (0)