Tuesday, June 20, 2017

How to serve a R code that produces a Shiny app in your local shiny server

Leave a Comment

I have the following R code from (BatchQC package)

 library(BatchQC)     nbatch <- 3     ncond <- 2     npercond <- 10     data.matrix <- rnaseq_sim(ngenes=50, nbatch=nbatch, ncond=ncond, npercond=         npercond, basemean=10000, ggstep=50, bbstep=2000, ccstep=800,      basedisp=100, bdispstep=-10, swvar=1000, seed=1234) batch <- rep(1:nbatch, each=ncond*npercond) condition <- rep(rep(1:ncond, each=npercond), nbatch) batchQC(data.matrix, batch=batch, condition=condition,          report_file="batchqc_report.html", report_dir=".",          report_option_binary="111111111",         view_report=FALSE, interactive=TRUE, batchqc_output=TRUE) 

When run in RStudio console, it produces this:

enter image description here

My question is how can I show that site through my local Shiny Server

/srv/shiny-server/ 

2 Answers

Answers 1

what do you mean with local shiny server? when you run a preview from R that's local already. if you have a full shiny server install on your machine, just create a folder in sample-apps and then point the browser to the shiny server (usually http://127.0.0.1:3838/sample-apps/youfolder/

Answers 2

I'm not familiar with that BatchQC package, but assuming it's this one on GitHub, I looked at the batchQC function and saw this code:

    appDir <- system.file("shiny", "BatchQC", package = "BatchQC")     if (appDir == "") {         stop("Could not find shiny directory. Try re-installing BatchQC.",              call. = FALSE)     }     shiny::runApp(appDir, display.mode = "normal") 

So, I don't know if this will work or not (I wasn't able to install the package myself), but you can try to create an app.R file in your shiny server with the following lines:

appDir <- system.file("shiny", "BatchQC", package = "BatchQC") shiny::runApp(appDir) 

Can't guarantee it'll work, but try it out.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment