py2cytoscape: how to save the network as a dict containing the key position for each node

12 views
Skip to first unread message

Emily P

unread,
Feb 6, 2019, 4:22:52 AM2/6/19
to cytoscape-helpdesk
Hi all,

My aim is to create a network via py2cytoscape and  save the network i as a dict.
From such a dict  I'll be able to plot an interactive d3.js network, via Plotly.

I tried to extract such info as follows:
    
`netdict= my_cynet.to_json()`

but a dict like this one `netdict['elements']['nodes'][0]` hasn't a key, 'position':

```
{'data': {'SUID': 137,
  'id': '137',
  'id_original': '3',
  'name': '3',
  'selected': False,
  'shared_name': '3'}}
```
that displays the node position as:
```
"position" : {
        "x" : 870,
        "y" : 393
      }
```   

How could I get the node positions, too?
Thanks!!!!

Emily P

unread,
Feb 6, 2019, 9:09:27 AM2/6/19
to cytoscape-helpdesk
Hi,

Meanwhile I realized that 

```
netdict=my_cynet.get_first_view()
```

displays node positions.

Em

Scooter Morris

unread,
Feb 7, 2019, 9:48:16 AM2/7/19
to cytoscape-helpdesk
Right.  Networks don't have positions, just nodes and edges.  The network view is where information about node positions, color, etc. are stored.

-- scooter
Reply all
Reply to author
Forward
0 new messages