We can choose the format of the saving image in Python. To execute this examples, first, we have to import sample data.
Write an image of the specified type to the specified file, at the specified scaling factor.
Note: the file is written to the file system of the computer upon which R is running, not Cytoscape – in those cases where they are different. It is saved to the working directory.
In [2]:
# import data from url
from py2cytoscape.data.cyrest_client import CyRestClient
# Create REST client for Cytoscape
cy = CyRestClient()
# Reset current session for fresh start
cy.session.delete()
# Load a sample network
network = cy.network.create_from('http://chianti.ucsd.edu/~kono/data/galFiltered.sif')
# Apply layout to the cytoscape network object
cy.layout.apply(network = network)
In [3]:
# png
from IPython.display import Image
network_png = network.get_png()
Image(network_png)
Out[3]:
In [4]:
# svg
from IPython.display import SVG
network_svg = network.get_svg()
SVG(network_svg)
Out[4]:
In [6]:
# pdf
network_pdf = network.get_pdf()
# save the file
f = open('resultImage/scale_free_500.pdf', 'wb')
f.write(network_pdf)
f.close()