cytoscape / cyjShiny

An R/shiny widget for cytoscape.js
Other
92 stars 28 forks source link

Documentation Issue: Graph or cyJSON #21

Closed cannin closed 4 years ago

cannin commented 4 years ago

On this file:

https://github.com/cytoscape/cyjShiny/blob/5579e9f347a9a71f9167872f533d130e1ef5f906/R/cyjShiny.R#L16

the help makes it seems the input is a graphNEL object, but in the examples:

https://github.com/cytoscape/cyjShiny/blob/898bab836cb1af4d38642ca665ef429be3474e7a/inst/unitTests/cyjShinyDemo.R#L18

It seems like the input is actually a graph converted to JSON. Should the documentation be made more clear?

paul-shannon commented 4 years ago

Thanks, Augustin. We will get to this by the end of the week.

On Sep 3, 2019, at 11:14 AM, Augustin Luna notifications@github.com wrote:

On this file:

https://github.com/cytoscape/cyjShiny/blob/5579e9f347a9a71f9167872f533d130e1ef5f906/R/cyjShiny.R#L16

the help makes it seems the input is a graphNEL object, but in the examples:

https://github.com/cytoscape/cyjShiny/blob/898bab836cb1af4d38642ca665ef429be3474e7a/inst/unitTests/cyjShinyDemo.R#L18

It seems like the input is actually a graph converted to JSON. Should the documentation be made more clear?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

paul-shannon commented 4 years ago

@cannin I improved the documentation along the lines you proposed - thanks for pointing this out. Let me know what you think.

Also, this package is overdue for automated tests. Coming soon!

Arguments:

   graph: a graph in json format; converters from graphNEL and
          data.frame/s offered ("see also" below)

Examples:

       tbl.nodes <- data.frame(id=c("A", "B", "C"),
                               type=c("kinase", "TF", "glycoprotein"),
                               lfc=c(-3, 1, 1),
                               count=c(0, 0, 0),
                               stringsAsFactors=FALSE)

       tbl.edges <- data.frame(source=c("A", "B", "C"),
                               target=c("B", "C", "A"),
                               interaction=c("phosphorylates", "synthetic lethal", "unknown"),
                               stringsAsFactors=FALSE)

       graph.json.v1 <- dataFramesToJSON(tbl.edges) #  simple legitimate graph, nodes implied, but no node attributes
       graph.json.v2 <- dataFramesToJSON(tbl.edges, tbl.nodes) # nodes and edges both explicit,  attributes specified

       g <- graphNEL(nodes=c("A","B","C") edgemode="directed")
       g <- addEdge("A", "B", g)
       graph.json.v3 <- graphNELtoJSON(g)

       #output$cyjShiny <- renderCyjShiny(cyjShiny(graph.json.v[123]))
cannin commented 4 years ago

This is good thanks.