Commit 31348d72 authored by dmattek's avatar dmattek

Fixed: NA treatment. Now NA's are allowed in clustering. NA removal and...

Fixed: NA treatment. Now NA's are allowed in clustering. NA removal and interpolaton happen when the checkbox is checked in UI.
parent ec391e2a
......@@ -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!'
)
......
......@@ -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',
......
......@@ -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)
})
......
......@@ -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',
......
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