README.md 5.17 KB
Newer Older
dmattek's avatar
dmattek committed
1 2
# Time-course analysis web-app

dmattek's avatar
dmattek committed
3
## Running the app from the server
Maciej Dobrzynski's avatar
Maciej Dobrzynski committed
4
The app can be deployed on R/Shiny server. Follow instruction [here](https://shiny.rstudio.com/deploy/ Shiny - Hosting).
dmattek's avatar
dmattek committed
5

dmattek's avatar
dmattek committed
6
## Running the app locally
Maciej Dobrzynski's avatar
Maciej Dobrzynski committed
7
Alternatively, after downloading the code, the app can run within RStudio. Open `server.R` or `ui.R` file, then click "Run App" button with green triangle in the upper right corner of the window with code open.
dmattek's avatar
dmattek committed
8 9 10 11 12

Following packages need to be installed in order to run the app locally:

* shiny
* shinyjs
13
* shinybs
dmattek's avatar
dmattek committed
14
* data.table
Maciej Dobrzynski's avatar
Update  
Maciej Dobrzynski committed
15
* DT
dmattek's avatar
dmattek committed
16 17 18
* ggplot2
* gplots
* plotly
Maciej Dobrzynski's avatar
Update  
Maciej Dobrzynski committed
19 20
* scales
* grid
dmattek's avatar
dmattek committed
21 22 23
* dendextend
* RColorBrewer
* sparcl
dmattek's avatar
dmattek committed
24
* dtw
Maciej Dobrzynski's avatar
Update  
Maciej Dobrzynski committed
25
* imputeTS
26 27 28
* MASS
* robust
* pracma
29
* Hmisc
dmattek's avatar
dmattek committed
30 31 32

Install packages using `install.packages('name_of_the_package_from_the_list_above')` command in RStudio command line.

dmattek's avatar
dmattek committed
33
```
34
install.packages(c("shiny", "shinyjs", "shinybs",
35
					"data.table", "DT",
Maciej Dobrzynski's avatar
Update  
Maciej Dobrzynski committed
36 37
					"ggplot2", "gplots", "plotly", "scales", "grid",
					"dendextend", "RColorBrewer",
dmattek's avatar
dmattek committed
38
					"sparcl", "dtw",
Maciej Dobrzynski's avatar
Update  
Maciej Dobrzynski committed
39
					"imputeTS", "MASS", "robust", "pracma", "Hmisc")) 
40 41
```

dmattek's avatar
dmattek committed
42 43
## Input file
The app recognises CSV (comma-separated values) files: data columns separated by a comma, floating point numbers using a dot (full-stop).
dmattek's avatar
dmattek committed
44 45 46

The data file has to be in a so called long format, where individual time-courses (tracks) are arranged one after another. Note a wide-format where individual tracks are arranged in neighbouring columns is NOT supported!

Maciej Dobrzynski's avatar
Update  
Maciej Dobrzynski committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
The app recognizes CSV (comma-separated values) files where data columns are separated by a comma, and floating point numbers use a dot (full-stop). Data should be arranged in a long format, where time-series (tracks) are arranged one after another. The wide format where individual tracks are arranged in neighboring columns is not supported.

The first row should include column headers. The input CSV file should contain at least these three columns:

* Identifier of a time series, i.e. a track label
* Time points
* Time-varying variable

| ID | Time | Meas1 |
|----|------|-------|
| 1  |  1   | 3.3   |
| 1  |  2   | 2.1   |
| 1  |  4   | 4.3   |
|----|------|-------|
| 2  |  1   | 2.8   |
| 2  |  2   | 1.9   |
| 2  |  3   | 1.7   |
| 2  |  4   | 2.2   |

In case of multi-variate time series, additional columns with variables can be added in the input. Then, GUI allows for choosing a single or a combination of two variables to display.

Time series can be grouped by introducing a grouping column:

| Group | ID | Time | Meas1 |
|-------|----|------|-------|
| gr1   | 1  |  1   | 3.3   |
| gr1   | 1  |  2   | 2.1   |
| gr1   | 1  |  4   | 4.3   |
|-------|----|------|-------|
| gr1   | 2  |  1   | 2.8   |
| gr1   | 2  |  2   | 1.9   |
| gr1   | 2  |  3   | 1.7   |
| gr1   | 2  |  4   | 2.2   |
|-------|----|------|-------|
| gr2   | 1  |  1   | 5.1   |
| gr2   | 1  |  2   | 5.4   |
| gr2   | 1  |  3   | 5.3   |

Introduction of grouping allows for the analysis and displaying data per group.

## Unique track IDs

For the analysis, track labels need to be unique across the entire dataset. If the track label column is not unique in the uploaded dataset, there's an option in the UI to create a unique track ID. Check the *Create unique track label* box on and choose grouping columns that will be added to the existing non-unique track label. 

In the example above, the `ID` column is not unique across the dataset (ID=1 is repeated in group `gr1` and `gr2`), therefore the unique track label has to consist of columns `Group` and `ID`. The resulting track label will be `gr1_1`, `gr2_1`, etc.


## Modules
dmattek's avatar
dmattek committed
95

Maciej Dobrzynski's avatar
Maciej Dobrzynski committed
96
The app opens with a default window that allows to plot population averages, individual time series, and power spectral density. 
dmattek's avatar
dmattek committed
97

Maciej Dobrzynski's avatar
Maciej Dobrzynski committed
98
The following features of time series analysis are available in the app:
dmattek's avatar
dmattek committed
99

Maciej Dobrzynski's avatar
Maciej Dobrzynski committed
100 101 102 103 104 105
- Perform simple **math calculations** on an individual variable (inversion 1/X), or on two variables (division, sum, multiplication, subtraction).
- **Trim** the time axis of the data.
- **Normalise** to the average of data points in a selected interval. Time series can be normalised with respect to the entire dataset, a group, or a single time series. The latter would normalise every time course to the mean of its own selected interval.
- **Remove outlier time points** by removing a percentage of data from the top, bottom, or both tails of pooled data points. Gaps in time series due to outlier removal can be then linearly interpolated or tracks can be removed entirely from the set. The UI allows for selecting the size of gaps above which the track is removed.
- **Highlight** individual time series by selecting a unique series identifier.
- Calculate area under individual time series and visualise as a dot-, violin-, or a box-plot. The UI allows for selection of the time series range used for **AUC** calculation.
Maciej Dobrzynski's avatar
Update  
Maciej Dobrzynski committed
106
- Display a dot-, violin-, box-, or a line-plot for selected time points.
Maciej Dobrzynski's avatar
Maciej Dobrzynski committed
107 108
- Display a scatter-plot to identify **correlations** between two time points. 
- Perform **hierarchical and sparse-hierarchical clustering** of individual time series. In these modules, the dendrogram can be cut at a chosen level to help visualising clusters. Addiitonally available are plots with cluster averages, individual times series per cluster, and contribution of time series from different groupings to clusters.