Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

export images as png by running a script

103 views
Skip to first unread message

Dima

unread,
Sep 22, 2018, 2:13:28 PM9/22/18
to cytoscape-helpdesk
Hello,
I am tryign to automate image export out of the cytscape - was wonderign if I can create a png out of the network with top resolution and dpi by just runnign a script file?
Dima

Alex Pico

unread,
Sep 22, 2018, 2:22:09 PM9/22/18
to cytoscape...@googlegroups.com
Hi Dima,

Using the RCy3 package, you have the exportImage() function, which can produce vector graphics (like SVG and PDF) or raster graphics at any resolution you want (like PNG):



Here are more examples of the exportImage() options for large PNGs:

exportImage(‘my_image_file', 'PNG', zoom=200) #.png scaled by 200%
exportImage(‘my_image_file', 'PNG', width=1500) #.png scaled to a width of 1500 pixels 

 - Alex

Dima

unread,
Sep 22, 2018, 2:54:00 PM9/22/18
to cytoscape-helpdesk
Thank you for your kidn reply - do I need to have the r isntalled to run this script? I am using high level automation macro (netork automation Automate)  - can I just rung a script file to do this from inside the Cytoscape?

Alex Pico

unread,
Sep 22, 2018, 3:29:34 PM9/22/18
to cytoscape...@googlegroups.com
Sure. I previously shared an R package solution, but you can also do this in Cytoscape directly using “Commands”.

To test out command syntax, open Tools>Command Line Dialog and then type ‘help view export’ and you’ll see the same options as in R:

Exports the current view to a graphics file and returns the path to the saved file. PNG and JPEG formats have options for scaling, while other formats only have the option 'exportTextAsFont'. For the PDF format, exporting text as font does not work for two-byte characters such as Chinese or Japanese. To avoid corrupted texts in the exported PDF, please set false to 'exportTextAsFont' when exporting networks including those non-English characters.



view export arguments:
Height=<Double>:
The height of the exported image. Valid only for bitmap formats, such as PNG and JPEG.
options=<ListSingleSelection (JPEG (*.jpeg, *.jpg)|PDF (*.pdf)|PNG (*.png)|PostScript (*.ps)|SVG (*.svg))>:
The format of the output file.
OutputFile=<File>:
The path name of the file where the view must be saved to. By default, the view's title is used as the file name.
Resolution=<ListSingleSelection (72|100|150|300|600)>:
The resolution of the exported image, in DPI. Valid only for bitmap formats, when the selected width and height 'units' is ```inches```. The possible values are: ```72``` (default), ```100```, ```150```, ```300```, ```600```.
Units=<ListSingleSelection (pixels|inches)>:
The units for the 'width' and 'height' values. Valid only for bitmap formats, such as PNG and JPEG. The possible values are: ```pixels``` (default), ```inches```.
Width=<Double>:
The width of the exported image. Valid only for bitmap formats, such as PNG and JPEG.
Zoom=<BoundedDouble (0.0<=100.0<=500.0)>:
The zoom value to proportionally scale the image. The default value is ```100.0```. Valid only for bitmap formats, such as PNG and JPEG.       

The command script can be run in this interface or as a script file. The equivalent examples as provided before would look like this:

view export OutputFile=my_image_file.png options=PNG Zoom=200
view export OutputFile=my_image_file2.png options=PNG Width=1500

 - Alex



--
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/dfb6ecc3-8c98-42be-ab68-777a63d67ce7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dima Chernovolov

unread,
Sep 22, 2018, 3:39:21 PM9/22/18
to cytoscape...@googlegroups.com
Fantastic Alex  - there are two options in image export window - DPI (shoudl eb set to 600) and zoom factor (shoudl be 500%) - can you help me woth this command line?
I can just enter it in command ine editor and run right?
Thats soudns closer to my automation goal.
Dima

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/FsSrCredSKY/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.

Alex Pico

unread,
Sep 22, 2018, 3:40:16 PM9/22/18
to cytoscape...@googlegroups.com
Yes! That is how you do it. Give it a try and let me know what does not work.
 - Alex



Dima Chernovolov

unread,
Sep 22, 2018, 3:40:32 PM9/22/18
to cytoscape...@googlegroups.com
I entered this line in Command Line dialog - pasted endter and it did nto show any response

view export OutputFile=my_image_file.png options=PNG Zoom=200

can you pls check

Dima Chernovolov

unread,
Sep 22, 2018, 3:41:25 PM9/22/18
to cytoscape...@googlegroups.com
when I type help view export and press enter - it also shows nothing((

Alex Pico

unread,
Sep 22, 2018, 3:57:54 PM9/22/18
to cytoscape...@googlegroups.com
You’ll need the latest version of Cytoscape. Again, version 3.2.1 is very very outdated.
 - Alex



Dima

unread,
Sep 22, 2018, 4:10:10 PM9/22/18
to cytoscape-helpdesk
Thank you Alex - I will instal the new version now - can you please give me the code to eport image as png with 500% zoom factor and PDI of 600?
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.

--
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/FsSrCredSKY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.

--
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-helpdesk+unsub...@googlegroups.com.

--
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/FsSrCredSKY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.

--
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-helpdesk+unsub...@googlegroups.com.

Dima

unread,
Sep 23, 2018, 1:01:46 AM9/23/18
to cytoscape-helpdesk
I was able to export an image withe a script!!!!  (dancing) I also wanted to ask if there is a way to force overwirite exisiting image? so that no prompt is shown?

Alexander Pico

unread,
Sep 23, 2018, 6:36:42 PM9/23/18
to cytoscape...@googlegroups.com
Unfortunately, no there is not. 

 - Alex
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.
Reply all
Reply to author
Forward
0 new messages