-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathshare.Rmd
More file actions
87 lines (67 loc) · 3.34 KB
/
share.Rmd
File metadata and controls
87 lines (67 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
---
title: "Share interactive heatmaps to collaborators"
author: "Zuguang Gu ( z.gu@dkfz.de )"
date: "`r Sys.Date()`"
output:
rmarkdown::html_vignette:
width: 8
fig_width: 5
vignette: >
%\VignetteIndexEntry{8. Share interactive heatmaps to collaborators}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
For JavaScript-based interactive heatmaps, all necessary files (html, js and css files) can be saved to disk
and interactive heatmaps can be opened in another computer without R being installed. But **InteractiveComplexHeatmap**
is different. The interactivity of **InteractiveComplexHeatmap** is implemented with **shiny**, **ComplexHeatmap** and other related R packages,
which means, R must be installed on computers where interactive heatmaps are going to be opened. Nevertheless,
there are the following two ways that can used to share interactive heatmaps generated by **InteractiveComplexHeatmap**.
## The `save` argument
In `htShiny()`, there is a `save` argument which can be set to a path of a folder where interactive heatmap files are stored.
```{r, eval = FALSE}
# E.g. the folder is "test_ht"
htShiny(ht, save = "test_ht")
```
Then in the folder `test_ht`, there are the following files generated:
```
guz@B069-mb04:~/test_ht$ ls -l
total 40
-rw-r--r-- 1 guz staff 1.1K Oct 18 15:19 htShiny.R
-rw-r--r-- 1 guz staff 5.9K Oct 18 15:19 htShiny.RData
-rw-r--r-- 1 guz staff 18B Oct 18 15:19 htShiny.bat
-rw-r--r--@ 1 guz staff 18B Oct 18 15:19 htShiny.sh
```
`htShiny.R` contains R code that generates the interactive heatmap. `htShiny.RData` contains all R objects needed for heatmap and it will be loaded in `htShiny.R`.
The other two files `htShiny.sh` and `htShiny.bat` are basically identical and they can be run in the terminal under Linux/MacOS or Windows.
The four files can be sent to collaborators and they can run the following commands to open the interactive heatmap:
```
cd ~/test_ht
sh htShiny.sh
# or
Rscript htShiny.R
```
Under Windows, they can simply double click `htShiny.bat`.
Executing `htShiny.sh` or `htShiny.bat` prints a message where collaborators can find the link and paste it to browser to open the interactive heatmap.
```
guz@B069-mb04:~/test_ht$ sh htShiny.sh
If the shiny app is not automatically opened in the browser, you can manually
copy the following link and paste it to the browser.
Listening on http://127.0.0.1:4132
```
Note, on the collaborator's side, R must be installed (however, they don't
need to directly interact with R). If the **InteractiveComplexHeatmap**
package is not yet installed there, `htShiny.R` automatically installs it for
them.
## Use Shiny Server
It would be much easier if there is already a [Shiny Server](https://www.rstudio.com/products/shiny/shiny-server/) available.
Users simply put all code that generates interactive heatmaps into a script named `app.R`.
Under RStudio, they execute the script and click "Publish" in the Shiny app window.
Or under command-line:
```r
rsconnect::setAccountInfo(...)
rsconnect::deployApp(...)
```
Check https://shiny.rstudio.com/deploy/ to find out how to publish Shiny apps to Shiny Server.
Please note, in the R session which publishes the Shiny app, you must execute the command `setRepositories(ind = 1:4)` so that on the Shiny Server side, it can
successfully install **InteractiveComplexHeatmap** package.
`