R Shiny Example Web App
This is an example web applet that shows how to build and run an R Shiny application on DNAnexus.
Last updated
Was this helpful?
This is an example web applet that shows how to build and run an R Shiny application on DNAnexus.
View full source code on GitHub
Inside the dxapp.json, add "httpsApp": {"ports":[443], "shared_access": "VIEW"} to tell the worker to expose this port.
R Shiny needs two scripts, server.R and ui.R. Place them under resources/home/dnanexus/my_app/. When a job starts based on this applet, the resources directory is copied onto the worker, and since the ~/ path on the worker is /home/dnanexus, that means you have ~/my_app with those two scripts inside.
From the main applet script code.sh, start shiny pointing to ~/my_app, serving its mini-application on port 443.
main() {
R -e "shiny::runApp('~/my_app', host='0.0.0.0', port=443)"
}For all web apps, if everything is running without errors (the ideal case), the line of code that starts the server keeps it running indefinitely. The applet stops only when it is terminated. This also means that any lines of code after the server starts are not executed.
To make your own applet with R Shiny, copy the source code from this example and modify server.R and ui.R inside resources/home/dnanexus/my_app.
To build the asset, run the dx build_asset command and pass shiny-asset, that is the name of the directory holding dxasset.json:
dx build_asset shiny-assetThis outputs a record ID record-xxxx that you can then put into the applet's dxapp.json in place of the existing one:
Build and run the applet itself:
Once it starts, you can go to that job's URL based on its job ID, https://job-xxxx.dnanexus.cloud/, to see the result.
Last updated
Was this helpful?
Was this helpful?
"runSpec": {
...
"assetDepends": [
{
"id": "record-xxxx"
}
]
...
}dx build -f r-shiny-web-app
dx run r-shiny-web-app