Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed an issue to convert this to the standard data flow used in packages in the next version. See #30.


```{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 )
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for making this reproducible.

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