diff --git a/example-data/test-case-1/README.md b/example-data/test-case-1/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..f6e40c6fdfe5ae58dcaf644b8483ccbd0aedd1fa
--- /dev/null
+++ b/example-data/test-case-1/README.md
@@ -0,0 +1,31 @@
+# Test case dataset
+
+This dataset contains around 234 time-series with 121 time points each. The set comes from a microfluidic time-lapse microscopy experiment. In this experiment, PC-12 cells were stimulated with 3 dosages of fibroblast growth factor 2 (FGF2): 2.5 ng/ml, 25 ng/ml, and 250 ng/ml. The stimulation was performed with 3' pulses of FGF2 at 20' intervals. The readout is the measurement of ERK activity using a FRET biosensor.
+
+The set comes from a publication Blum *et al.* (2019) *Temporal perturbation of Erk dynamics reveals network architecture of FGF2-MAPK signaling* (**preprint**), available in [bioRxiv](https://www.biorxiv.org/content/10.1101/629287v1"bioRxiv")].
+
+Files in this set:
+
+**`mp3-20_FGF_ekar.csv.gz`**
+
+Main dataset in the long format with following columns:
+
+- `intensity_ekar` - measurement of the biosensor
+- `realtime` - time points in minutes
+- `id` - identifiers of time-series
+- `group` - grouping according to treatment with 3 concentrations of FGF2
+- `fov` - additional grouping according to the field of view during experiment acquisition.
+
+Note, the `id` column contains identifiers that are unique only within a single field of view. Thus, in order to create data-wide unique identifiers, you need to combine the `fov` and `id` columns.
+
+The `csv.gz` file can be uploaded directly into Time Course Inspector (TCI).
+
+
+**`mp3-20_FGF_badTraj.csv`**
+
+A single-column csv file with identifiers of outlier trajectories. This file can be uploaded into TCI, and listed time series will be removed from further analysis. The IDs need to be in the same format as in the app. If a unique identifier was created within the app (e.g. by combining ''fov'' and ''id'' columns), then the IDs in this file need to be of the same form.
+
+
+**`mp3-20_FGF_pulsey_y0-97.csv`** and **`mp3-20_FGF_pulse_y1100`**
+
+Files with coordinates of segments to plot under time-series. Each row should contain x and y coordinates of the start and end of segments (4 columns: `tstart`, `tend`, `ystart`, `yend`), `group` column used for grouping of the main dataset in the app, a dummy `id` column.
\ No newline at end of file
diff --git a/example-data/test-case-1/mp3-20_FGF_badTraj.csv b/example-data/test-case-1/mp3-20_FGF_badTraj.csv
new file mode 100755
index 0000000000000000000000000000000000000000..c55e6a22853295b324ab6e1fb30fb6f354615a83
--- /dev/null
+++ b/example-data/test-case-1/mp3-20_FGF_badTraj.csv
@@ -0,0 +1,35 @@
+id
+12_6
+2_3
+15_2
+12_1
+2_37
+7_35
+14_19
+14_8
+12_5
+2_12
+0_40
+3_19
+2_20
+1_8
+0_27
+5_9
+4_23
+8_3
+8_1
+3_38
+0_4
+0_16
+11_15
+3_28
+12_21
+13_38
+12_7
+6_2
+10_25
+11_11
+7_13
+15_7
+14_14
+10_20
\ No newline at end of file
diff --git a/example-data/test-case-1/mp3-20_FGF_ekar.csv.gz b/example-data/test-case-1/mp3-20_FGF_ekar.csv.gz
new file mode 100644
index 0000000000000000000000000000000000000000..67f31c55480474218846e15ee32cb0d196c8bf4c
Binary files /dev/null and b/example-data/test-case-1/mp3-20_FGF_ekar.csv.gz differ
diff --git a/example-data/test-case-1/mp3-20_FGF_pulse_y1100.csv b/example-data/test-case-1/mp3-20_FGF_pulse_y1100.csv
new file mode 100644
index 0000000000000000000000000000000000000000..767d7e185f71de13bb33a1636c6d6498045eff89
--- /dev/null
+++ b/example-data/test-case-1/mp3-20_FGF_pulse_y1100.csv
@@ -0,0 +1,13 @@
+group.idx,tstart,tend,ystart,yend,group,id
+5,43,46,1100,1100,250,1
+5,66,69,1100,1100,250,1
+5,89,92,1100,1100,250,1
+5,112,115,1100,1100,250,1
+6,43,46,1100,1100,25,1
+6,66,69,1100,1100,25,1
+6,89,92,1100,1100,25,1
+6,112,115,1100,1100,25,1
+7,43,46,1100,1100,2.5,1
+7,66,69,1100,1100,2.5,1
+7,89,92,1100,1100,2.5,1
+7,112,115,1100,1100,2.5,1
\ No newline at end of file
diff --git a/example-data/test-case-1/mp3-20_FGF_pulsey_y0-97.csv b/example-data/test-case-1/mp3-20_FGF_pulsey_y0-97.csv
new file mode 100644
index 0000000000000000000000000000000000000000..86f941fcffef16224e4aee748951525e600928f3
--- /dev/null
+++ b/example-data/test-case-1/mp3-20_FGF_pulsey_y0-97.csv
@@ -0,0 +1,13 @@
+group.idx,tstart,tend,ystart,yend,group,id
+5,43,46,0.97,0.97,250,1
+5,66,69,0.97,0.97,250,1
+5,89,92,0.97,0.97,250,1
+5,112,115,0.97,0.97,250,1
+6,43,46,0.97,0.97,25,1
+6,66,69,0.97,0.97,25,1
+6,89,92,0.97,0.97,25,1
+6,112,115,0.97,0.97,25,1
+7,43,46,0.97,0.97,2.5,1
+7,66,69,0.97,0.97,2.5,1
+7,89,92,0.97,0.97,2.5,1
+7,112,115,0.97,0.97,2.5,1
\ No newline at end of file
diff --git a/modules/auxfunc.R b/modules/auxfunc.R
index 83713699cbbc9b13b1e173bff16963fa1531fdc3..b07ea2b2f0a0b7a75704b25a530a3b9bfa3b88e8 100644
--- a/modules/auxfunc.R
+++ b/modules/auxfunc.R
@@ -2,7 +2,7 @@
# Time Course Inspector: Shiny app for plotting time series data
# Author: Maciej Dobrzynski
#
-# These are auxilary functions
+# Auxilary functions & definitions of global constants
#
@@ -25,6 +25,7 @@ DEB = T
# PLOTFONTFACETSTRIP = 10
# PLOTFONTLEGEND = 8
+# font sizes in pts for screen display
PLOTFONTBASE = 16
PLOTFONTAXISTEXT = 16
PLOTFONTAXISTITLE = 16
@@ -155,28 +156,16 @@ helpPopup <- function(title, content,
)
}
-help.text = c(
- 'Accepts CSV file with a column of cell IDs for removal.
- IDs should correspond to those used for plotting.
- 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.',
- '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!',
- 'Accepts CSV file with 5 columns: grouping (e.g. condition), start and end time points of stimulation, start and end points of y-position, dummy column with id.'
-)
-
help.text.short = c(
- 'Load CSV file with a column of cell IDs for removal. IDs should correspond to those used for plotting.',
+ 'Load CSV file with a column of track IDs for removal. IDs should correspond to those used for plotting.',
'If the track ID is unique only within a group, make it unique globally by combining with the grouping column.',
- 'Interpolate missing tpts and pre-existing NAs. When checked, the interval of time column must be provided!',
- 'Load CSV file with 5 columns: grouping, start and end tpts of stimulation, start and end of y-position, dummy column with id.',
+ 'Interpolate missing time points and pre-existing NAs. The interval of the time column must be provided!',
+ 'Load CSV file with 5 columns: grouping, start and end tpts of stimulation, start and end of y-position, dummy column with ID.',
'Select columns to group data according to treatment, condition, etc.',
'Select math operation to perform on a single or two columns,',
'Select range of time for further processing.',
- 'Normalise data to a selected region.',
- 'Download data after modification in this section.'
+ 'Normalise time series to a selected region.',
+ 'Download time series after modification in this section.'
)
# Functions for data processing ----
diff --git a/modules/boxPlot.R b/modules/boxPlot.R
index fcf9c9ede9e20e88d8dbd08497cd73a8b0d8a00d..61dd24f9a03a17efa6d4d34a8734a09434c16d6c 100644
--- a/modules/boxPlot.R
+++ b/modules/boxPlot.R
@@ -1,10 +1,15 @@
-# Module for plotting a choice of box/violin/dot-plots
+#
+# Time Course Inspector: Shiny app for plotting time series data
+# Author: Maciej Dobrzynski
+#
+# This module is for plotting a choice of box/violin/dot-plots
# Assumes in.data contains columns:
# realtime
# y
# group
# id
+# UI ----
modBoxPlotUI = function(id, label = "Plot Box-plots") {
ns <- NS(id)
@@ -68,7 +73,7 @@ modBoxPlotUI = function(id, label = "Plot Box-plots") {
)
}
-
+# SERVER ----
modBoxPlot = function(input, output, session,
in.data,
in.cols = list(meas.x = 'realtime',
diff --git a/modules/clDistPlot.R b/modules/clDistPlot.R
index 8c1c28bc5f4df18d29a1062ee46d40c4f92e358d..5e93c25fbdb2ca415c20df43ecc6afdb9b8b15f7 100644
--- a/modules/clDistPlot.R
+++ b/modules/clDistPlot.R
@@ -1,4 +1,12 @@
-modClDistPlotUI = function(id, label = "Plot Fractions WIthin Clusters") {
+#
+# Time Course Inspector: Shiny app for plotting time series data
+# Author: Maciej Dobrzynski
+#
+# This module is for plotting stacked bar plot with percentages of time series in clusters
+#
+
+# UI ----
+modClDistPlotUI = function(id, label = "Plot Fractions Within Clusters") {
ns <- NS(id)
tagList(
@@ -14,6 +22,8 @@ modClDistPlotUI = function(id, label = "Plot Fractions WIthin Clusters") {
+# SERVER ----
+
# Params:
# in.data - data prepared with data4clDistPlot f-n
# in.cols - table with 1st column as cluster number, 2nd column colour assignments
@@ -55,7 +65,7 @@ modClDistPlot = function(input, output, session, in.data, in.cols = NULL, in.fna
p.out = p.out +
scale_y_continuous(labels = percent) +
- ylab("percentage of cells\n") +
+ ylab("Percentage of time-series\n") +
xlab("") +
LOCggplotTheme(in.font.base = PLOTFONTBASE,
in.font.axis.text = PLOTFONTAXISTEXT,
diff --git a/modules/dispTrackStats.R b/modules/dispTrackStats.R
index 3d61d0eb6d2916b5313f9fa60d37332138cde771..ab596f96977c6a332e9a3a8067dda01cb5b1cfa6 100644
--- a/modules/dispTrackStats.R
+++ b/modules/dispTrackStats.R
@@ -1,6 +1,15 @@
+#
+# Time Course Inspector: Shiny app for plotting time series data
+# Author: Maciej Dobrzynski
+#
+# This module is for displaying time series statistics
+#
+
require(DT)
require(data.table)
+
+# UI ----
modTrackStatsUI = function(id, label = "Comparing t-points") {
ns <- NS(id)
@@ -10,7 +19,7 @@ modTrackStatsUI = function(id, label = "Comparing t-points") {
)
}
-
+# SERVER ----
modTrackStats = function(input, output, session,
in.data) {
@@ -61,7 +70,7 @@ modTrackStats = function(input, output, session,
if (is.null(loc.dt))
return(NULL)
- sprintf('Number of tracks: %d
Average track length: %.2f time units',
+ sprintf('Number of time-series: %d
Average length: %.2f time units',
length(unique(loc.dt[['id']])),
loc.dt[, .(trackLength = .N), by = 'id'][, mean(trackLength)])
diff --git a/modules/downCSV.R b/modules/downCSV.R
index b0a341358a7a78a0e965319258bcf00ab04b49a6..8567b36d4108a4ae34757e5794d311544fcdab0c 100644
--- a/modules/downCSV.R
+++ b/modules/downCSV.R
@@ -2,8 +2,7 @@
# Time Course Inspector: Shiny app for plotting time series data
# Author: Maciej Dobrzynski
#
-# This is the module of a Shiny web application.
-# Download CSV with data
+# This module is for downloading CSV with data
#
# Usage:
# in ui.R
diff --git a/modules/downPlot.R b/modules/downPlot.R
index 619d84509823a2e8760b5bec880a5af8fb381681..5dd6aedf3060f37740fdb020014d2e9772a24010 100644
--- a/modules/downPlot.R
+++ b/modules/downPlot.R
@@ -1,4 +1,8 @@
-# RShiny module for downloading pdf of the plot
+#
+# Time Course Inspector: Shiny app for plotting time series data
+# Author: Maciej Dobrzynski
+#
+# This module is for downloading pdf of the plot
# Use:
# in ui.R
# downPlotUI('uniqueID', "your_label")
@@ -6,7 +10,7 @@
# in server.R
# callModule(downPlot, "uniqueID", 'fname.pdf', input_plot_to_save)
-
+# UI ----
downPlotUI <- function(id, label = "Download Plot") {
ns <- NS(id)
@@ -41,6 +45,8 @@ downPlotUI <- function(id, label = "Download Plot") {
)
}
+# SERVER ----
+
downPlot <- function(input, output, session, in.fname, in.plot, in.gg = FALSE) {
output$uiDownButton = renderUI({
diff --git a/modules/selOutliers.R b/modules/selOutliers.R
index 7326c1947fb9a8e94693920dc68d67a04fe03ce9..829242744e00d3229a3f450d1fdd4cbff24558ea 100644
--- a/modules/selOutliers.R
+++ b/modules/selOutliers.R
@@ -2,7 +2,7 @@
# Time Course Inspector: Shiny app for plotting time series data
# Author: Maciej Dobrzynski
#
-# This is the module of a Shiny web application.
+# This is a module of a Shiny web application.
# Outlier identification, selection
# UI-remove-outliers ----
diff --git a/modules/tabAUC.R b/modules/tabAUC.R
index 07f957972d1740db03c28ad76f2c4e9bab2cc35b..bafb04e213931a04c857136eab7b828920e75982 100644
--- a/modules/tabAUC.R
+++ b/modules/tabAUC.R
@@ -1,7 +1,14 @@
+#
+# Time Course Inspector: Shiny app for plotting time series data
+# Author: Maciej Dobrzynski
+#
+# This module is a tab for plotting Area Under Curve
+#
# Calculates area under curve (AUC) for every single time course provided in the input
require(pracma) # for trapz
+# UI ----
modAUCplotUI = function(id, label = "Plot Area Under Curves") {
ns <- NS(id)
@@ -19,6 +26,7 @@ modAUCplotUI = function(id, label = "Plot Area Under Curves") {
)
}
+# SERVER ----
modAUCplot = function(input, output, session, in.data, in.fname) {
ns <- session$ns
diff --git a/modules/tabBoxPlot.R b/modules/tabBoxPlot.R
index d67df5fc33a966d15ef22f3f46b834f2b76f681b..c75f0113e8e5d4b072b355a11a6c75c54f7802c7 100644
--- a/modules/tabBoxPlot.R
+++ b/modules/tabBoxPlot.R
@@ -1,3 +1,11 @@
+#
+# Time Course Inspector: Shiny app for plotting time series data
+# Author: Maciej Dobrzynski
+#
+# This module is a tab for plotting box-plots at selected time points
+#
+
+# UI ----
tabBoxPlotUI = function(id, label = "Comparing t-points") {
ns <- NS(id)
@@ -19,8 +27,7 @@ tabBoxPlotUI = function(id, label = "Comparing t-points") {
)
}
-####
-## server box-plot
+# SERVER ----
tabBoxPlot = function(input, output, session, in.data, in.fname) {
callModule(modStats, 'dispStats',
diff --git a/modules/tabClBay.R b/modules/tabClBay.R
index 12488f90858dc901d21f4e84d5b99443bd61838b..6f21bafb8f855a2cf6b0087bddd28e7edac89868 100644
--- a/modules/tabClBay.R
+++ b/modules/tabClBay.R
@@ -1,4 +1,10 @@
-# RShiny module for performing Bayesian clustering using bclust
+#
+# Time Course Inspector: Shiny app for plotting time series data
+# Author: Maciej Dobrzynski
+#
+# This module is for Bayesian clustering using bclust package
+# NOT USED AT THE MOMENT!!!
+#
# Use:
# in ui.R
# tabPanel(
@@ -27,7 +33,7 @@ l.col.pal = list(
"Blues" = "Blues"
)
-# UI
+# UI ----
clustBayUI <- function(id, label = "Sparse Hierarchical CLustering") {
ns <- NS(id)
@@ -142,7 +148,7 @@ clustBayUI <- function(id, label = "Sparse Hierarchical CLustering") {
)
}
-# SERVER
+# SERVER ----
clustBay <- function(input, output, session, dataMod) {
userFitBclus <- reactive({
cat(file = stderr(), 'userFitBclus \n')
diff --git a/modules/tabClHier.R b/modules/tabClHier.R
index 36e8a49ed85055fc016b84092f8420a0d6a55495..813d2ab352a888d5ee194feadbd479510c8869ec 100644
--- a/modules/tabClHier.R
+++ b/modules/tabClHier.R
@@ -2,8 +2,7 @@
# Time Course Inspector: Shiny app for plotting time series data
# Author: Maciej Dobrzynski
#
-# This is the module of a Shiny web application.
-# Hierarchical clustering
+# This module is a tab for hierarchical clustering (base R hclust + dist)
# UI ----
clustHierUI <- function(id, label = "Hierarchical CLustering") {
@@ -51,9 +50,12 @@ clustHierUI <- function(id, label = "Hierarchical CLustering") {
ticks = TRUE,
round = TRUE
),
+
# These two lines are to manually assign colours to clusters; it doesn't really work well, so skip
+ # NOT USED AT THE MOMENT!
#checkboxInput(ns('chBPlotHierClAss'), 'Manually assign cluster colours'),
#uiOutput(ns('uiPlotHierClAss')),
+
checkboxInput(ns('chBPlotHierClSel'), 'Manually select clusters to display'),
uiOutput(ns('uiPlotHierClSel')),
downloadButton(ns('downCellCl'), 'Download CSV with cell IDs and cluster no.')
@@ -279,9 +281,10 @@ clustHier <- function(input, output, session, in.data4clust, in.data4trajPlot, i
loc.col = get(input$selectPlotHierPaletteDend)(n = loc.k)
# take into account manual assignment of cluster numbers
- if (input$chBPlotHierClAss) {
- loc.col = loc.col[as.numeric(input$inPlotHierClAss)]
- }
+ # NOT USED AT THE MOMENT
+ #if (input$chBPlotHierClAss) {
+ # loc.col = loc.col[as.numeric(input$inPlotHierClAss)]
+ #}
dend <- as.dendrogram(cl.hc)
dend <- color_branches(dend,
diff --git a/modules/tabClHierSpar.R b/modules/tabClHierSpar.R
index 0412430decb21b531c922d1115811f5764d99eb6..4b9d511aca711d6710c4a6ba6d098c2ce2d9584f 100644
--- a/modules/tabClHierSpar.R
+++ b/modules/tabClHierSpar.R
@@ -1,5 +1,11 @@
+#
+# Time Course Inspector: Shiny app for plotting time series data
+# Author: Maciej Dobrzynski
+#
+# This module is for sparse hierarchical clustering using sparcl package
+#
-# UI
+# UI ----
clustHierSparUI <- function(id, label = "Sparse Hierarchical CLustering") {
ns <- NS(id)
@@ -183,7 +189,7 @@ clustHierSparUI <- function(id, label = "Sparse Hierarchical CLustering") {
)
}
-# SERVER
+# SERVER ----
clustHierSpar <- function(input, output, session, in.data4clust, in.data4trajPlot, in.data4stimPlot) {
# UI for advanced options
diff --git a/modules/tabScatter.R b/modules/tabScatter.R
index ef6d6541b32148ed4833d5c1b7957ca2319061f3..695658a26fb98d42e942745775ceec414618df4f 100644
--- a/modules/tabScatter.R
+++ b/modules/tabScatter.R
@@ -1,4 +1,9 @@
-# RShiny module for the scatter plot
+#
+# Time Course Inspector: Shiny app for plotting time series data
+# Author: Maciej Dobrzynski
+#
+# This module is a tab for plotting scatter plots between two time points
+#
# Use:
# in ui.R
# tabPanel(
@@ -14,7 +19,7 @@ require(plotly) # interactive plot
require(robust)
require(MASS)
-# UI
+# UI ----
tabScatterPlotUI <- function(id, label = "Comparing t-points") {
ns <- NS(id)
@@ -65,7 +70,7 @@ tabScatterPlotUI <- function(id, label = "Comparing t-points") {
)
}
-# SERVER
+# SERVER ----
tabScatterPlot <- function(input, output, session, in.data, in.fname) {
# return all unique time points (real time)
diff --git a/modules/trajPlot.R b/modules/trajPlot.R
index 4368553cf1d7ef5f0c04fd91c604c9fc6a5f5f78..efaad8685c0081bc76a647d2bf04be2ec9209867 100644
--- a/modules/trajPlot.R
+++ b/modules/trajPlot.R
@@ -2,7 +2,7 @@
# Time Course Inspector: Shiny app for plotting time series data
# Author: Maciej Dobrzynski
#
-# This is the module for plotting individual time series
+# This module is for plotting individual time series
#
diff --git a/modules/trajPsdPlot.R b/modules/trajPsdPlot.R
index b9dff99d068ee1f5c52850db5570a7e01395ab28..085166ec6bfd94c522d4112bdf5e3a98492d18d3 100644
--- a/modules/trajPsdPlot.R
+++ b/modules/trajPsdPlot.R
@@ -1,3 +1,10 @@
+#
+# Time Course Inspector: Shiny app for plotting time series data
+# Author: Marc-Antoine Jacques
+#
+# This module is for plotting Power Spectral Analysis
+#
+
require(DT)
require(scales)
@@ -82,10 +89,6 @@ modPSDPlot = function(input, output, session,
})
- callModule(modTrackStats, 'dispTrackStats',
- in.data = in.data)
-
-
output$outPlotTraj <- renderPlot({
loc.p = plotTraj()
diff --git a/modules/trajRibbonPlot.R b/modules/trajRibbonPlot.R
index 180e0010d45b16e8b4bb6576024b8c9025b34875..f37344ff15823b3f51c9ddec712900bcf9e1c626 100644
--- a/modules/trajRibbonPlot.R
+++ b/modules/trajRibbonPlot.R
@@ -1,3 +1,10 @@
+#
+# Time Course Inspector: Shiny app for plotting time series data
+# Author: Maciej Dobrzynski
+#
+# This module is for plotting group averages as ribbon plots (mean + 95%CI)
+#
+
require(DT)
modTrajRibbonPlotUI = function(id, label = "Plot Individual Time Series") {
diff --git a/server.R b/server.R
index 5ca6c5701835ec0c43d59280babb7c08d980806a..cb4df0f684720719be863b008165ff0bb96c682e 100644
--- a/server.R
+++ b/server.R
@@ -166,7 +166,7 @@ shinyServer(function(input, output, session) {
selectInput(
'inSelTrackLabel',
- 'Select Track Label:',
+ 'Select ID:',
locCols,
width = '100%',
selected = locColSel
diff --git a/ui.R b/ui.R
index 5575bff546dfc358bfe6ae55c4a8f2c54f82953c..9a2a4373b61feafda610e0a7474c434b53b7c0a5 100644
--- a/ui.R
+++ b/ui.R
@@ -49,7 +49,7 @@ shinyUI(fluidPage(
uiOutput('varSelTimeFreq'),
- checkboxInput('chBtrackUni', 'Create unique track ID', F),
+ checkboxInput('chBtrackUni', 'Create unique ID', F),
bsTooltip('chBtrackUni', help.text.short[2], placement = "right", trigger = "hover", options = NULL),
tags$hr(),