How can I display a title of a network next to its visualization?

74 views
Skip to first unread message

katja...@gmail.com

unread,
Oct 11, 2018, 11:41:12 AM10/11/18
to cytoscape-helpdesk
Hello,

I am using py2cytoscape to load multiple networks from a jupyter notebook into cytoscape, set the style and layout and then save an image of every network as pdf. I would like to add a title to every image on top (or bottom, doesn't matter) of the network visualization that indicates the name of the network. How can I do that? The networks all have the right name in the network control panel but how can I add these names to the network visualization and saved image?

Many thanks in advance for your help.

Best,
Katja

Ruth Isserlin

unread,
Oct 11, 2018, 11:49:18 AM10/11/18
to cytoscape...@googlegroups.com
Hi Katja,
You can manually add an annotation to the network (right click where you want to put the title and add—>annotation and specify the title) with its title before exporting the image but unfortunately I don’t think annotations are accessible through commands yet so you can’t do it automatically with py2cytoscape. In my notebooks when I insert an image I often specify the title from the notebook instead.
Ruth
> --
> You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpd...@googlegroups.com.
> To post to this group, send email to cytoscape...@googlegroups.com.
> Visit this group at https://groups.google.com/group/cytoscape-helpdesk.
> To view this discussion on the web visit https://groups.google.com/d/msgid/cytoscape-helpdesk/b13d1bfe-cfbc-4529-868b-f36d310597d5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Katja Luck

unread,
Oct 11, 2018, 11:57:34 AM10/11/18
to cytoscape...@googlegroups.com
Hi Ruth,

Thanks for your quick answer. I didn't know about the right click feature. I just tried it and it worked but sadly I would need automation as I am dealing with 30 and more networks at a time. I don't fully understand your second solution with respect to adding a title from the notebook. You mean when you show the image within the notebook you can add a title and save it then? Would you have some sample code for me starting from my code below?

from py2cytoscape.data.cyrest_client import CyRestClient
cy = CyRestClient()
network = cy.network.create_from_igraph(g,name='network1') # g is some igraph object
pdf = network.get_pdf()
target = open('some_file_path_and_name.pdf','wb')
target.write(pdf)
target.close()

Thanks!
Katja
> You received this message because you are subscribed to a topic in the Google Groups "cytoscape-helpdesk" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/cytoscape-helpdesk/NEbShibcmsk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to cytoscape-helpd...@googlegroups.com.
> To post to this group, send email to cytoscape...@googlegroups.com.
> Visit this group at https://groups.google.com/group/cytoscape-helpdesk.
> To view this discussion on the web visit https://groups.google.com/d/msgid/cytoscape-helpdesk/D75E1A9E-C2EC-4A7C-8D97-A73515D08224%40utoronto.ca.

Ruth Isserlin

unread,
Oct 11, 2018, 12:04:30 PM10/11/18
to cytoscape...@googlegroups.com
HI Katja,
Unfortunately I am not using py2cytoscape. I am using R notebooks. So I am not quite sure how you can do it in your notebook but there should be a way.

In R I simply export the network to a file and then insert the image with something like this:

### Title of figure
```{r example_heatmap, echo=FALSE, fig.cap=“caption for example"}
knitr::include_graphics(example_hetmap_filename)
```

Thanks,
Ruth
> To view this discussion on the web visit https://groups.google.com/d/msgid/cytoscape-helpdesk/12AB32F8-C5AD-4FD9-AB94-D33195E45D01%40gmail.com.

Scooter Morris

unread,
Oct 11, 2018, 12:12:38 PM10/11/18
to cytoscape-helpdesk
Hi Katja,
   It's on our project list to provide a connection to the Cytoscape graphical annotations via py2cytoscape, but it didn't make the 3.7 cut-off.  Hopefully we'll be able to add it in 3.7.1 or 3.8.

-- scooter

Katja Luck

unread,
Oct 11, 2018, 12:22:18 PM10/11/18
to cytoscape...@googlegroups.com
Ok, thanks!

-- 
You received this message because you are subscribed to a topic in the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cytoscape-helpdesk/NEbShibcmsk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cytoscape-helpd...@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.
Reply all
Reply to author
Forward
0 new messages