Commit 46cd43de authored by dmattek's avatar dmattek

Display track stats

parent c8a2e909
...@@ -2,6 +2,7 @@ source('modules/auxfunc.R') ...@@ -2,6 +2,7 @@ source('modules/auxfunc.R')
source('modules/downPlot.R') source('modules/downPlot.R')
source('modules/downCellIDsCls.R') source('modules/downCellIDsCls.R')
source('modules/dispStats.R') source('modules/dispStats.R')
source('modules/dispTrackStats.R')
source('modules/trajPlot.R') source('modules/trajPlot.R')
source('modules/boxPlot.R') source('modules/boxPlot.R')
source('modules/tabAUC.R') source('modules/tabAUC.R')
......
require(DT)
require(data.table)
modTrackStatsUI = function(id, label = "Comparing t-points") {
ns <- NS(id)
tagList(
checkboxInput(ns('chbTabStats'), 'Show stats', FALSE),
uiOutput(ns('uiTabStats'))
)
}
modTrackStats = function(input, output, session,
in.data) {
ns <- session$ns
output$uiTabStats = renderUI({
cat(file = stderr(), 'UI uiTabStats\n')
ns <- session$ns
if(input$chbTabStats) {
tagList(
htmlOutput(ns('txtNtracks')),
#br(),
#p("Track IDs with duplicated objects in a frame"),
br(),
DT::dataTableOutput(ns('outTabStats'))
)
}
})
# unused at the moment
calcStats = reactive({
cat(file = stderr(), 'tabBoxPlot: calsStats\n')
loc.dt = in.data()
if (is.null(loc.dt))
return(NULL)
loc.dt.aggr = loc.dt[, sapply(.SD, function(x) list('N' = .N,
'Mean' = mean(x),
'CV' = sd(x)/mean(x),
'Median' = median(x),
'rCV (IQR)' = IQR(x)/median(x),
'rCV (MAD)'= mad(x)/median(x))), .SDcols = in.meascol, by = in.bycols]
setnames(loc.dt.aggr, c(in.bycols, 'N', 'Mean', 'CV', 'Median', 'rCV IQR', 'rCV MAD'))
return(loc.dt.aggr)
})
# Print number of tracks
output$txtNtracks = renderText({
loc.dt = in.data()
if (is.null(loc.dt))
return(NULL)
sprintf('<b>Number of tracks: %d <br>Average track length: %.2f time units</b>',
length(unique(loc.dt[['id']])),
loc.dt[, .(trackLength = .N), by = 'id'][, mean(trackLength)])
})
# Print a table with Track IDs assigned to multiple objects in a frame
output$outTabStats = DT::renderDataTable(server = FALSE, {
cat(file = stderr(), 'tabBoxPlot: outTabStats\n')
loc.dt = in.data()
if (is.null(loc.dt))
return(NULL)
# Look whether there were more objects with the same track ID in the frame
# Such track IDs will have TRUE assigned in 'dup' column
# Keep only s.track column with dup=TRUE
loc.duptracks = loc.dt[, .(dup = (sum(duplicated(get('realtime'))) > 0)), by = 'id'][dup == TRUE, 'id', with = FALSE]
if (nrow(loc.duptracks))
datatable(loc.duptracks,
caption = 'Track IDs with duplicated objects in a frame',
rownames = TRUE,
extensions = 'Buttons',
options = list(
dom = 'Bfrtip',
buttons = list('copy',
'print',
list(extend = 'collection',
buttons = list(list(extend='csv',
filename = 'hitStats'),
list(extend='excel',
filename = 'hitStats'),
list(extend='pdf',
filename= 'hitStats')),
text = 'Download'))))
else
return(NULL)
})
}
\ No newline at end of file
require(DT)
tabBoxPlotUI = function(id, label = "Comparing t-points") { tabBoxPlotUI = function(id, label = "Comparing t-points") {
ns <- NS(id) ns <- NS(id)
......
require(DT)
modTrajPlotUI = function(id, label = "Plot Individual Time Series") { modTrajPlotUI = function(id, label = "Plot Individual Time Series") {
ns <- NS(id) ns <- NS(id)
...@@ -46,6 +48,9 @@ modTrajPlotUI = function(id, label = "Plot Individual Time Series") { ...@@ -46,6 +48,9 @@ modTrajPlotUI = function(id, label = "Plot Individual Time Series") {
) )
), ),
uiOutput(ns('uiPlotTraj')), uiOutput(ns('uiPlotTraj')),
br(),
modTrackStatsUI(ns('dispTrackStats')),
downPlotUI(ns('downPlotTraj'), "Download PDF") downPlotUI(ns('downPlotTraj'), "Download PDF")
) )
} }
...@@ -69,6 +74,11 @@ modTrajPlot = function(input, output, session, in.data, in.facet = 'group', in.f ...@@ -69,6 +74,11 @@ modTrajPlot = function(input, output, session, in.data, in.facet = 'group', in.f
) )
}) })
callModule(modTrackStats, 'dispTrackStats',
in.data = in.data)
output$outPlotTraj <- renderPlot({ output$outPlotTraj <- renderPlot({
loc.p = plotTraj() loc.p = plotTraj()
......
...@@ -115,11 +115,11 @@ shinyServer(function(input, output, session) { ...@@ -115,11 +115,11 @@ shinyServer(function(input, output, session) {
output$varSelTrackLabel = renderUI({ output$varSelTrackLabel = renderUI({
cat(file = stderr(), 'UI varSelTrackLabel\n') cat(file = stderr(), 'UI varSelTrackLabel\n')
locCols = getDataNucCols() locCols = getDataNucCols()
locColSel = locCols[locCols %like% 'rack'][1] # index 1 at the end in case more matches; select 1st locColSel = locCols[locCols %like% 'rack.*abel'][1] # index 1 at the end in case more matches; select 1st
selectInput( selectInput(
'inSelTrackLabel', 'inSelTrackLabel',
'Select Track Label (e.g. objNuc_Track_ObjectsLabel):', 'Select Track Label (e.g. objNuc_TrackObjects_Label):',
locCols, locCols,
width = '100%', width = '100%',
selected = locColSel selected = locColSel
...@@ -134,7 +134,7 @@ shinyServer(function(input, output, session) { ...@@ -134,7 +134,7 @@ shinyServer(function(input, output, session) {
cat(locColSel, '\n') cat(locColSel, '\n')
selectInput( selectInput(
'inSelTime', 'inSelTime',
'Select time column (e.g. RealTime):', 'Select time column (e.g. Metadata_T, RealTime):',
locCols, locCols,
width = '100%', width = '100%',
selected = locColSel selected = locColSel
...@@ -449,7 +449,6 @@ shinyServer(function(input, output, session) { ...@@ -449,7 +449,6 @@ shinyServer(function(input, output, session) {
loc.dt.rem = dataLoadTrajRem() loc.dt.rem = dataLoadTrajRem()
loc.dt = loc.dt[!(trackObjectsLabelUni %in% loc.dt.rem[[1]])] loc.dt = loc.dt[!(trackObjectsLabelUni %in% loc.dt.rem[[1]])]
} }
...@@ -550,9 +549,10 @@ shinyServer(function(input, output, session) { ...@@ -550,9 +549,10 @@ shinyServer(function(input, output, session) {
# This is different from TrackObject_Label and is handy to keep # This is different from TrackObject_Label and is handy to keep
# because labels on segmented images are typically ObjectNumber # because labels on segmented images are typically ObjectNumber
loc.s.objnum = names(loc.dt)[names(loc.dt) %like% c('ObjectNumber')] loc.s.objnum = names(loc.dt)[names(loc.dt) %like% c('ObjectNumber')]
if (length(loc.s.objnum) > 0) {
if (length(loc.s.objnum) == 1) loc.s.objnum = loc.s.objnum[1]
locObjNum = TRUE locObjNum = TRUE
}
else else
locObjNum = FALSE locObjNum = FALSE
......
...@@ -103,7 +103,7 @@ shinyUI(fluidPage( ...@@ -103,7 +103,7 @@ shinyUI(fluidPage(
tabPanel( tabPanel(
"AUI", "AUC",
modAUCplotUI('tabAUC') modAUCplotUI('tabAUC')
), ),
......
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