diff --git a/modules/auxfunc.R b/modules/auxfunc.R index ea2b59ed7aec81bcbf9f3993d6755cefc66a2bc3..6e8de042f2fb4c0cd0c87badac9628e02a9e06bf 100644 --- a/modules/auxfunc.R +++ b/modules/auxfunc.R @@ -95,7 +95,9 @@ help.text = c( Say, the main data file contains columns Metadata_Site and TrackLabel. These two columns should be then selected in UI to form a unique cell ID, e.g. 001_0001 where former part corresponds to Metadata_Site and the latter to TrackLabel.', 'Plotting and data processing requires a unique cell ID across entire dataset. A typical dataset from CellProfiler assigns unique cell ID (TrackLabel) within each field of view (Metadata_Site). - Therefore, a unique ID is created by concatenating these two columns. If the dataset already contains a unique ID, UNcheck this box and select a single column only.' + Therefore, a unique ID is created by concatenating these two columns. If the dataset already contains a unique ID, UNcheck this box and select a single column only.', + 'This option allows to interpolate NAs or missing data. Some rows in the input file might be missing because a particular time point might not had been acquired. + This option, interpolates such missing points as well as points with NAs in the measurement column. When this option is checked, the interval of time column must be provided!' ) diff --git a/modules/trajPlot.R b/modules/trajPlot.R index 055e315e75293466d22feecbb5dd359d1f95997e..5567fc6c6decf62ad6beb3eb86c0b2d0f15a4c61 100644 --- a/modules/trajPlot.R +++ b/modules/trajPlot.R @@ -88,7 +88,7 @@ modTrajPlot = function(input, output, session, locYmin = signif(min(loc.dt$y, na.rm = T), 4) locYmax = signif(max(loc.dt$y, na.rm = T), 4) - + sliderInput( ns('slYTrim'), label = 'Trim y-axis', diff --git a/server.R b/server.R index b477f9e8a5d79f7a9c1febf71283c81d9b9bac9d..3de0d0496e5e502023fa3d40d8b3ac3c4da60921 100644 --- a/server.R +++ b/server.R @@ -451,7 +451,6 @@ shinyServer(function(input, output, session) { cat(file = stderr(), 'dataMod: trajRem not NULL\n') loc.dt.rem = dataLoadTrajRem() - print(loc.dt.rem) loc.dt = loc.dt[!(trackObjectsLabelUni %in% loc.dt.rem[[1]])] } @@ -613,18 +612,18 @@ shinyServer(function(input, output, session) { } - ## Interpolate NA's and data points that are missing + ## Interpolate missing data and NA data points # From: https://stackoverflow.com/questions/28073752/r-how-to-add-rows-for-missing-values-for-unique-group-sequences # Tracks are interpolated only within first and last time points of every cell id # Datasets can have different realtime frequency (e.g. every 1', 2', etc), # or the frame number metadata can be missing, as is the case for tCourseSelected files that already have realtime column. - # Therefore, we cnanot rely on that info to get time frequency; user provides this number! + # Therefore, we cannot rely on that info to get time frequency; user provides this number! setkey(loc.out, group, id, realtime) if (input$chBtrajInter) { # here we fill missing data with NA's - loc.out = loc.out[setkey(loc.out[, .(seq(min(realtime), max(realtime), input$inSelTimeFreq)), by = .(group, id)], group, id, V1)] + loc.out = loc.out[setkey(loc.out[, .(seq(min(realtime, na.rm = T), max(realtime, na.rm = T), input$inSelTimeFreq)), by = .(group, id)], group, id, V1)] # x-check: print all rows with NA's print('Rows with NAs:') @@ -727,11 +726,13 @@ shinyServer(function(input, output, session) { loc.out = as.matrix(loc.out[, -1]) rownames(loc.out) = loc.rownames + # This might be removed entirely because all NA treatment happens in data4trajPlot + # Clustering should work with NAs present. These might result from data itself or from missing time point rows that were turned into NAs when dcast-ing from long format. # Remove NA's # na.interpolation from package imputeTS works with multidimensional data # but imputation is performed for each column independently # The matrix for clustering contains time series in rows, hence transposing it twice - loc.out = t(na.interpolation(t(loc.out))) + # loc.out = t(na.interpolation(t(loc.out))) return(loc.out) }) diff --git a/ui.R b/ui.R index 801274fb5d42fd4f2882244f7bfd931a7a92bf84..62019d62086b76e0a523107e418fd62ef5cbff8c 100644 --- a/ui.R +++ b/ui.R @@ -42,7 +42,15 @@ shinyUI(fluidPage( uiOutput('uiButLoadTrajRem'), tags$hr(), - checkboxInput('chBtrajInter', 'Interpolate NAs?', value = T), + checkboxInput('chBtrajInter', 'Interpolate NAs and missing data?', value = T), + helpPopup( + title = 'Interpolation of NAs and missing data', + content = help.text[3], + placement = 'right', + trigger = 'hover' + ), + + uiOutput('varSelTimeFreq'), checkboxInput('chBtrackUni', 'Create unique TrackLabel', T), helpPopup( title = 'Create unique cell ID', @@ -57,7 +65,6 @@ shinyUI(fluidPage( checkboxInput('chBgroup', 'Dataset contains grouping column (e.g. treatment, condition)', TRUE), uiOutput('varSelGroup'), uiOutput('varSelTime'), - uiOutput('varSelTimeFreq'), uiOutput('varSelMeas1'), radioButtons( 'inSelMath',