Difference between revisions of "Shiny"

From 太極
Jump to navigation Jump to search
(One intermediate revision by the same user not shown)
Line 327: Line 327:
* Essential guidelines for computational method benchmarking [https://genomebiology.biomedcentral.com/articles/10.1186/s13059-019-1738-8 paper]
* Essential guidelines for computational method benchmarking [https://genomebiology.biomedcentral.com/articles/10.1186/s13059-019-1738-8 paper]
* [https://www.rna-seqblog.com/bisr-rnaseq-an-efficient-and-scalable-rnaseq-analysis-workflow-with-interactive-report-generation/ BISR-RNAseq] – an efficient and scalable RNAseq analysis workflow with interactive report generation
* [https://www.rna-seqblog.com/bisr-rnaseq-an-efficient-and-scalable-rnaseq-analysis-workflow-with-interactive-report-generation/ BISR-RNAseq] – an efficient and scalable RNAseq analysis workflow with interactive report generation
* [https://bmcbioinformatics.biomedcentral.com/articles/10.1186/s12859-020-03577-4 NASQAR]: a web-based platform for high-throughput sequencing data analysis and visualization. 2020
= Interesting Examples =
= Interesting Examples =

Latest revision as of 20:50, 30 June 2020


The following is what we see on a browser after we run an example from shiny package. See http://rstudio.github.com/shiny/tutorial/#hello-shiny. Note that the R session needs to be on; i.e. R command prompt will not be returned unless we press Ctrl+C or ESC.

ShinyHello.png Shinympg.png ShinyReactivity.png ShinyTabsets.png ShinyUpload.png

More shiny examples can be found on https://github.com/rstudio/shiny-examples shiny-examples.

shiny depends on websockets, caTools, bitops, digest packages.

Q & A:

  • Tutorial: http://wch.github.io/shiny/tutorial/
  • Layout: http://shiny.rstudio.com/articles/layout-guide.html
  • Q: If we run runExample('01_hello') in Rserve from an R client, we can continue our work in R client without losing the functionality of the GUI from shiny. Question: how do we kill the job?
  • If I run the example "01_hello", the browser only shows the control but not graph on Firefox? A: Use Chrome or Opera as the default browser.
  • Q: How difficult to put the code in Gist:github? A: Just create an account. Do not even need to create a repository. Just go to http://gist.github.com and create a new gist. The new gist can be secret or public. A secret gist can not be edited again after it is created although it works fine when it was used in runGist() function.


Deploy to run locally

Follow the instruction here, we can do as following (Tested on Windows OS)

  1. Create a desktop shortcut with target "C:\Program Files\R\R-3.0.2\bin\R.exe" -e "shiny::runExample('01_hello')" . We can name the shortcut as we like, e.g. R+shiny
  2. Double click the shortcut. The Windows Firewall will be popped up and say it block some features of the program. It does not matter if we choose Allow access or Cancel.
  3. Look at the command prompt window (black background console window), it will say something like
    Listening on port 7510
    at the last line of the console.
  4. Open your browser (Chrome or Firefox works), and type the address http://localhost:7510. You will see something magic happen.
  5. If we don't want to play with it, we can close the browser and close the command console (hit 'x')too.


Installs shiny apps packaged as stand-alone Electron apps using Inno Setup, an open source software that builds installers for Windows programs only.

Deploy on cloud


Shiny server series part 1: setting up. It includes setting up A- and CNAME records on DigitalOcean.

Deploy on shinyapps.io

See Getting started with shinyapps.io page and Dashboard page.

Limitations of the free account (5 applications, 25 active hours per month) on shinyapps.io.

Shinyapps.io can accept google account to sign up. I create an account and a test application/instance on


  1. The R packages our shiny app uses will be automatically downloaded by shinyapps.io service. See the package dependencies section on http://shiny.rstudio.com/articles/shinyapps.html.
  2. Two commands are needed to upload an app: 1. rsconnect() [the full command is copied from account's token page. 2. deployApp() [assume we are in the right working directory].
  3. After we run rsconnect() command to deploy our apps, a new subfolder rsconnect will be created under our app folder. I add this folder to .gitignore file.
  4. The rsconnect stores account information. If we get the app from another account make sure to delete this subfolder before we run rsconnect::deployApp(); otherwise we will get an error message Error: HTTP 403 .... Forbidden'; see I can't deploy my app with a name that was used in a previous deleted app.
  5. For the shiny apps we uploaded to shinyapps.io, we can download them back. The download bundle will also include packrat subfolder (packrat.lock file and desc subfolder). See R packages → packrat for more about packrat.

Deploy with Docker

Shiny server installation

Each app directory needs to be copied to /srv/shiny-server/ (which links to /opt/shiny-server/) directory using sudo.

The default port is 3838. That is, the remote computer can access the website using http://xxx.xxx.x.xx:3838/AppName.

Ubuntu & firewall

In my case, I need to modify the firewall to allow traffic through to Shiny Server sudo ufw allow 3838. See How to Set Up Shiny Server on Ubuntu 16.04. The tutorial also covers Securing Shiny Server with a Reverse Proxy and SSL Certificate.



Raspberry Pi



sudo nano /etc/apt/sources.list
# deb http://archive.raspbian.org/raspbian/ stretch main 

sudo apt-get update
sudo apt-get install r-base r-base-core r-base-dev


sudo apt-get install cmake

sudo su - -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/')\"" 

git clone https://github.com/rstudio/shiny-server.git
cd shiny-server
mkdir tmp
cd tmp

PYTHON=`which python`
$PYTHON --version


mkdir ../build
(cd .. && ./bin/npm --python="$PYTHON" install)
(cd .. && ./bin/node ./ext/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js --python="$PYTHON" rebuild)

sudo make install

sudo ln -s /usr/local/shiny-server/bin/shiny-server /usr/bin/shiny-server

sudo useradd -r -m shiny

sudo mkdir -p /var/log/shiny-server
sudo mkdir -p /srv/shiny-server
sudo mkdir -p /var/lib/shiny-server
sudo chown shiny /var/log/shiny-server
sudo mkdir -p /etc/shiny-server

cd /etc/shiny-server/
sudo wget http://withr.me/misc/shiny-server.conf

sudo shiny-server


建立 server.R 及 ui.R 程式

cd /srv/shiny-server
mkdir hello_shiny
cd hello_shiny
# 分別建立 server.R 及 ui.R

Running shiny server as non-root: run_as

Reverse proxy: Deploy your own shiny server

Shiny https: Securing Shiny Open Source with SSL

How to run an R shiny app

Example of embedding shiny in your web page


The R Shiny packages you need for your web apps


Shiny + Docker



Dash bio for R

Introducing Dash Bio for R


shinythemes 1.1.1


How to use bootstraplib's Live Theme Previewer to customize Shiny apps?

shiny + databases: pool package


tags, hyperlinks





Persistent data storage in Shiny apps




shinyFiles package. This package extends the functionality of shiny by providing an API for client side access to the server file system. As many shiny apps are run locally this is equivalent to accessing the filesystem of the users own computer, without the overhead of copying files to temporary locations that is tied to the use of fileInput().

Password protection

Install all required R packages


Building a Shiny App as a Package


Collapsible menu

Three R Shiny tricks to make your Shiny app shines (2/3): Semi-collapsible sidebar

Color picker



Monte Carlo Shiny





Time series




reactlog: Visually debug your reactivity issues


Shiny in production: Principles, practices, and tools - Joe Cheng 2019


Shiny tips & tricks for improving your apps and solving common problems by Dean Attali.

Recreating a Shiny App with Flask

Recreating a Shiny App with Flask

Modularize your shiny apps

A Shiny-app Serves as Shiny-server Load Balancer

Shinyloadtest tools for load testing Shiny applications


New in RStudio 1.2: record and run tests for your Shiny code right inside the IDE with the shinytest package

Shiny-server System Performance Monitoring for Open Source Edition

Build a static website with R Shiny

Build a static website with R Shiny

Real Shiny Examples

Interesting Examples