This is a follow up question to:
"Hi.
Sorry for slow response.
Unfortunately,
Network Analyzer is designed to be used from GUI, not from external
scripts and it is a bit tricky if I implement to call its function from
cyREST/ py2cytoscape. For now, the best way to do the same analysis
with Cytoscape and Python is using Cytoscape as visualizer for the
output of Python-based graph analysis tool such as NetworkX or igraph.
In this sample notebook, you can find how to convert NetworkX / igraph objects into Cytoscape:
Cell
#14 is the sample code analyzing graph with networkX and send it to
Cytoscape for visualization. These graph analysis tools have all of the
functions Network Analyzer has, and you can create similar
visualizations by calling them from your Python code.
Please let me know if you have further questions.
Thanks,
Kei"
So I have a network in cytoscape, and I've used it to cut down the number of nodes to those within 3 "neighbors" away from a center node.
I create the networkx:
res = requests.get(BASE + 'networks/' + network_id + "/views/first")
# Convert to Python object
existing_network = res.json()
nx_network = cy.to_networkx(existing_network)
I then calculate some statistics(not shown) and add it to the networkx, (This might be uneccessary) for example:
nx.set_node_attributes(nx_network, 'average shortest path', translated_path_dict)
I get the network view:
view_id_list = network.get_views()
view = network.get_view(view_id_list[0], format='view')
I attempt to set visual properties:
view.update_node_views(visual_property='NODE_SIZE', values = translated_path_dict)
view.update_node_views(visual_property='NODE_FILL_COLOR', values = translated_color_dict)
The color is updated but the node size is not.
When I get the values from the view, the new values are present, but the cytoscape window only reflect the color change:
node_views_dict = view.get_node_views_as_dict()
nv_df = pd.DataFrame.from_dict(node_views_dict, orient='index' )
Am I going about this wrong?