Commit 4ce763a6 authored by dmattek's avatar dmattek
Browse files

Mod:

- tab with stats optional
- added N to tab stats
parent ca81f193
...@@ -4,21 +4,25 @@ tabBoxPlotUI = function(id, label = "Comparing t-points") { ...@@ -4,21 +4,25 @@ tabBoxPlotUI = function(id, label = "Comparing t-points") {
ns <- NS(id) ns <- NS(id)
tagList( tagList(
h4(
"Box-/dot-/violin plot at selected time points"
),
br(),
uiOutput(ns('varSelTpts')), uiOutput(ns('varSelTpts')),
DT::dataTableOutput(ns('outTabStats')), checkboxInput(ns('chbTabStats'), 'Show stats', FALSE),
downloadButton(ns('downloadData4BoxPlot'), 'Download single-cell data'), uiOutput(ns('uiTabStats')),
uiOutput(ns('uiDownSingleCellData')),
br(),
fluidRow( fluidRow(
column( column(
6, 6,
radioButtons(ns('inPlotType'), 'Plot type:', list('Box-plot' = 'box', radioButtons(ns('inPlotType'), 'Plot type:', list('Box-plot' = 'box',
'Dot-plot' = 'dot', 'Dot-plot' = 'dot',
'Violin-plot' = 'viol', 'Violin-plot' = 'viol',
'Line-plot' = 'line')), 'Line-plot' = 'line'))
uiOutput(ns('uiPlotBoxNotches')),
uiOutput(ns('uiPlotBoxOutliers')),
uiOutput(ns('uiPlotDotNbins'))
), ),
column( column(
6, 6,
...@@ -31,7 +35,10 @@ tabBoxPlotUI = function(id, label = "Comparing t-points") { ...@@ -31,7 +35,10 @@ tabBoxPlotUI = function(id, label = "Comparing t-points") {
"Bottom" = 'bottom' "Bottom" = 'bottom'
), ),
selected = 'top' selected = 'top'
) ),
uiOutput(ns('uiPlotBoxNotches')),
uiOutput(ns('uiPlotBoxOutliers')),
uiOutput(ns('uiPlotDotNbins'))
) )
), ),
...@@ -88,6 +95,24 @@ tabBoxPlot = function(input, output, session, in.data) { ...@@ -88,6 +95,24 @@ tabBoxPlot = function(input, output, session, in.data) {
) )
} }
}) })
output$uiTabStats = renderUI({
cat(file = stderr(), 'UI uiTabStats\n')
ns <- session$ns
if(input$chbTabStats) {
DT::dataTableOutput(ns('outTabStats'))
}
})
output$uiDownSingleCellData = renderUI({
cat(file = stderr(), 'UI uiDownSingleCellData\n')
ns <- session$ns
if(input$chbTabStats) {
downloadButton(ns('downloadData4BoxPlot'), 'Download single-cell data')
}
})
output$uiPlotBoxNotches = renderUI({ output$uiPlotBoxNotches = renderUI({
cat(file = stderr(), 'UI uiPlotBoxNotches\n') cat(file = stderr(), 'UI uiPlotBoxNotches\n')
...@@ -124,9 +149,15 @@ tabBoxPlot = function(input, output, session, in.data) { ...@@ -124,9 +149,15 @@ tabBoxPlot = function(input, output, session, in.data) {
if (is.null(loc.dt)) if (is.null(loc.dt))
return(NULL) return(NULL)
loc.dt.aggr = loc.dt[, sapply(.SD, function(x) list('Mean' = mean(x), 'CV' = sd(x)/mean(x), 'Median' = median(x), 'rCV (IQR)' = IQR(x)/median(x), 'rCV (MAD)'= mad(x)/median(x))), .SDcols = c('y'), by = .(realtime, group)] loc.dt.aggr = loc.dt[, sapply(.SD, function(x) list('N' = .N,
setnames(loc.dt.aggr, c('Time point', 'Group', 'Mean', 'CV', 'Median', 'rCV IQR', 'rCV MAD')) 'Mean' = mean(x),
print(loc.dt.aggr) 'CV' = sd(x)/mean(x),
'Median' = median(x),
'rCV (IQR)' = IQR(x)/median(x),
'rCV (MAD)'= mad(x)/median(x))), .SDcols = c('y'), by = .(realtime, group)]
setnames(loc.dt.aggr, c('Time point', 'Group','N', 'Mean', 'CV', 'Median', 'rCV IQR', 'rCV MAD'))
#print(loc.dt.aggr)
return(loc.dt.aggr) return(loc.dt.aggr)
}) })
...@@ -176,7 +207,7 @@ tabBoxPlot = function(input, output, session, in.data) { ...@@ -176,7 +207,7 @@ tabBoxPlot = function(input, output, session, in.data) {
filename = 'hitStats'), filename = 'hitStats'),
list(extend='pdf', list(extend='pdf',
filename= 'hitStats')), filename= 'hitStats')),
text = 'Download')))) %>% formatRound(3:7, 3) text = 'Download')))) %>% formatRound(4:8, 3)
}) })
# Boxplot - display # Boxplot - display
......
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