rcytoscapejs not working on account of renderGraph function not available

36 views
Skip to first unread message

crowm...@outlook.com

unread,
Jun 20, 2016, 3:02:28 PM6/20/16
to Shiny - Web Framework for R

 need to allow users to upload a file to define a network being rendered in an app.

I would like to vary the parameters to re-render an interactive shiny graph that is deployed via a special shiny github package- "rcytoscapejs": https://github.com/cytoscape/r-cytoscape.js/tree/master

While the graph deploys fine, my problem is that it can only be deployed from the UI, independently of the server...

 g<-createCytoscapeJsNetwork(nodeData = nodes, edgeData = edge)
 #ui.R
 dashboardBody(
  sliderInput(inputId="num", label="Choose coef", value=2, min=1, max=3),
  rcytoscapejs(g$nodes, g$edges)
 )

As you can see this is completely impartial from the server, when I try to implement the code within the server via something like this:

 #ui.R
 graphOutput("graph")
 #server.R
 output$graph<-renderGraph({rcytoscapejs(g$nodes, g$edges)})

I have tried "graphOutput" and "renderGraph" but the functions doesn't seem to exist...

I tried downloading the "renderGraph" from github.

 devtools::install_github("mfontcada/renderGraph");
 Downloading GitHub repo mfontcada/renderGraph@master
 from URL https://api.github.com/repos/mfontcada/renderGraph/zipball/master
 Error: Does not appear to be an R package (no DESCRIPTION)

But that package is in version 0.1 and hasn't been updated since 2014...

So ultimately my question is how can I vary the parameters of something that resides in the "ui.R" code???

Something like the following, (file upload code taken from: http://shiny.rstudio.com/gallery/file-upload.html):

  server <- function(input, output) {
   dataInput <- eventReactive(input$choices, {
     inFile <- input$file1
     if (is.null(inFile))
       return(NULL)
       read.csv(inFile$datapath, header = input$header, sep = input$sep, quote = input$quote)
     createCytoscapeJsNetwork(nodeData = nodes, edgeData = edge)
   })
  }

#ui.R  
actionButton("choices", "Run analyses"),
fileInput('file1', 'Choose file to upload',
          accept = c(
            'text/csv',
            'text/comma-separated-values',
            'text/tab-separated-values',
            'text/plain',
            '.csv',
            '.tsv'
          ),
 rcytoscapejs(dataInput()$nodes, dataInput()$edges),

This of course returns an error as one can not vary parameters within the ui.R script as such ....

Any tips on how to circumvent this?

Joe Cheng

unread,
Jun 21, 2016, 10:25:31 PM6/21/16
to crowm...@outlook.com, Shiny - Web Framework for R
The UI function to use is rcytoscapejsOutput, and the render function is renderRcytoscapejs (both part of the rcytoscapejs package). See the example they include: https://github.com/cytoscape/r-cytoscape.js/tree/master/inst/examples/shiny

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/3d375184-ace7-4574-9da3-e491531aa32d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

crowm...@outlook.com

unread,
Jun 22, 2016, 6:14:07 AM6/22/16
to Shiny - Web Framework for R, crowm...@outlook.com
Thanks so much Joe that worked- hadn't seen that before Chris
Reply all
Reply to author
Forward
0 new messages