-
Notifications
You must be signed in to change notification settings - Fork 2
Iz dev #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iz dev #29
Changes from all commits
621b1dc
79455f5
73e4259
119e8ea
75ac90f
acdfd4d
229bec3
672637b
02cabce
fd7b55e
f12cd0f
7a88b95
53faacd
8b312d7
5ca0136
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,5 @@ | ||
| # volcano-plot | ||
|
|
||
| Original Developers | ||
|  | ||
|
|
||
| - 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. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)) | ||
| ``` | ||
Large diffs are not rendered by default.
| 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)) | ||
| } | ||
|
|
Uh oh!
There was an error while loading. Please reload this page.