============================================================================== README: CYTOSCAPE file: /mnt/Vancouver/programming/cytoscape/_readme-cytoscape-victoria.txt last modified: 2019-08-13 ============================================================================== [victoria@victoria cytoscape]$ dpl Fri 02 Aug 2019 01:50:07 PM PDT /mnt/Vancouver/apps/cytoscape total 16 drwxr-xr-x 6 victoria victoria 4096 Jul 15 09:44 cytoscape-3.7.1 drwxr-xr-x 2 victoria victoria 4096 Aug 2 13:41 kegg drwxr-xr-x 2 victoria victoria 4096 May 27 20:28 src drwxr-xr-x 3 victoria victoria 4096 May 28 14:02 web [victoria@victoria cytoscape]$ yay -Ss cytoscape aur/cytoscape 3.7.1-1 (+11 0.36%) A software for visualizing molecular interaction networks and integration with gene expression profiles and other state data. ============================================================================== * GitHub: https://github.com/cytoscape * manual: http://manual.cytoscape.org/en/stable/index.html * Google group: https://groups.google.com/forum/#!forum/cytoscape-helpdesk * tutorials: https://github.com/miriamposner/cytoscape_tutorials ** Command Line Arguments: http://manual.cytoscape.org/en/stable/Command_Line_Arguments.html#command-line-arguments ** Node and Edge Column Data: http://manual.cytoscape.org/en/stable/Node_and_Edge_Column_Data.html#node-and-edge-column-data * https://cytoscape.org/manual/Cytoscape3_6_0Manual.pdf Lines in the SIF file specify a source node, a relationship type (or edge type), and one or more target nodes: nodeA nodeB nodeC nodeA nodeD nodeE nodeF nodeB nodeG ... nodeY nodeZ A more specific example is: node1 typeA node2 node2 typeB node3 node4 node5 node0 The first line identifies two nodes, called node1 and node2, and a single relationship between node1 and node2 of typetypeA. The second line specifies three new nodes, node3, node4, and node5; here “node2” refers to the same node asin the first line. The second line also specifies three relationships, all of type typeB and with node2 as the source, withnode3, node4, and node5 as the targets. This second form is simply shorthand for specifying multiple relationships ofthe same type with the same source node. The third line indicates how to specify a node that has no relationships withother nodes. This form is not needed for nodes that do have relationships, since the specification of the relationshipimplicitly identifies the nodes as well. Duplicate entries are ignored. Multiple edges between the same nodes must have different edge types. For example,the following specifies two edges between the same pair of nodes, one of type xx and one of type yy: node1 xx node2 node1 xx node2 node1 yy node2 Edges connecting a node to itself (self-edges) are also allowed: node1 xx node1 Every node and edge in Cytoscape has a name column. For a network defined in SIF format, node names should beunique, as identically named nodes will be treated as identical nodes. The name of each node will be the name in this file by default (unless another string is mapped to display on the node using styles). This is discussed in the section onStyles. The name of each edge will be formed from the name of the source and target nodes plus the interaction type:for example, sourceName (edgeType) targetName. The tag can be any string. Whole words or concatenated words may be used to define types of relationships, e.g. geneFusion, cogInference, pullsDown, activates, degrades, inactivates, inhibits, phosphorylates, upRegulates, etc. Some common interaction types used in the Systems Biology community are as follows: pp : protein - protein interaction pd : protein -> DNA (e.g. transcription factor binding upstream of a regulating gene.) Some less common interaction types used are: pr : protein -> reaction rc : reaction -> compound cr : compound -> reaction gl : genetic lethal relationship pm : protein-metabolite interactiob mp : metabolite-protein interaction ... ------------------------------------------------------------------------------ * UTILITIES: ------------ ** py2cytoscape : Python utilities for Cytoscape and Cytoscape.js ** Cytoscape automation: collection of scripts that include programmatic I/O and control of Cytoscape *** https://github.com/cytoscape/cytoscape-automation https://github.com/cytoscape/cytoscape-automation/wiki ## << this! *** https://github.com/cytoscape/cytoscape-automation/wiki#python-notebooks ** cyREST | cyclient : Cytoscape 3 access for external tools via a language agnostic RESTful API ** KEGGlincs : visualize all edges within a KEGG pathway and overlay LINCS data ** cyto_vis: send graph to Cytoscape via CyREST utility functions, to view the KEGG pathway in Cytoscape ** KEGGscape : Cytoscape app for importing KGML (KEGG pathway XML) ============================================================================== APPS ==== * Can install these within Cytoscape (Apps menu) or from Apps webpage (if Cytoscape instance running): ** explanation ---------------------------------------- * enhancedGraphics : passthrough mapper for charts and gradients (add charts to nodes; https://apps.cytoscape.org/apps/enhancedgraphics ** e.g.: file:///mnt/Vancouver/domains/PERSAGEN.com/2.0/files/misc/cytoscape-metabolome-profile.png ** e.g.: https://cytoscape.org/cytoscape-automation/for-scripters/R/notebooks/Custom-Graphics.nb.html#enhanced_graphics ---------------------------------------- * KEGGscape : file reader and pathway visualizer for KEGG XML (KGML) files https://apps.cytoscape.org/apps/keggscape ** You can import KEGG pathway [directly into!] Cytoscape by requesting the pathway ID. For example you can import http://www.genome.jp/dbget-bin/www_bget?eco00010 by requesting http://localhost:1234/keggscape/v1/eco00010 ---------------------------------------- * ReactomeFIPlugIn https://apps.cytoscape.org/apps/reactomefiplugin Explore Reactome pathways and search for diseases related pathways and network patterns using the Reactome functional interaction network. ... ReactomeFIViz (also called Reactome Cytoscape Plugin or ReactomeFIPlugIn) is designed to find pathways and network patterns related to cancer and other types of diseases. This plugin accesses the Reactome pathways stored in the database, help you to do pathway enrichment analysis for a set of genes, visualize hit pathways using manually laid-out pathway diagrams directly in Cytoscape, and investigate functional relationships among genes in hit pathways. The plugin can also access the Reactome Functional Interaction (FI) network, a highly reliable, manually curated pathway-based protein functional interaction network covering over 50% of human proteins, and allows you to construct a FI sub-network based on a set of genes, query the FI data source for the underlying evidence for the interaction, build and analyze network modules of highly-interacting groups of genes, perform functional enrichment analysis to annotate the modules, expand the network by finding genes related to the experimental data set, display pathway diagrams, and overlay with a variety of information sources such as cancer gene index annotations. ---------------------------------------- * ReNE: Regulatory Network Enhancing Plugin https://apps.cytoscape.org/apps/rene ** ReNE allows users to enhance standard KEGG/Reactome pathways with information regarding: Transcription Factors, Proteins and MicroRNAs. Such enhancement allows to better understand/inspect possible regulatory motifs which involve entities commonly not presented into pathways. ... ============================================================================== CYTOSCAPE.JS ============ * Cytoscape.js: http://js.cytoscape.org/#introduction ## replaces Cytoscape Web [deprecated: http://cytoscapeweb.cytoscape.org/] * py2cytoscape https://py2cytoscape.readthedocs.io/en/latest/ py2cytoscape is a collection of utilities to use Cytoscape and Cytoscape.js from Python. Network visualization feature is still limited in Python, but with this tool, you can access both of Cytoscape and Cytoscape.js as network visualization engines for your Python code! Data Conversion Utilities to/from Cytoscape.js JSON https://github.com/cytoscape/cytoscape-automation/tree/master/for-scripters * Loading JSON file into Cytoscape.js https://stackoverflow.com/a/41646474/1904943 Cytoscape desktop erroneously names the exported file with the extension .cyjs. It's just a JSON file, so rename it to .json. Just point Cytoscape.js to the particular parts of the JSON you want to use (when you call cytoscape( myOptions ). * [2014] How to export all graph data including [node] position info from Cytoscape.js graph? Load your network into Cytoscape 3.1.1 (or 3.2.0 nightly build) Apply layout, move nodes, edit styles, etc. Select File-->Export --> Network and View... Select .cyjs format and name your file Press OK. This generates a Cytoscape.js-readable JSON file including (x,y) position of nodes. Optionally, you can export Visual Styles into a JSON file and use it with the network JSON. By the way, if you need to export multiple network JSON files at once, you can use Cytoscape 3.2.0 nightly build and use "Export as Interactive Web Visualization" option. This generates web application from your networks. And in data folder, it has all of your networks in Cytoscape.js-style JSON. http://wiki.cytoscape.org/Cytoscape_3/UserManual/Publish OR, you can use cyREST: http://apps.cytoscape.org/apps/cyrest Install it from the App store and access the following URL using node.js, python, R, curl, web browser, etc. http://localhost:1234/v1/networks.json This generates array of your networks in Cytoscape.js compatible JSON. Note that both options require Java 7. ---------------------------------------- Thanks Kei for your reply, but my question is how to export data from graph in my web graph which was made via cytoscape js library (not cytoscape software). I want to export all node, edge data and their position in the graph. ---------------------------------------- That's simpler: http://js.cytoscape.org/#core/export/cy.json And this JSON can be used in BOTH cytoscape.js and Cytoscape desktop. * Introduction to py2cytoscape: Pythonista-friendly wrapper for cyREST https://nbviewer.jupyter.org/github/idekerlab/py2cytoscape/blob/develop/examples/New_wrapper_api_sample.ipynb https://github.com/cytoscape/py2cytoscape/blob/develop/examples/New_wrapper_api_sampl ## << this displays better * Using Cytoscape.js in Jupyter Notebook https://github.com/idekerlab/cy-rest-python/blob/f789203044b4dc870a8b63572a935f92fbd9b89d/basic/CytoscapeJS_visualization.ipynb ---------------------------------------- DATA CONVERSION UTILITIES FROM/TO Cytoscape.js JSON: http://js.cytoscape.org/ Cytoscape.js JSON is one of the standard data exchange formats in Cytoscape community. py2cytoscape includes some graph data conversion utilities for popular graph analysis packages in Python. Currently, the following graph objects are supported: NetworkX - From / To Cytoscape.js JSON igraph - From / To Cytoscape.js JSON pandas DataFrame - To Cytoscape.js JSON ------------------------------------------------------------------------------ DEMOS: * Cytoscape.js tutorial demo https://cytoscape.org/cytoscape.js-tutorial-demo/ https://github.com/cytoscape/cytoscape.js-tutorial-demo https://raw.githubusercontent.com/cytoscape/cytoscape.js-tutorial-demo/gh-pages/index.html ** includes genes data: https://github.com/cytoscape/cytoscape.js-tutorial-demo/blob/gh-pages/datasets/genes.json * Cola.js/Cytoscape.js demo graph of gene-gene interactions; uses Cola.js for layout & Cytoscape.js for graph model & visualisation https://js.cytoscape.org/demos/colajs-graph/ ** http://genemania.org/ http://genemania.org/search/homo-sapiens/brca1/fen1 ## pretty neat; based on: ** http://apps.cytoscape.org/apps/genemania * d3.js: ** cytoscape-d3 : Cytoscape to D3.js Exporter, a Cytoscape app for exporting network and data table to D3.js style JSON https://github.com/keiono/ https://github.com/keiono/cytoscape-d3 http://chianti.ucsd.edu/~kono/cy3js/d3-tree.html * Cytoscape.js Layout Demo http://www.cs.bilkent.edu.tr/~ivis/Cytoscape_LayoutDemo/# * CerebralWeb javascript layout plugin for Cytoscape.js https://www.innatedb.ca/CerebralWeb/ https://www.innatedb.ca/CerebralWeb/demos.php Provided by InnateDB.ca, a publicly available database of the genes, proteins, experimentally-verified interactions ## SFU | UBC! https://www.innatedb.ca/redirect.do?go=aboutIDB and signaling pathways involved in the innate immune response of humans, mice and bovines to microbial infection. * dash-cytoscape https://github.com/plotly/dash-cytoscape https://xinghanlu.com/projects/ Dash Cytoscape is a graph visualization component for creating easily customizable, high-performance, interactive, and web-based networks. It extends and renders Cytoscape.js, and offers deep integration with Dash layouts and callbacks, enabling the creation of powerful networks in conjunction with the rich collection of Dash components, as well as established computational biology and network science libraries such as BioPython and NetworkX. * http://www.wineandcheesemap.com/ ------------------------------------------------------------------------------ JAVASCRIPT * "onchange" event listener example (calls function) https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onchange_html "onclick" event listener --- buttons, text input fields ... http://embed.plnkr.co/O7mWEfZuIhhtahdAhsAM/ * cytoscape js selector demo https://codepen.io/yeoupooh/pen/BjWvRa * JS selectors [slide 16: https://co.mbine.org/events/COMBINE_2012/agenda?q=system/files/2012-08-17-combine-bader-franz-cytoscape.pdf] cy.$('node[weight > 50]{degree > 2}') ## [ ] for client-defined data; { } for metadata https://raw.githubusercontent.com/kzuberi/ipython-cytoscape.js/master/examples/no_widget.ipynb ============================================================================== ATTRIBUTES | LABELS | PROPERTIES ================================ * [2019-08-08] /mnt/Vancouver/programming/data/metabolism/practice/cytoscape/ I was only able to add one edge attribute, via the edge visual style "Tooltip" tool. The GitHub repo, below, apparently addresses this issue. * How to add html label to cytoscape graph node ## I believe this is how to add a URL to a node ... https://stackoverflow.com/questions/45658912/how-to-add-html-label-to-cytoscape-graph-node ** cytoscape-node-html-label https://github.com/kaluginserg/cytoscape-node-html-label ** Display more attributes per node/edge https://groups.google.com/forum/#!searchin/cytoscape-helpdesk/multiple$20attributes%7Csort:date/cytoscape-helpdesk/x4b76auy9SY/OIrEUeSJBAAJ How to add set label from different fields https://groups.google.com/forum/#!searchin/cytoscape-helpdesk/multiple$20columns%7Csort:date/cytoscape-helpdesk/4yfvZ5IGVq8/DXuFk_WuEAAJ ** How to Prepare Data for Import into Cytoscape (Version 3.2.1, released February 2015) https://ebeshero.github.io/thalaba/cytosc.html#dataImport "... In Cytoscape, information that describes qualities of particular nodes or edges is known as attribute data, and we can have node attributes and edge attributes. Your first import to Cytoscape will only submit the node, edge, and node columns, plus a column identified as "edge attributes." You may import, in a second stage, the attribute information about your nodes. We can write XSLT or XQuery to output text arrayed in columns with a separator, knowing that we can import data in tab-separated or comma-separated columns. I prepare a single text file containing all of my node data, node attribute data, edge data, edge attribute data, and connected node data and connected attribute data, and I use that file twice: once to initiate the network, and again to add node attribute data. ..." ** Node and Edge Column Data http://manual.cytoscape.org/en/stable/Node_and_Edge_Column_Data.html#node-and-edge-column-data Legacy Cytoscape Attributes Format http://manual.cytoscape.org/en/stable/Node_and_Edge_Column_Data.html#legacy-cytoscape-attributes-format ** Working with Attributes https://github.com/miriamposner/cytoscape_tutorials/blob/master/working-with-attributes.md ============================================================================== NETWORKS!!! :-O ================ * NDEx: https://www.ndexbio.org/#/ ## ability -- apparently -- to DIRECTLY import those to Cytoscape!! ** NDEx is an academic project, not-for-profit, open source and 100% FREE! ** https://www.ndexbio.org/#/search?searchType=All&searchString=genes&searchTermExpansion file:///mnt/Vancouver/projects/files/cytoscape_NDEx.png Mutations in Melanoma Genes Drugs Targeting Melanoma Genes Pathways Affected by Melanoma Genes CTD: Genes-Pathways Associations Drugs Targeting Melanoma Genes Pathways Affected by Melanoma Genes CTD: Chemicals-Genes Interactions ... ... ... ** NOTE: Firefox wouldn't let me open those in Cytoscape or even d/l them, but Opera did!! ** [R] Cytoscape and NDEx https://cytoscape.org/cytoscape-automation/for-scripters/R/notebooks/Cytoscape-and-NDEx.nb.html ------------------------------------------------------------------------------ REACTOME DATABASE: -------------------- * https://reactome.org/ * schema: https://reactome.org/content/schema/DatabaseObject * Cytoscape Reactome FI Example: https://github.com/reactome-fi/workflows/blob/master/CytoscapeReactomeFI.ipynb This example demonstrates a workflow using ReactomeFIViz CyREST API to perform a comparison pathway and network analysis for TCGA BRCA (breast invasive carcinoma) and OV (ovarian serous cystadenocarcinoma) mutation data. ** FIViz: Functional Interaction Vizualization: https://reactome.org/tools/reactome-fiviz The ReactomeFIViz app is designed to find pathways and network patterns related to cancer and other types of diseases. This app accesses the Reactome pathways stored in the database, help you to do pathway enrichment analysis for a set of genes, visualize hit pathways using manually laid-out pathway diagrams directly in Cytoscape, and investigate functional relationships among genes in hit pathways. ... ** https://reactome.org/tools/reactome-fiviz#Download_and_Launch_ReactomeFIViz ReactomeFIViz app 6 needs Cytoscape 3.7.0 or above. If you have not installed Cytoscape 3.7.0 or above, please download it from Cytoscape's web site: http://www.cytoscape.org. After launching Cytoscape, use menu "Apps/App Manager" to open the "App Manager" dialog, and search for "ReactomeFI". You should see the ReactomeFIViz app listed in the middle panel (See the Figure below. You may see a different version number. Note: The listed name of this app is "ReactomeFIPlugIn", which is the original name of the app.). Choose the app, and then click the "Install" button at the bottom of the dialog. Follow the procedures to finish the installation. ... ============================================================================== KEGG ==== * NOTE re: KGML files -- (Glycolysis / Gluconeogenesis) available here ## genome.jp https://www.genome.jp/kegg-bin/show_pathway?hsa00010 [ Pathway menu | Organism menu | Pathway entry | ***DOWNLOAD KGML*** | Show description | User data mapping ] not here ## kegg.jp https://www.kegg.jp/kegg-bin/show_pathway?org_name=hsadd&mapno=00010&mapscale=&show_description=show [ Pathway menu | Hide description | Disease/drug list | User data mapping ] ------------------------------------------------------------------------------ 2019-08-02 Downloaded Glycolysis/Gluconeogenesis - Homo sapiens (human) KGML file https://www.kegg.jp/kegg-bin/download?entry=hsa00010&format=kgml to /mnt/Vancouver/apps/cytoscape/kegg/hsa00010-glycolysis.kgml Cytoscape >> File menu >> Import >> Network from file >> [select above .kgml XML file] >> Create new network collection | check: Import pathway details from KEGG database >> OK file:///mnt/Vancouver/projects/files/cytoscape-glycolysis_kgml_import-2019.08.02a.png Imports that pathway into Cytoscape!! :-D Saved as Cytoscape session /mnt/Vancouver/apps/cytoscape/sessions/kegg-hsa00010-glycolysis-human.cys file:///mnt/Vancouver/projects/files/cytoscape-glycolysis_kgml_import-2019.08.02b.png ============================================================================== py2cytoscape ============ GitHub: https://github.com/cytoscape/py2cytoscape ## Python utilities for Cytoscape and Cytoscape.js intro: https://github.com/cytoscape/cytoscape-automation/tree/master/for-scripters/Python https://github.com/cytoscape/cytoscape-automation/blob/master/for-scripters/Python/basic-fundamentals.ipynb docs: https://py2cytoscape.readthedocs.io/en/latest/ demo: https://github.com/cytoscape/cytoscape-automation/blob/master/for-scripters/Python/basic-feature-demos.ipynb https://github.com/cytoscape/cytoscape-automation/blob/master/for-scripters/Python/advanced-cancer-networks-and-data.ipynb ## + cytoscape-automation Introduction to py2cytoscape: Pythonista-friendly wrapper for cyREST https://nbviewer.jupyter.org/github/idekerlab/py2cytoscape/blob/develop/examples/New_wrapper_api_sample.ipynb https://github.com/cytoscape/py2cytoscape/blob/develop/examples/New_wrapper_api_sample.ipynb ## << this displays better CyREST: Turbocharging Cytoscape Access for External Tools via a RESTful API [2015] https://f1000research.com/articles/4-478/v1 ------------------------------------------------------------------------------ Cytoscape automation: https://github.com/cytoscape/cytoscape-automation ## Collection of scripts that include programmatic I/O and control of Cytoscape https://github.com/cytoscape/cytoscape-automation/wiki Resources are organized into categories below, leveraging R and Python libraries: * RCy3 package * py2cytoscape utility * Python Notebooks (https://github.com/cytoscape/cytoscape-automation/wiki#python-notebooks) -- includes ** Network Assisted Genomic Analysis (NAGA): https://github.com/shfong/naga/blob/master/notebooks/tutorial.ipynb Re-prioritizes significant single nucleotide polymorphisms (SNPs) to genes using network diffusion methods including random walk and heat diffusion. ** Cytoscape Reactome FI Example: https://github.com/reactome-fi/workflows/blob/master/CytoscapeReactomeFI.ipynb This example demonstrates a workflow using ReactomeFIViz CyREST API to perform a comparison pathway and network analysis for TCGA BRCA (breast invasive carcinoma) and OV (ovarian serous cystadenocarcinoma) mutation data https://github.com/cytoscape/cytoscape-automation/blob/master/for-scripters/Python/advanced-cancer-networks-and-data.ipynb ## << fabulous demo!!! https://docs.google.com/document/d/1QTrT-9ylhI4OX5DkauMo2ujLIqeg3WDUDwl77KLtfVY/edit https://f1000research.com/articles/7-822/v2 Copycat Layout: Network layout alignment via Cytoscape Automation The copycatLayout app is a network-based visual differential analysis tool that improves upon the existing layoutSaver app and is delivered pre-installed with Cytoscape, beginning with v3.6.0. LayoutSaver cloned a network layout by mapping node locations from one network to another based on node attribute values, but failed to clone view scale and location, and provided no means of identifying which nodes were successfully mapped between networks. Copycat addresses these issues and provides additional layout options. With the advent of Cytoscape Automation (packaged in Cytoscape v3.6.0), researchers can utilize the Copycat layout and its output in workflows written in their language of choice by using only a few simple REST calls. Copycat enables researchers to visually compare groups of homologous genes,generate network comparison images for publications, and quickly identify differences between similar networks at a glance without leaving their script. With a few extra REST calls, scripts can discover nodes present in one network but not in the other, which can feed into more complex analyses (e.g.,modifying mismatched nodes based on new data, then re-running the layout to highlight additional network changes). ======================================== py2cytoscape INSTALLATION ========================= Latest stable release: pip3 install py2cytoscape Development version: pip3 install git+https://github.com/cytoscape/py2cytoscape.git https://github.com/cytoscape/py2cytoscape/issues/81 https://github.com/cytoscape/py2cytoscape#installation http://localhost:1234/v1/ ------------------------------------------------------------------------------ py2cytoscape is a collection of utilities to use Cytoscape and Cytoscape.js from Python. ... We want to introduce cy2cytoscape [typo: they mean py2cytoscape!], along with cyREST and Jupyter Notebook ... py2cytoscape depends on python-igraph and optionally depends on scipy. ... cyREST is a language-agnostic RESTful API for Cytoscape 3. Of course you can drive Cytoscape by calling raw RESTful API using requests or other http client library, but with this wrapper, you can significantly reduce your lines of code: from py2cytoscape.data.cyrest_client import CyRestClient cy = CyRestClient() network = cy.network.create(name='My Network', collection='My network collection') print(network.get_id()) ---------------------------------------- https://stackoverflow.com/questions/54411663/py2cytoscape-automate-saving-view [Mar 2019] There have been small changes with Cytoscape 3.7.1. Please install py2cytoscape from the development branch pip uninstall py2cytoscape pip install git+https://github.com/cytoscape/py2cytoscape.git --user ## Victoria: don't need "--user" and then use cytoscape.view.export(options="PDF", outputFile="FILENAME") ======================================== cyREST | cyclient ================= Cytoscape Access for External Tools via a RESTful API GitHub: https://github.com/idekerlab/cy-rest-python ## cyREST examples for Python users intro: https://nbviewer.jupyter.org/github/idekerlab/py2cytoscape/blob/develop/examples/New_wrapper_api_sample.ipynb demos: https://github.com/idekerlab/cy-rest-python/blob/develop/index.ipynb https://nbviewer.jupyter.org/github/idekerlab/cy-rest-python/blob/develop/advanced/CytoscapeREST_KEGG_time_series.ipynb Welcome to cyREST Examples for Python Users! https://nbviewer.jupyter.org/github/idekerlab/cy-rest-python/blob/develop/index.ipynb A CyREST client: cyclient(host="localhost", port=1234, version="V1") host CyREST host server address. default='localhost' port CyREST port number. default=1234 version CyREST version. default='v1' returns status a cyclient object. cyclient.status() ## checks the status of your CyREST server. cyclient.version() ## checks Cytoscape version. cyclient.copy() ## creates a copy of the cyclient object. [ ... SNIP! ... ] >>> from py2cytoscape import cyrest >>> ## cytoscape=cyrest.cyclient() >>> cy=cyrest.cyclient() >>> cy >>> cy.status() CyREST online! >>> cy.version() apiVersion v1 cytoscapeVersion 3.7.1 >>> cy2=cy.copy() >>> cy2 ============================================================================== py2cytoscape SESSION [2019-07-06] ================================= [Python 3.7 (py37 | p37) venv:] (py37) [victoria@victoria networkx]$ d Fri 05 Jul 2019 11:46:55 AM PDT (py37) [victoria@victoria networkx]$ python --version Python 3.7.3 ## pip IS pip3 (py37) [victoria@victoria networkx]$ pip install git+https://github.com/cytoscape/py2cytoscape.git Collecting git+https://github.com/cytoscape/py2cytoscape.git [ ... snip ... ] Successfully built py2cytoscape pydotplus Installing collected packages: pydot, pydotplus, py2cytoscape Successfully installed py2cytoscape-0.7.1 pydot-1.4.1 pydotplus-2.0.2 (py37) [victoria@victoria networkx]$ P Python 3.7.3 (default, Jun 24 2019, 04:54:02) [GCC 9.1.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import scipy >>> import numpy >>> import py2cytoscape ## https://py2cytoscape.readthedocs.io/en/latest/ >>> from py2cytoscape.data.cyrest_client import CyRestClient >>> cy = CyRestClient() Traceback (most recent call last): [ ... snip ... ] requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=1234): Max retries exceeded with url: /v1/styles/visualproperties (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')) ## SOLUTION: start Cytoscape desktop client! >>> cy = CyRestClient() >>> cy.version() Traceback (most recent call last): File "", line 1, in >>> from py2cytoscape import cyrest ## https://github.com/cytoscape/cytoscape-automation/blob/master/for-scripters/Python/advanced-cancer-networks-and-data.ipynb >>> cytoscape=cyrest.cyclient() >>> cytoscape.version() apiVersion v1 cytoscapeVersion 3.7.1 ## In Cytoscape >> Apps >> ... install StringApp >>> from py2cytoscape.cyrest.base import api ## Takes ~5 sec; auto opens in Cytoscape: ## file:///mnt/Vancouver/projects/files/cytoscape-automation-2019.07.05a.png >>> api(namespace="string",command="disease query",PARAMS={"disease":"breast cancer","cutoff":"0.9", "species":"Homo sapiens","limit":"150"}) {'SUID': 1184} >>> cytoscape.network.list() {'networks': [1184, 52]} >>> cytoscape.layout.circular() >>> print(cytoscape.commands.namespace("layout")) Available commands for 'layout': apply preferred attribute-circle attributes-layout circular copycat cose degree-circle force-directed fruchterman-rheingold get preferred grid hierarchical isom kamada-kawai set preferred stacked-node-layout >>> cytoscape.layout.force_directed(defaultSpringCoefficient=".000004", defaultSpringLength="5") >>> print(cytoscape.commands.command("layout","force-directed")) Available arguments for 'layout force-directed': defaultEdgeWeight defaultNodeMass defaultSpringCoefficient defaultSpringLength edgeAttribute isDeterministic maxWeightCutoff minWeightCutoff network nodeAttribute nodeList numIterations singlePartition type >>> cytoscape.node.list_attributes() ['SUID', 'shared name', 'name', 'selected', 'canonical name', 'display name', 'full name', 'database identifier', 'description', '@id', 'namespace', 'node type', 'query term', 'sequence', 'species', 'STRING style', 'enhancedLabel Passthrough', 'canonical', 'compartment cytoskeleton', 'compartment cytosol', 'compartment endoplasmic reticulum', 'compartment golgi apparatus', 'compartment mitochondrion', 'compartment nucleus', 'compartment plasma membrane', 'image', 'target development level', 'target family', 'tissue adrenal gland', 'tissue blood', 'tissue bone', 'tissue bone marrow', 'tissue eye', 'tissue gall bladder', 'tissue heart', 'tissue intestine', 'tissue kidney', 'tissue liver', 'tissue lung', 'tissue muscle', 'tissue nervous system', 'tissue pancreas', 'tissue saliva', 'tissue skin', 'tissue spleen', 'tissue stomach', 'tissue thyroid gland', 'tissue urine', 'disease score'] >>> disease_score_table=cytoscape.table.getTable(columns=['disease score'],table='node') >>> disease_score_table.head() disease score 9606.ENSP00000309913 2.998750 9606.ENSP00000349016 2.998750 9606.ENSP00000221992 2.569643 9606.ENSP00000322457 3.291596 9606.ENSP00000265171 2.937734 >>> import seaborn as sns Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'seaborn' ## (needed to "pip install seaborn" in another py37 venv session) >>> import seaborn as sns >>> sns.set_style("white") >>> sns.kdeplot( disease_score_table["disease score"] ) >>> import matplotlib >>> import matplotlib.pyplot as plt >>> plt.xlabel("disease score") Text(0.5, 0, 'disease score') >>> plt.ylabel("frequency") Text(0, 0.5, 'frequency') >>> plt.show() ## file:///mnt/Vancouver/projects/files/cytoscape-automation-2019.07.05b.png >>> top_quart=disease_score_table[["disease score"]].quantile(0.75)[0] >>> top_quart 3.64357375 >>> top_nodes=disease_score_table[disease_score_table["disease score"]>top_quart].index.tolist() >>> top_nodes ['9606.ENSP00000261769', '9606.ENSP00000369497', '9606.ENSP00000405330', '9606.ENSP00000372023', '9606.ENSP00000352271', '9606.ENSP00000342235', '9606.ENSP00000369816', '9606.ENSP00000441765', '9606.ENSP00000260947', '9606.ENSP00000265433', '9606.ENSP00000295736', '9606.ENSP00000324856', '9606.ENSP00000451974', '9606.ENSP00000371194', '9606.ENSP00000261584', '9606.ENSP00000424328', '9606.ENSP00000336701', '9606.ENSP00000451828', '9606.ENSP00000325120', '9606.ENSP00000278616', '9606.ENSP00000363804', '9606.ENSP00000269571', '9606.ENSP00000259008', '9606.ENSP00000309572', '9606.ENSP00000219746', '9606.ENSP00000418960', '9606.ENSP00000351273', '9606.ENSP00000382423', '9606.ENSP00000379683', '9606.ENSP00000410294', '9606.ENSP00000263967', '9606.ENSP00000275493', '9606.H19', '9606.ENSP00000372088', '9606.ENSP00000269305', '9606.ENSP00000361021', '9606.ENSP00000303939', '9606.ENSP00000227507'] ## [ ... SNIP! ... ] FABULOUS!! https://github.com/cytoscape/cytoscape-automation/blob/master/for-scripters/Python/advanced-cancer-networks-and-data.ipynb >>> [Ctrl-D] (py37) [victoria@victoria networkx]$ ============================================================================== ============================================================================== KEGG IN {CYTOSCAPE | R} ============================================================================== ============================================================================== https://rdrr.io/search?q=cytoscape ============================================================================== KEGGlincs ========= * https://rdrr.io/bioc/KEGGlincs/ KEGGlincs: : visualize all edges within a KEGG pathway and overlay LINCS data * https://rdrr.io/bioc/KEGGlincs/man/cyto_vis.html cyto_vis: Send graph to Cytoscape via CyREST ** View the KEGG pathway in Cytoscape. With either the 'expanded edges' or 'stacked nodes' layout, users can visualize and interact with the graphs [strictly] as they are documented in the most recent KGML available from KEGG. This function is a modified version of the function send2cy(), which is part of the cyREST utility functions. ** Script: https://rdrr.io/bioc/KEGGlincs/man/cyto_vis.html /mnt/Vancouver/programming/R/scripts/kegg_p53_signaling.R ======================================== KEGGlincs INSTALLATION [2019-07-06] =================================== https://bioconductor.org/packages/release/bioc/html/KEGGlincs.html install.packages("BiocManager") ## https://cran.r-project.org/web/packages/BiocManager/index.html BiocManager::install("KEGGlincs") ## LONG install (gcc ...) R:> install.packages("BiocManager") trying URL 'http://cran.stat.sfu.ca/src/contrib/BiocManager_1.30.4.tar.gz' Content type 'application/x-gzip' length 242304 bytes (236 KB) downloaded 236 KB * installing *source* package 'BiocManager' ... ** package 'BiocManager' successfully unpacked and MD5 sums checked ** using staged installation ** R ** inst ** byte-compile and prepare package for lazy loading ** help *** installing help indices ** building package indices ** installing vignettes ** testing if installed package can be loaded from temporary location ** testing if installed package can be loaded from final location ** testing if installed package keeps a record of temporary installation path * DONE (BiocManager) The downloaded source packages are in '/tmp/RtmpVpk0e2/downloaded_packages' R:> BiocManager::install("KEGGlincs") Bioconductor version 3.9 (BiocManager 1.30.4), R 3.6.1 (2019-07-05) Installing package(s) 'BiocVersion', 'KEGGlincs' also installing the dependencies 'assertthat', 'bit', 'prettyunits', 'digest', 'sys', 'zlibbioc', 'bit64', 'blob', 'memoise', 'BH', 'plogr', 'bitops', 'askpass', 'XVector', 'BiocGenerics', 'Biobase', 'IRanges', 'DBI', 'RSQLite', 'S4Vectors', 'graph', 'RCurl', 'magrittr', 'pkgconfig', 'Rcpp', 'curl', 'jsonlite', 'mime', 'openssl', 'R6', 'png', 'Biostrings', 'KOdata', 'hgu133a.db', 'org.Hs.eg.db', 'AnnotationDbi', 'KEGGgraph', 'igraph', 'plyr', 'gtools', 'httr', 'RJSONIO', 'KEGGREST', 'XML' [ ... SNIP! ... ] * DONE (KEGGlincs) The downloaded source packages are in '/tmp/RtmpVpk0e2/downloaded_packages' R:> browseVignettes("KEGGlincs") starting httpd help server ... done ## http://127.0.0.1:26205/library/KEGGlincs/doc/Example-workflow.html R:> ------------------------------------------------------------------------------ SCRIPT: https://rdrr.io/bioc/KEGGlincs/man/cyto_vis.html /mnt/Vancouver/programming/R/scripts/kegg_p53_signaling.R ## R: library(KEGGlincs) p53_KGML <- get_KGML("hsa04115") p53_KEGG_mappings <- expand_KEGG_mappings(p53_KGML, FALSE) nodes <- node_mapping_info(p53_KEGG_mappings) p53_edges <- expand_KEGG_edges(p53_KGML, p53_KEGG_mappings) edges <- edge_mapping_info(p53_edges) p53_graph_object <- get_graph_object(nodes, edges) ## Not run: # cyto_vis(graph_object, title = "Cytoscape Graph Window", edge_width_attribute = "summary_score", port.number = 1234) cyto_vis(p53_graph_object, "Default p53 Graph [no data added]") #Workflow to visualize graph with data-dependent attributes: p53_KGML <- get_KGML("hsa04115") p53_KEGG_mappings <- expand_KEGG_mappings(p53_KGML) nodes <- node_mapping_info(p53_KEGG_mappings) p53_edges <- expand_KEGG_edges(p53_KGML, p53_KEGG_mappings) p53_HA1E_data <- overlap_info(p53_KGML, p53_KEGG_mappings, "HA1E", data_type = "100_bing") p53_edges_plus_data <- add_edge_data(p53_edges, p53_KEGG_mappings, p53_HA1E_data, c(3, 10,12), only_mapped = TRUE) edges <- edge_mapping_info(p53_edges_plus_data, data_added = TRUE) p53_plus_data_graph_object <- get_graph_object(nodes, edges) cyto_vis(p53_plus_data_graph_object, "p53 Graph: Mapped Edges + HA1E Data", edge_width_attribute = "UP") ## End(Not run) ---------------------------------------- # Execution: # directly: /mnt/Vancouver/programming/R/scripts/kegg_p53_signaling.R # R shell: source("/mnt/Vancouver/programming/R/scripts/kegg_p53_signaling.R") # NOTE: Cytoscape must be running for cyto_vis() instance to instantiate ... ======================================== KEGGlincs SESSION [2019-07-06] ============================== R:> browseVignettes("KEGGlincs") starting httpd help server ... done ## http://127.0.0.1:26205/library/KEGGlincs/doc/Example-workflow.html http://127.0.0.1:26205/library/KEGGlincs/doc/Example-workflow.html R:> FoxO_KGML <- get_KGML("hsa04068") R:> # Information from KGML can be accessed using the following syntax: R:> slot(FoxO_KGML, "pathwayInfo") [ Title ]: FoxO signaling pathway [ Name ]: path:hsa04068 [ Organism ]: hsa [ Number ] :04068 [ Image ] :http://www.kegg.jp/kegg/pathway/hsa/hsa04068.png [ Link ] :http://www.kegg.jp/kegg-bin/show_pathway?hsa04068 R:> # View the original pathway image (get address for pathway with active links): R:> slot(slot(FoxO_KGML, "pathwayInfo"), "image") [1] "http://www.kegg.jp/kegg/pathway/hsa/hsa04068.png" R:> # Download a static pathway image (png file) to working directory: R:> image_link <- slot(slot(FoxO_KGML, "pathwayInfo"), "image") R:> download.file(image_link, basename(image_link), mode = "wb") trying URL 'http://www.kegg.jp/kegg/pathway/hsa/hsa04068.png' Content type 'image/png' length 36405 bytes (35 KB) downloaded 35 KB R:> getwd() [1] "/mnt/Vancouver/programming/data/metabolism/practice/networkx" R:> ls() [1] "edges" "FoxO_KGML" "image_link" "library" "nodes" "p53_edges" [7] "p53_edges_plus_data" "p53_graph_object" "p53_HA1E_data" "p53_KEGG_mappings" "p53_KGML" "p53_plus_data_graph_object" R:> dir() [1] "_networkx_notes.txt" "docs" "glycolysis_nodes_xy.tsv" "glycolysis_nodes_xy2_reversed_y.tsv" [5] "glycolysis+tca.tsv" "holoview_(bokeh)_practice" "hsa04068.png" "mpldatacursor" [9] "networkx_practice-03.py" "networkx_practice-hover-follow-cursor.py" "pyvis" "test05.csv" [13] "test05.tsv" "test05+code.tsv" "versions" ============================================================================== KEGGscape ========= * http://keggscape.readthedocs.org/ A Cytoscape app for importing KGML (KEGG pathway XML) * How to import KEGG pathway xml (kgml) to Cytoscape https://keggscape.readthedocs.io/en/latest/howtouse.html * A guide to exploring KEGG pathways with KEGGscape https://keggscape.readthedocs.io/en/latest/index.html ** KEGGscape (Ideker lab) constructs KEGG pathway on Cytoscape3 https://github.com/idekerlab/KEGGscape ** https://github.com/idekerlab/KEGGscape#tutorials TUTORIALS! *** https://github.com/idekerlab/KEGGscape/wiki/Visualizing-Time-Series-Metabolome-Profiles [2014; within Cytoscape] Visualizing Time Series Metabolome Profiles [Jupyter notebook] https://nbviewer.jupyter.org/github/idekerlab/cy-rest-python/blob/develop/advanced/CytoscapeREST_KEGG_time_series.ipynb *** https://keggscape.readthedocs.io/en/latest/drugtarget.html#mapping-drug-targets-on-kegg-pathway Mapping drug targets on KEGG pathway * QUESTION: ARE KEGG XML (KGML) FILES MISSING FROM WEBSITE? https://www.biostars.org/p/160077/ https://www.biostars.org/p/202663/ https://www.biostars.org/p/71737/ https://www.biostars.org/p/57344/ http://onetipperday.sterding.com/2018/06/download-all-kegg-pathway-kgml-files.html [https://github.com/widdowquinn/KGML << deprecated; refers to:] https://github.com/biopython/biopython https://nbviewer.jupyter.org/github/widdowquinn/notebooks/blob/master/Biopython_KGML_intro.ipynb ## << cool; some comments in: https://github.com/biopython/biopython/issues/1510 ** NOTE re: KGML files -- (Glycolysis / Gluconeogenesis) available here ## genome.jp https://www.genome.jp/kegg-bin/show_pathway?hsa00010 [ Pathway menu | Organism menu | Pathway entry | ***DOWNLOAD KGML*** | Show description | User data mapping ] not here ## kegg.jp https://www.kegg.jp/kegg-bin/show_pathway?org_name=hsadd&mapno=00010&mapscale=&show_description=show [ Pathway menu | Hide description | Disease/drug list | User data mapping ] ------------------------------------------------------------------------------ ============================================================================== LITERATURE ========== * Analysis of Triplet Motifs in Biological Signed Oriented Graphs Suggests a Relationship Between Fine Topology and Function https://arxiv.org/pdf/1803.06520.pdf Cytoscape App Store: http://apps.cytoscape.org/apps/counttriplets The Cytoscape CountTriplets app counts triplets and computes z-scores against randomly generated networks. In addition, it plots significance profiles and lists motifs for each node in the network reporting in a separate column the functional class the protein (node) belongs to (Transcription factor, receptor, phosphatase, kinase) which can be used in further statistical and machine learning studies. ============================================================================== WEB === * Amazing visualizations, including 3D: ** https://news.ycombinator.com/item?id=18527104 *** https://github.com/anvaka/pm https://anvaka.github.io/pm/#/?_k=9kvbgq ============================================================================== ============================================================================== END OF FILE ============================================================================== ==============================================================================