Commit f78cdc1a authored by dmattek's avatar dmattek

Added UI for optional display of shaded region (SE or CI) around the mean.

parent 1d05a082
...@@ -13,10 +13,16 @@ modTrajRibbonPlotUI = function(id, label = "Plot Individual Time Series") { ...@@ -13,10 +13,16 @@ modTrajRibbonPlotUI = function(id, label = "Plot Individual Time Series") {
fluidRow( fluidRow(
column( column(
2, 2,
radioButtons(ns('rBlegendPos'), 'Legend:', list('top' = 'top', 'right' = 'right')),
checkboxInput(ns('chBplotTrajInt'), 'Interactive Plot'), checkboxInput(ns('chBplotTrajInt'), 'Interactive Plot'),
radioButtons(ns('rBlegendPos'), 'Legend placement:', list('top' = 'top', 'right' = 'right')),
actionButton(ns('butPlotTraj'), 'Plot!') actionButton(ns('butPlotTraj'), 'Plot!')
), ),
column(
2,
radioButtons(ns('rBPlotTrajStat'), 'Display:', list('Mean only' = 'Mean',
'Add 95% CI' = 'CI',
'Add SE' = 'SE'))
),
column( column(
3, 3,
sliderInput(ns('sliPlotTrajSkip'), 'Plot every n-th point:', min = 1, max = 10, value = 1, step = 1), sliderInput(ns('sliPlotTrajSkip'), 'Plot every n-th point:', min = 1, max = 10, value = 1, step = 1),
...@@ -171,11 +177,11 @@ modTrajRibbonPlot = function(input, output, session, ...@@ -171,11 +177,11 @@ modTrajRibbonPlot = function(input, output, session,
output$uiPlotTraj = renderUI({ output$uiPlotTraj = renderUI({
if (input$chBplotTrajInt) if (input$chBplotTrajInt)
plotlyOutput( plotlyOutput(
ns("outPlotTrajInt"), ns("outPlotTrajInt"),
width = paste0(input$inPlotTrajWidth, '%'), width = paste0(input$inPlotTrajWidth, '%'),
height = paste0(input$inPlotTrajHeight, 'px') height = paste0(input$inPlotTrajHeight, 'px')
) else ) else
plotOutput( plotOutput(
ns("outPlotTraj"), ns("outPlotTraj"),
width = paste0(input$inPlotTrajWidth, '%'), width = paste0(input$inPlotTrajWidth, '%'),
...@@ -309,12 +315,38 @@ modTrajRibbonPlot = function(input, output, session, ...@@ -309,12 +315,38 @@ modTrajRibbonPlot = function(input, output, session,
loc.facet.col = loc.facet.col[loc.groups] loc.facet.col = loc.facet.col[loc.groups]
} }
loc.dt.aggr = LOCcalcTrajCI(in.dt = loc.dt,
in.col.meas = 'y', # aggregate data; calculate Mean, CI or SE
in.col.by = c(in.facet, 'realtime'), loc.ribbon.lohi = NULL
in.type = 'normal')
if(input$rBPlotTrajStat == "Mean") {
# calculate the mean
loc.dt.aggr = loc.dt[, .(Mean = mean(get(COLY))), by = c(in.facet, COLRT)]
} else if(input$rBPlotTrajStat == "CI") {
# calculate the mean and the confidence intervals
loc.dt.aggr = LOCcalcTrajCI(in.dt = loc.dt,
in.col.meas = COLY,
in.col.by = c(in.facet, COLRT),
in.type = 'normal')
loc.ribbon.lohi = c('Lower', 'Upper')
} else if(input$rBPlotTrajStat == "SE") {
# calculate the mean and the standard error of the mean
loc.dt.aggr = loc.dt[, .(Mean = mean(get(COLY)),
Lower = mean(get(COLY)) - LOCstderr(get(COLY)),
Upper = mean(get(COLY)) + LOCstderr(get(COLY))), by = c(in.facet, COLRT)]
loc.ribbon.lohi = c('Lower', 'Upper')
}
# set the grouing column to a factor (for plotting)
loc.dt.aggr[, (in.facet) := as.factor(get(in.facet))] loc.dt.aggr[, (in.facet) := as.factor(get(in.facet))]
# setting bounds for displaying of x and y axes
loc.xlim.arg = NULL loc.xlim.arg = NULL
if(input$chBsetXbounds) { if(input$chBsetXbounds) {
loc.xlim.arg = c(input$inSetXboundsLow, input$inSetXboundsHigh) loc.xlim.arg = c(input$inSetXboundsLow, input$inSetXboundsHigh)
...@@ -326,13 +358,14 @@ modTrajRibbonPlot = function(input, output, session, ...@@ -326,13 +358,14 @@ modTrajRibbonPlot = function(input, output, session,
} }
p.out = LOCplotTrajRibbon(dt.arg = loc.dt.aggr, p.out = LOCplotTrajRibbon(dt.arg = loc.dt.aggr,
x.arg = 'realtime', x.arg = COLRT,
y.arg = 'Mean', y.arg = 'Mean',
col.arg = loc.facet.col, col.arg = loc.facet.col,
group.arg = in.facet, group.arg = in.facet,
dt.stim.arg = loc.dt.stim, dt.stim.arg = loc.dt.stim,
x.stim.arg = c('tstart', 'tend'), x.stim.arg = c('tstart', 'tend'),
y.stim.arg = c('ystart', 'yend'), y.stim.arg = c('ystart', 'yend'),
ribbon.lohi.arg = loc.ribbon.lohi,
xlim.arg = loc.xlim.arg, xlim.arg = loc.xlim.arg,
ylim.arg = loc.ylim.arg, ylim.arg = loc.ylim.arg,
xlab.arg = 'Time', xlab.arg = 'Time',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment