import ipycytoscape
import json
with open("geneData.json") as fi:
json_file = json.load(fi)
with open("geneStyle.json") as fi:
s = json.load(fi)
cytoscapeobj = ipycytoscape.CytoscapeWidget()
cytoscapeobj.graph.add_graph_from_json(json_file)
cytoscapeobj.set_style(s)
cytoscapeobj.set_layout(name = 'cola',
nodeSpacing = 5,
edgeLengthVal = 45,
animate = True,
randomize = False,
maxSimulationTime = 1500)
cytoscapeobj
# edits graph directly
cytoscapeobj.set_layout(nodeSpacing=100)
cytoscapeobj.get_layout()
# connects a slider to the nodeSpacing of the graph
import ipywidgets as widgets
node_range = widgets.IntSlider()
output = widgets.Output()
display(node_range, output)
def on_value_change(change):
with output:
cytoscapeobj.set_layout(nodeSpacing = node_range.value)
cytoscapeobj.get_layout()
node_range.observe(on_value_change)