Skip to content

Commit

Permalink
Merge pull request #20 from ASA-DIA-InteractiveSafetyGraphics/v0.2.1-dev
Browse files Browse the repository at this point in the history
V0.2.1 dev
  • Loading branch information
jwildfire authored Oct 24, 2018
2 parents a3a4716 + 32b0fae commit 4953342
Show file tree
Hide file tree
Showing 9 changed files with 3,633 additions and 2,663 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ vignettes/*.pdf
# Shiny token, see https://shiny.rstudio.com/articles/shinyapps.html
rsconnect/
.Rproj.user

.DS_Store
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ReDish
Title: Create an interactive graphic for the Evaluation of Drug-Induced Serious Hepatotoxicity (eDISH).
Version: 0.0.1
Version: 0.2.1
Authors@R: c(
person("Becca", "Krouse", email = "rebecca_krouse@rhoworld.com", role = c("cre","aut")),
person("Jeremy", "Wildfire", role = "aut"),
Expand Down
17 changes: 12 additions & 5 deletions R/eDISH.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#' @param id_col Unique subject identifier variable name. Default: \code{"USUBJID"}.
#' @param value_col Lab result variable name. Default: \code{"STRESN"}.
#' @param measure_col Lab measure variable name. Default: \code{"TEST"}.
#' @param unit_col Lab measure unit variable name. Default: \code{"STRESU"}.
#' @param normal_col_low Lower limit of normal variable name. Default: \code{"STNRLO"}.
#' @param normal_col_high Upper limit of normal variable name. Default: \code{"STNRHI"}.
#' @param visit_col Visit variable name. Default: \code{"VISIT"}.
#' @param visitn_col Visit number variable name. Default: \code{"VISITN"}.
#' @param studyday_col Visit day variable name. Default: \code{"DY"}.
#' @param baseline_visitn Value of baseline visit number. Used to calculate mDish. Default: \code{1}.
#' @param filters An optional data frame of filters ("value_col") and associated metadata ("label"). Default: \code{NULL}.
#' @param group_cols An optional data frame of filters ("value_col") and associated metadata ("label"). Default: \code{NULL}.
Expand All @@ -21,6 +21,7 @@
#' When multiple options are specified, a control allowing the user to interactively change the x variable is shown. Default: \code{c("ALT", "AST", "ALP")}.
#' @param y_options Specifies variable options for the y-axis using the key values from \code{measure_values} (e.g. "TB").
#' When multiple options are specified, a control allowing the user to interactively change the y variable is shown. Default: \code{c("TB", "ALP")}.
#' @param analysisFlag An optional list defining which column \code{value_col} and values \code{values} should be used to records for use in eDish and mDish analyses. Default: \code{NULL}.
#' @param visit_window Default visit window used to highlight eDish points where x and y measures occurred within the specified number of days.
#' Editable by user after render. Default: \code{30}.
#' @param r_ratio_filter Specifies whether the R Ratio filter should be shown. R ratio is defined as:
Expand All @@ -42,7 +43,9 @@
#' id_col = "USUBJID",
#' value_col = "AVAL",
#' measure_col = "PARAM",
#' visit_col = "VISIT",
#' visitn_col = "VISITNUM",
#' studyday_col = "ADY",
#' normal_col_low = "A1LO",
#' normal_col_high = "A1HI",
#' measure_values = list(ALT = "Alanine Aminotransferase (U/L)",
Expand All @@ -61,7 +64,9 @@
#' settingsl <- list(id_col = "USUBJID",
#' value_col = "AVAL",
#' measure_col = "PARAM",
#' visitn_col = "VISITNUM",
#' visit_col = "VISIT",
#' visitn_col = "VISITNUM",
#' studyday_col = "ADY",
#' normal_col_low = "A1LO",
#' normal_col_high = "A1HI",
#' group_cols = group_cols_vec,
Expand All @@ -81,20 +86,21 @@ eDISH <- function(data,
id_col = "USUBJID",
value_col = "STRESN",
measure_col = "TEST",
unit_col = "STRESU",
normal_col_low = "STNRLO",
normal_col_high = "STNRHI",
visit_col = "VISIT",
visitn_col = "VISITN",
studyday_col = "DY",
baseline_visitn = 1,
filters = NULL,
group_cols = NULL,
analysisFlag= NULL,
measure_values = list(ALT = "Aminotransferase, alanine (ALT)",
AST = "Aminotransferase, aspartate (AST)",
TB = "Total Bilirubin",
ALP = "Alkaline phosphatase (ALP)"),
x_options = c("ALT", "AST", "ALP"),
y_options = c("TB", "ALP"), # temporarily making this a vector of length 2 until JS side fixed
y_options = "TB",
visit_window = 30,
r_ratio_filter = TRUE,
r_ratio_cut = 0,
Expand All @@ -112,14 +118,15 @@ eDISH <- function(data,
id_col = id_col,
value_col = value_col,
measure_col = measure_col,
unit_col = unit_col,
normal_col_low = normal_col_low,
normal_col_high = normal_col_high,
visit_col = visit_col,
visitn_col = visitn_col,
studyday_col = studyday_col,
baseline_visitn = baseline_visitn,
filters = filters,
group_cols = group_cols,
analysisFlag = analysisFlag,
measure_values = measure_values,
x_options = x_options,
y_options = y_options,
Expand Down
74 changes: 8 additions & 66 deletions inst/htmlwidgets/eDISH.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
HTMLWidgets.widget({

name: 'eDISH',
name: "eDISH",

type: 'output',
type: "output",

factory: function(el, width, height) {

Expand All @@ -11,74 +11,16 @@ HTMLWidgets.widget({
return {

renderValue: function(rSettings) {


el.innerHTML = "<div class='edish'></div>";

let settings = rSettings.settings;
settings.max_width = 600;

// let settings = {
// max_width: 600,
// value_col: 'AVAL',
// measure_col: 'PARAM',
// visitn_col: 'VISITNUM',
//studyday_col: 'ADY',
//normal_col_low: 'A1LO',
// normal_col_high: 'A1HI',
// id_col: 'USUBJID',
// group_cols: ['TRTA','RACE','AGEGR1'],
// filters: [
// {
// value_col: 'TRTA',
// label: 'Treatment'
// },
// {
// value_col: 'SEX',
// label: 'Sex'
// },
// {
// value_col: 'RACE',
// label: 'Race'
// },
// {
// value_col: 'AGEGR1',
// label: 'Age group'
// },
// ],
// // measure_values:{
// 'ALT':'Alanine Aminotransferase (U/L)',
// 'AST':'Aspartate Aminotransferase (U/L)',
// 'TB':'Bilirubin (umol/L)',
// 'ALP':'Alkaline Phosphatase (U/L)'
// }
// value_col: rSettings.settings.value_col,
// measure_col: rSettings.settings.measure_col,
// visitn_col: rSettings.settings.visitn_col,
// normal_col_low: rSettings.settings.normal_col_low,
// normal_col_high: rSettings.settings.normal_col_high,
// id_col: rSettings.settings.id_col,
// baseline_visitn: rSettings.settings.baseline_visitn,
// filters: rSettings.settings.filters,
// group_cols: rSettings.settings.group_cols,
// measure_values: rSettings.settings.measure_values,
// x_options: rSettings.settings.x_options,
// y_options: rSettings.settings.y_options,
// measure_bounds: rSettings.settings.measure_bounds,
// visit_window: rSettings.settings.visit_window,
// r_ratio_filter: rSettings.settings.r_ratio_filter,
// r_ratio_cut: rSettings.settings.r_ratio_cut,
// showTitle: rSettings.settings.showTitle,
// warningText: rSettings.settings.warningText
// };

rSettings.data = HTMLWidgets.dataframeToD3(rSettings.data);
rSettings.data = HTMLWidgets.dataframeToD3(rSettings.data);

// console.log(settings);
// console.log(rSettings);

console.log(settings);
console.log(rSettings);

safetyedish('.edish', settings).init(rSettings.data);
safetyedish(".edish", settings).init(rSettings.data);

},

Expand All @@ -90,4 +32,4 @@ HTMLWidgets.widget({

};
}
});
});
12 changes: 6 additions & 6 deletions inst/htmlwidgets/eDISH.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ dependencies:
src: htmlwidgets/lib/d3-3.5.17
script: d3.v3.min.js
- name: webcharts
version: 1.10.0
src: htmlwidgets/lib/webcharts-1.10.0
version: 1.11.1
src: htmlwidgets/lib/webcharts-1.11.1
script: webcharts.js
stylesheet: webcharts.css
- name: safety-eDish
version: 0.12.1
src: htmlwidgets/lib/safety-eDISH-0.12.1
script: safetyedish.js
version: 0.14.0
src: htmlwidgets/lib/safety-eDISH-0.14.0
script: safetyedish.js

Loading

0 comments on commit 4953342

Please sign in to comment.