Skip to content

Instantly share code, notes, and snippets.

@kozo2
Created June 27, 2020 20:46
Show Gist options
  • Save kozo2/2641f9c0c531e41209ff68b05929f2c6 to your computer and use it in GitHub Desktop.
Save kozo2/2641f9c0c531e41209ff68b05929f2c6 to your computer and use it in GitHub Desktop.
library(dash)
library(dashHtmlComponents)
library(dashCytoscape)
library(readr)
library(purrr)
library(dplyr)
app <- Dash$new()
nodes <- read_csv("C:/Users/kozon/Downloads/nodes.csv")
edges <- read_csv("C:/Users/kozon/Downloads/edges.csv")
edges <- rename(edges, source=from)
edges <- rename(edges, target=to)
nodes <- lapply(
transpose(nodes),
function(x) {
return(
list(
data=x
)
)
}
)
edges <- lapply(
transpose(edges),
function(x) {
return(
list(
data=x
)
)
}
)
app$layout(
htmlDiv(
list(
cytoCytoscape(
id = 'cytoscape-two-nodes',
layout = list('name' = 'cose'),
style = list('width' = '100%', 'height' = '1000px'),
elements = c(edges,nodes)
)
)
)
)
app$run_server()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment