Skip to content

Commit

Permalink
Merge pull request #29 from SafetyGraphics/IZ_dev
Browse files Browse the repository at this point in the history
Iz dev
  • Loading branch information
jwildfire authored Aug 13, 2020
2 parents 29a9699 + 5ca0136 commit 83f863c
Show file tree
Hide file tree
Showing 12 changed files with 2,227 additions and 1,722 deletions.
876 changes: 283 additions & 593 deletions GetStatistics.R

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# volcano-plot

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

- Ke Xiao (Boehringer Ingelheim)
- Hong Wang (Boehringer Ingelheim)
- Dennis o'Brien (Boehringer Ingelheim)
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.
77 changes: 77 additions & 0 deletions data/Get Test Data.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@


```{r}
setwd("~/Desktop/volcano-plot")
library(scales); library(dplyr); library(tidyr); library(tibble); library(stringr); library(ggplot2); library(cowplot); library(ggpubr)
select <- dplyr::select; rename <- dplyr::rename; mutate <- dplyr::mutate;
summarize <- dplyr::summarize; arrange <- dplyr::arrange; slice <- dplyr::slice; filter <- dplyr::filter; recode<-dplyr::recode
style <- plotly::style
```


Make test dataset
```{r}
# https://github.com/SafetyGraphics/volcano-plot/issues/7
ae_vars = c("USUBJID", "AESEQ", "AESTDT", "AESTDY", "AEENDT", "AEENDY", "AETERM", "AEDECOD", "AEBODSYS", "AESER", "AEONGO", "AESEV", "AEREL", "AEOUT", "STUDYFL", "TRTEMFL")
dm_vars = c("SITE", "SITEID", "AGE", "SEX", "RACE", "ARM", "ARMCD", "SBJTSTAT", "RFSTDTC", "RFENDTC", "RFENDY", "SAFFL")
all_vars = c(ae_vars,dm_vars)
# https://github.com/phuse-org/phuse-scripts/tree/master/data/sdtm/TDF_SDTM_v1.0
library(haven)
library(readr)
adae <- haven::read_xpt("https://github.com/phuse-org/phuse-scripts/raw/master/data/adam/cdisc/adae.xpt") %>% select(USUBJID, TRTEMFL, SAFFL)
adsl <- haven::read_xpt("https://github.com/phuse-org/phuse-scripts/raw/master/data/adam/cdisc/adsl.xpt")
ae = read_xpt("data/ae.xpt") %>% select(-STUDYID, -DOMAIN )
dm = read_xpt("data/dm.xpt")%>% select(-STUDYID, -DOMAIN )
ds = read_xpt("data/ds.xpt")%>% select(-STUDYID, -DOMAIN ) %>% filter(EPOCH=="TREATMENT" & DSCAT=="DISPOSITION EVENT") %>% select(USUBJID,DSDECOD)
test_data = ae %>%
inner_join(dm,by="USUBJID") %>%
inner_join(adae, by="USUBJID") %>%
left_join(ds, by="USUBJID") %>%
rename(AESTDT = AESTDTC, AEENDT = AEENDTC) %>%
mutate(AEONGO = ifelse(AEENDT=="","Y","N"),
STUDYFL = TRTEMFL,
SITE = SITEID,
RFENDTC = as.Date(RFENDTC),
AEENDT = as.Date(ifelse(AEENDT=="",NA,AEENDT)),
RFENDY = as.Date(RFENDTC) - AEENDT,
RFENDY = ifelse(AEENDT<RFENDTC, RFENDY+1, RFENDY),
SBJTSTAT = case_when(DSDECOD=="COMPLETED"~"TREATMENT COMPLETED",
!is.na(DSDECOD) & DSDECOD!="COMPLETED"~"DISCONTINUED",
TRUE~"ONGOING"),
AEREL = recode(AEREL,"PROBABLE"="Y","REMOTE"="Y","POSSIBLE"="Y","NONE"="N"),
AEREL = ifelse(AEREL=="",NA,AEREL))
match_vars = all_vars[which(all_vars %in% colnames(test_data))]
match_vars
no_vars = all_vars[which(!all_vars %in% colnames(test_data))]
no_vars
test_data2 = test_data %>% select(match_vars) %>% group_by_all() %>% slice(1) %>% group_by() %>% as.data.frame() %>%
mutate(AESTDT = as.Date(AESTDT), AEENDT = as.Date(AEENDT), RFSTDTC = as.Date(RFSTDTC), RFENDTC = as.Date(RFENDTC))
write_csv(test_data2, path="data/test_data.csv")
```



Load test data
```{r}
setwd("~/Desktop/volcano-plot")
library(scales); library(dplyr); library(tidyr); library(tibble); library(stringr); library(ggplot2); library(cowplot); library(ggpubr)
select <- dplyr::select; rename <- dplyr::rename; mutate <- dplyr::mutate;
summarize <- dplyr::summarize; arrange <- dplyr::arrange; slice <- dplyr::slice; filter <- dplyr::filter; recode<-dplyr::recode
style <- plotly::style
```


```{r}
library(data.table)
test_data = fread("data/test_data.csv") %>% as.data.frame() %>%
mutate(AESTDT = as.Date(AESTDT), AEENDT = as.Date(AEENDT), RFSTDTC = as.Date(RFSTDTC), RFENDTC = as.Date(RFENDTC))
```
Binary file added data/ae.xpt
Binary file not shown.
Binary file added data/dm.xpt
Binary file not shown.
Binary file added data/ds.xpt
Binary file not shown.
1,156 changes: 1,156 additions & 0 deletions data/test_data.csv

Large diffs are not rendered by default.

104 changes: 53 additions & 51 deletions global.R
Original file line number Diff line number Diff line change
@@ -1,51 +1,53 @@
################################################################################
# global.R
# This R Script declares the required packages for loading the Shiny App, links
# other R Scripts with global objects and defines global variables and functions.
################################################################################

### Declaration of required packages for running the Shiny App smoothly --------
library(shiny) # version: 1.4.0
library(shinyjs) # version: 1.1
library(data.table) # version: 1.12.8
library(DT) # version: 0.12
library(ggplot2) # version: 3.2.1
library(plotly) # version: 4.9.1
library(scales) # version: 1.1.0
library(shinycssloaders) # version: 0.3
library(conflicted) # version: 1.0.4
library(dplyr) # version: 0.8.3
library(tidyr) # version: 1.0.2
library(survival) # version: 3.1-8
library(survminer) # version: 0.4.6
library(fmsb) # version: 0.7.0

conflict_prefer("first", "dplyr")
conflict_prefer("filter", "dplyr")
# conflict_prefer("layout", "plotly")
# conflict_prefer("hidden", "shinyjs")
# conflict_prefer("dataTableOutput", "DT")


### Source any R Scripts other than ui.R, server.R and global.R ----------------
source("volcano_plot.R")
source("GetStatistics.R")


### Definitions of global variables and functions ------------------------------
# Check that it doesn't match any non-number
numbers_only <- function(x) !grepl("\\D", x)

fmt_dcimals <- function(decimals = 0) {
function(x) format(x, nsmall = decimals, scientific = FALSE)
}

reverselog_trans <- function(base = exp(1)) {
trans <- function(x) -log(x, base)
inv <- function(x) base^(-x)
trans_new(paste0("reverselog-", format(base)), trans, inv,
log_breaks(base = base),
domain = c(1e-100, Inf))
}


################################################################################
# global.R
# This R Script declares the required packages for loading the Shiny App, links
# other R Scripts with global objects and defines global variables and functions.
################################################################################

### Declaration of required packages for running the Shiny App smoothly --------
library(shiny) # version: 1.4.0
library(shinyjs) # version: 1.1
library(data.table) # version: 1.12.8
library(DT) # version: 0.12
library(ggplot2) # version: 3.2.1
library(plotly) # version: 4.9.1
library(scales) # version: 1.1.0
library(shinycssloaders) # version: 0.3
library(conflicted) # version: 1.0.4
library(dplyr) # version: 0.8.3
library(tidyr) # version: 1.0.2
library(survival) # version: 3.1-8
library(survminer) # version: 0.4.6
library(fmsb) # version: 0.7.0
library(shinyWidgets)
library(cowplot)
# if function conflicts, default dplyr
conflict_prefer("first", "dplyr")
select <- dplyr::select; rename <- dplyr::rename; mutate <- dplyr::mutate; summarize <- dplyr::summarize; arrange <- dplyr::arrange; slice <- dplyr::slice; filter <- dplyr::filter; recode<-dplyr::recode
style <- plotly::style
# conflict_prefer("layout", "plotly")
# conflict_prefer("hidden", "shinyjs")
# conflict_prefer("dataTableOutput", "DT")


### Source any R Scripts other than ui.R, server.R and global.R ----------------
source("volcano_plot.R")
source("GetStatistics.R")


### Definitions of global variables and functions ------------------------------
# Check that it doesn't match any non-number
numbers_only <- function(x) !grepl("\\D", x)

# fmt_dcimals <- function(decimals = 0) {
# function(x) format(x, nsmall = decimals, scientific = FALSE)
# }

reverselog_trans <- function(base = exp(1)) {
trans <- function(x) -log(x, base)
inv <- function(x) base^(-x)
trans_new(paste0("reverselog-", format(base)), trans, inv,
log_breaks(base = base),
domain = c(1e-100, Inf))
}

Loading

0 comments on commit 83f863c

Please sign in to comment.