Export

  • Save Images we can choose the format of the saving image in R.
    • pdf
    • png
    • svg

Save Images

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)

Save image as png



In [3]:
# png
from IPython.display import Image
network_png = network.get_png()
Image(network_png)


Out[3]:

Save image as svg



In [4]:
# svg
from IPython.display import SVG
network_svg = network.get_svg()
SVG(network_svg)


Out[4]:
Creator: FreeHEP Graphics2D Driver Producer: org.freehep.graphicsio.svg.SVGGraphics2D Revision Source: Date: 2016年9月5日 12時08分51秒 JST YLR075W YIL105C YLR134W YPR102C YGR085C YIL052C YNL069C YDL075W YBR248C YEL009C YOR202W YMR300C YMR108W YDR354W YDR050C YER074W YLR044C YGR254W YNL216W YAL038W YHR174W YNL301C YOL086C YNL307C YLR175W YML123C YIL133C YDR395W YOL127W YFR034C YER056CA YER179W YLR256W YIL070C YEL039C YGR088W YML054C YBR093C YML024W YOL120C YIL069C YDR171W YNL167C YOR120W YLR081W YOL051W YBR018C YJR048W YPR167C YPL075W YGL035C YCR012W YDR009W YJR060W YBR019C YPL248C YIL162W YBR020W YKL109W YCL030C YML051W YJR066W YGR046W YLR116W YGL237C YNL236W YBL021C YKL012W YKL074C YLR258W YGR108W YER143W YBR112C YBR160W YBL069W YCL067C YCR084C YKL101W YAL030W YLR345W YOR327C YDR299W YNL145W YGL008C YDR461W YHR084W YBR274W YHR071W YGR058W YPL031C YBR135W YJL219W YBL005W YOL156W YGL044C YOL123W YGL122C YER102W YMR255W YKR026C YOR361C YNL047C YPR041W YMR309C YGR136W YGL134W YLR321C YBR190W YCR086W YGL013C YOR264W YLR117C YPL149W YNR007C YHR171W YBR217W YDR412W YIL045W YPR119W YMR043W YMR183C YDL023C YPR113W YJL194W YGR009C YFL026W YIL015W YAL040C YJL159W YDR070C YDR429C YOL059W YOR362C YFL017C YMR146C YOR036W YPL240C YFL038C YLL021W YOR212W YML114C YDR174W YLL019C YHR030C YNL135C YDR167W YIL113W YER052C YDR335W YKL161C YER111C YOR089C YPL089C YDR309C YGL161C YJL157C YLR229C YBL050W YJR022W YNL050C YLL028W YNR050C YHR141C YLR109W YMR138W YLR362W YBR155W YGL073W YER124C YMR186W YER040W YGR019W YLR432W YPR035W YHR198C YML064C YEL015W YLR284C YOL136C YJL203W YDL030W YHR055C YGL166W YBR072W YMR005W YER103W YHR053C YLR310C YNR053C YDR032C YNL098C YOL149W YDR277C YLR264W YOR167C YDL194W YER112W YBL026W YPR062W YNL312W YAR007C YPL111W YML032C YIL143C YNL036W YNL189W YDR311W YOL058W YDL236W YKL028W YIR009W YKR099W ? YLR377C YNL117W YNL164C YER133W YMR311C YDR323C YKR097W YDR146C YBR045C YPR010C YLR319C YCL032W YDR103W YMR117C YDR184C YLR452C YHR005C YER116C YPR145W YOR178C YDL013W YDL215C YDR100W YER054C YBR050C YOR315W YPR048W YGR203W YLR153C YJL089W YNL199C YIL061C YMR044W YOR355W YNL091W YER065C YGL153W YLR191W YJL030W YJL013C YGL229C YNL214W YDR142C YIL160C YGL106W YOR326W YNL154C YDR382W YFR014C YDL130W YKL204W YCL040W YGR048W YGR074W YEL041W YPL222W YBR043C YBR170C YHR115C YGL202W YOL016C YER079W YDL078C YHR179W YDR244W YGR014W YNL116W YPL211W YFL039C YHR135C YBR109C YGL208W YML007W YGR218W YGL115W YOR039W YJR109C YER110C YOR303W YER062C YJL036W YDL063C YML074C YNL113W YKL211C YMR058W YFR037C YMR291W YDL081C YPR110C YER090W YOR290C YLR340W YPL131W YER145C YJL190C YDL113C YPL201C YBL079W YOR204W YGL097W YBR118W YDL088C YLR293C YLR249W YAL003W YPR080W YOR310C YLR197W YIL074C YDL014W YLR214W YMR021C YKL001C YNL311C YPR124W YOR215C YER081W

Save image as pdf



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()