Skip to content

Commit

Permalink
#136 move control of fold change labs in patient profile out of mappi…
Browse files Browse the repository at this point in the history
…ngs tab and into selectize within module
  • Loading branch information
pburnsdata committed Jun 6, 2024
1 parent 942d1df commit a08ca88
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 43 deletions.
24 changes: 19 additions & 5 deletions R/nepexplorerMod.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ nepexplorer_ui <- function(id) {
sidebar <- sidebarPanel(
selectizeInput(
ns("measures"),
"Select Measures",
"Select Patient Profile Fold Change Measures",
multiple = TRUE,
choices = c("")
),
Expand Down Expand Up @@ -42,6 +42,14 @@ nepexplorer_ui <- function(id) {


main <- mainPanel(
# HTML header with style specifications.
tags$head(
tags$style(
# hide measure values from mappings tab that we want controlled within "measure" dropdown
HTML("div.field-wrap:has(label[id^='sg-mapping-labs-measure_col-measure_values--nepFC_']) { display: none; }"
)
)
),
useShinyjs(),
# Scatter PLot + Summary Table UI
creatinineScatterUI(ns("scatter")),
Expand Down Expand Up @@ -98,15 +106,21 @@ nepexplorer_server <- function(input, output, session, params) {
})

# Populate sidebar control with measures and select all by default
observe({
observeEvent(param(), {
measure_col <- param()$settings$labs$measure_col
measures <- unique(param()$data[[measure_col]])
measure_values <- param()$settings$labs$measure_values

# go through metadata file and grab measure values with prefix "nepFC"
fold_change_measures <- intersect(measures,
measure_values[grep("nepFC", names(measure_values))])

# update selectize to reflect what's specific in metadata
updateSelectizeInput(session,
"measures",
choices = measures,
selected = measures
selected = fold_change_measures
)

})

animate <- reactive(input$animate)
Expand Down Expand Up @@ -134,7 +148,7 @@ nepexplorer_server <- function(input, output, session, params) {
#Patient Profile (demo tables + lab line charts)
observeEvent(selected_subject(), {
if (length(selected_subject()) == 1) { # avoid triggering patient profiles if there isn't a subject
patientProfileServer("patprofile", df = param()$data,
patientProfileServer("patprofile", df = param()$data, selected_measures = input$measures,
settings = param()$settings, subj_id = selected_subject())
}
}, ignoreInit = TRUE)
Expand Down
1 change: 0 additions & 1 deletion R/patient_profile_charts.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ drawULNFoldChange <- function(adlb, settings,
"Calcium", "Chloride", "Phosphorus",
"Potassium", "Sodium")) {


adlb_FC <- adlb %>%
filter(.data[[settings$measure_col]] %in% labs) %>%
group_by(.data[[settings$measure_col]]) %>%
Expand Down
12 changes: 2 additions & 10 deletions R/patient_profile_mod.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ patientProfileUI <- function(id) {
#' @import dplyr
#' @importFrom plotly renderPlotly
#' @importFrom magrittr %>%
patientProfileServer <- function(id, df, settings, subj_id) {
patientProfileServer <- function(id, df, selected_measures, settings, subj_id) {
moduleServer(
id,
function(input, output, session) {
Expand Down Expand Up @@ -95,15 +95,7 @@ patientProfileServer <- function(id, df, settings, subj_id) {

output$ULN_FC <- renderUI({

default_labs <- c(lab_settings$measure_values$BICARB,
lab_settings$measure_values$BUN,
lab_settings$measure_values$CA,
lab_settings$measure_values$CL,
lab_settings$measure_values$PHOS,
lab_settings$measure_values$K,
lab_settings$measure_values$SODIUM)

available_labs <- intersect(patient_df[[lab_settings$measure_col]] %>% unique(), default_labs)
available_labs <- intersect(patient_df[[lab_settings$measure_col]] %>% unique(), selected_measures)

if (length(available_labs) > 0) {
drawULNFoldChange(adlb = patient_df, settings = lab_settings,
Expand Down
54 changes: 27 additions & 27 deletions data-raw/meta_nepExplorer.csv
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
text_key,domain,col_key,field_key,type,label,description,multiple,standard_adam,standard_sdtm
id_col,vitals,id_col,,column,ID column,Unique subject identifier variable name.,FALSE,USUBJID,USUBJID
value_col,vitals,value_col,,column,Value column,Vitals result variable name.,FALSE,AVAL,VSSTRESN
measure_col,vitals,measure_col,,column,Measure column,Vitals measure variable name,FALSE,PARAM,VSTEST
studyday_col,vitals,studyday_col,,column,Study Day column,Visit day variable name,FALSE,ADY,VSDY
visit_col,vitals,visit_col,,column,Visit column,Visit variable name,FALSE,AVISIT,VISIT
visitn_col,vitals,visitn_col,,column,Visit Number column,Visit number variable name,FALSE,AVISITN,VISITNUM
measure_values--SYSBP,vitals,measure_col,SYSBP,field,Systolic value,Value used for Systolic Blood Pressure in the specified measure column,FALSE,Systolic Blood Pressure (mmHg),Systolic Blood Pressure
measure_values--DIABP,vitals,measure_col,DIABP,field,Diastolic value,Value used for Diastolic Blood Pressure in the specified measure column,FALSE,Diastolic Blood Pressure (mmHg),Diastolic Blood Pressure
unit_col,vitals,unit_col,,column,Unit column,Unit of measure variable name,FALSE,,VSSTRESU
vs_baseline_flag,vitals,vs_baseline_flag,,column,Vital Signs Baseline Flag,Column for assigning VS baseline visits,FALSE,ABLFL,
vs_baseline_values--Y,vitals,vs_baseline_flag,Y,field,Vital Signs Baseline Flag value,Value used for VS Baseline in the specified baseline column,FALSE,Y,
measure_values--ALB,labs,measure_col,ALB,field,Albumin value,Value used for Albumin in the specified measure column,FALSE,Albumin (g/L),Albumin
measure_values--Albumin/Creatinine,labs,measure_col,ALB/CREAT,field,Albumin/Creatinine Ratio value,Value used for Albumin/Creatinine ratio in the specified measure column,FALSE,Albumin/Creatinine,
measure_values--BICARB,labs,measure_col,BICARB,field,Bicarbonate value,Value used for Bicarbonate in the specified measure column,FALSE,Bicarbonate (umol/L),Bicarbonate
measure_values--BUN,labs,measure_col,BUN,field,Blood Urea Nitrogen value,Value used for Blood Urea Nitrogen in the specified measure column,FALSE,Blood Urea Nitrogen (mmol/L),Blood Urea Nitrogen
measure_values--CA,labs,measure_col,CA,field,Calcium value,Value used for Calcium in the specified measure column,FALSE,Calcium (mmol/L),Calcium
measure_values--CL,labs,measure_col,CL,field,Chloride value,Value used for Chloride in the specified measure column,FALSE,Chloride (mmol/L),Chloride
measure_values--CREAT,labs,measure_col,CREAT,field,Creatinine value,Value used for Creatinine in the specified measure column,FALSE,Creatinine (mg/dL),Creatinine
measure_values--CYSTC,labs,measure_col,CYSTC,field,Cystatin C value,Value used for Cystatin C in the specified measure column,FALSE,Cystatin C (umol/L),Cystatin C
measure_values--eGFR,labs,measure_col,eGFR,field,eGFR value,Value used for the Estimated Glomerular Filtration Rate in the specified measure column,FALSE,eGFR (mL/min),eGFR
measure_values--eGFRcys,labs,measure_col,eGFRcys,field,eGFRcys value,Value used for the Cystatic C-based Estimated Glomerular Filtration Rate in the specified measure column,FALSE,eGFRcys (mL/min),eGFRcys
measure_values--PHOS,labs,measure_col,PHOS,field,Phosphate value,Value used for Phosphate in the specified measure column,FALSE,Phosphate (mmol/L),Phosphate
measure_values--K,labs,measure_col,K,field,Potassium value,Value used for Potassium in the specified measure column,FALSE,Potassium (mmol/L),Potassium
measure_values--SODIUM,labs,measure_col,SODIUM,field,Sodium value,Value used for Sodium in the specified measure column,FALSE,Sodium (mmol/L),Sodium
baseline_flag,labs,baseline_flag,,column,Baseline Flag column,Column for assigning baseline visits,FALSE,ABLFL,LBBLFL
baseline_values--Y,labs,baseline_flag,Y,field,Baseline Flag value,Value used for Baseline in the specified baseline column,FALSE,Y,Y
text_key,domain,col_key,field_key,type,label,description,multiple,standard_adam,standard_sdtm
id_col,vitals,id_col,,column,ID column,Unique subject identifier variable name.,FALSE,USUBJID,USUBJID
value_col,vitals,value_col,,column,Value column,Vitals result variable name.,FALSE,AVAL,VSSTRESN
measure_col,vitals,measure_col,,column,Measure column,Vitals measure variable name,FALSE,PARAM,VSTEST
studyday_col,vitals,studyday_col,,column,Study Day column,Visit day variable name,FALSE,ADY,VSDY
visit_col,vitals,visit_col,,column,Visit column,Visit variable name,FALSE,AVISIT,VISIT
visitn_col,vitals,visitn_col,,column,Visit Number column,Visit number variable name,FALSE,AVISITN,VISITNUM
measure_values--SYSBP,vitals,measure_col,SYSBP,field,Systolic value,Value used for Systolic Blood Pressure in the specified measure column,FALSE,Systolic Blood Pressure (mmHg),Systolic Blood Pressure
measure_values--DIABP,vitals,measure_col,DIABP,field,Diastolic value,Value used for Diastolic Blood Pressure in the specified measure column,FALSE,Diastolic Blood Pressure (mmHg),Diastolic Blood Pressure
unit_col,vitals,unit_col,,column,Unit column,Unit of measure variable name,FALSE,,VSSTRESU
vs_baseline_flag,vitals,vs_baseline_flag,,column,Vital Signs Baseline Flag,Column for assigning VS baseline visits,FALSE,ABLFL,
vs_baseline_values--Y,vitals,vs_baseline_flag,Y,field,Vital Signs Baseline Flag value,Value used for VS Baseline in the specified baseline column,FALSE,Y,
measure_values--ALB,labs,measure_col,ALB,field,Albumin value,Value used for Albumin in the specified measure column,FALSE,Albumin (g/L),Albumin
measure_values--Albumin/Creatinine,labs,measure_col,ALB/CREAT,field,Albumin/Creatinine Ratio value,Value used for Albumin/Creatinine ratio in the specified measure column,FALSE,Albumin/Creatinine,
measure_values--nepFC_BICARB,labs,measure_col,BICARB,field,Bicarbonate value,Value used for Bicarbonate in the specified measure column,FALSE,Bicarbonate (umol/L),Bicarbonate
measure_values--nepFC_BUN,labs,measure_col,BUN,field,Blood Urea Nitrogen value,Value used for Blood Urea Nitrogen in the specified measure column,FALSE,Blood Urea Nitrogen (mmol/L),Blood Urea Nitrogen
measure_values--nepFC_CA,labs,measure_col,CA,field,Calcium value,Value used for Calcium in the specified measure column,FALSE,Calcium (mmol/L),Calcium
measure_values--nepFC_CL,labs,measure_col,CL,field,Chloride value,Value used for Chloride in the specified measure column,FALSE,Chloride (mmol/L),Chloride
measure_values--CREAT,labs,measure_col,CREAT,field,Creatinine value,Value used for Creatinine in the specified measure column,FALSE,Creatinine (mg/dL),Creatinine
measure_values--CYSTC,labs,measure_col,CYSTC,field,Cystatin C value,Value used for Cystatin C in the specified measure column,FALSE,Cystatin C (umol/L),Cystatin C
measure_values--eGFR,labs,measure_col,eGFR,field,eGFR value,Value used for the Estimated Glomerular Filtration Rate in the specified measure column,FALSE,eGFR (mL/min),eGFR
measure_values--eGFRcys,labs,measure_col,eGFRcys,field,eGFRcys value,Value used for the Cystatic C-based Estimated Glomerular Filtration Rate in the specified measure column,FALSE,eGFRcys (mL/min),eGFRcys
measure_values--nepFC_PHOS,labs,measure_col,PHOS,field,Phosphate value,Value used for Phosphate in the specified measure column,FALSE,Phosphate (mmol/L),Phosphate
measure_values--nepFC_K,labs,measure_col,K,field,Potassium value,Value used for Potassium in the specified measure column,FALSE,Potassium (mmol/L),Potassium
measure_values--nepFC_SODIUM,labs,measure_col,SODIUM,field,Sodium value,Value used for Sodium in the specified measure column,FALSE,Sodium (mmol/L),Sodium
baseline_flag,labs,baseline_flag,,column,Baseline Flag column,Column for assigning baseline visits,FALSE,ABLFL,LBBLFL
baseline_values--Y,labs,baseline_flag,Y,field,Baseline Flag value,Value used for Baseline in the specified baseline column,FALSE,Y,Y
Binary file modified data/meta_nepExplorer.rda
Binary file not shown.

0 comments on commit a08ca88

Please sign in to comment.