Overview of py4cytoscape¶
py4cytoscape is a Python package that communicates with Cytoscape via its REST API, providing access to a set over 250 functions that enable control of Cytoscape from within standalone and Notebook Python programming environments. It provides nearly identical functionality to RCy3, an R package in Bioconductor available to R programmers.
py4cytoscape provides:
functions that can be leveraged from Python code to implement network biology-oriented workflows;
access to user-written Cytoscape Apps that implement Cytoscape Automation protocols;
logging and debugging facilities that enable rapid development, maintenance, and auditing of Python-based workflow;
two-way conversion between the igraph and NetworkX graph packages, which enables interoperability with popular packages available in public repositories (e.g., PyPI); and
the ability to painlessly work with large data sets generated within Python or available on public repositories (e.g., STRING and NDEx);
execute Python code on the Cytoscape workstation or in Jupyter Notebooks on local or remote servers.
With py4cytoscape, you can leverage Cytoscape to:
load and store networks in standard and nonstandard data formats;
visualize molecular interaction networks and biological pathways;
integrate these networks with annotations, gene expression profiles and other state data;
analyze, profile, and cluster these networks based on integrated data, using new and existing algorithms.
py4cytoscape enables an agile collaboration between powerful Cytoscape, Python libraries, and novel Python code so as to realize auditable, reproducible and sharable workflows.
Look to the Tutorials section to get started with py4cytoscape.
Look to the Install section for installation instructions.
Look to the Reference section to see details on py4cytoscape functions.
Look to the Concepts section to see read about important py4cytoscape topics, including how to use py4cytoscape from a Jupyter Notebook running on a remote server.
Note that py4cytoscape and RCy3 functions implement a common interface called the Cytoscape Automation API Definition.
Audience¶
The audience for py4cytoscape includes biologists, mathematicians, physicists, biologists, computer scientists, and social scientists. A running sample of research based on Cytoscape can be found on Tumblr. Cytoscape provides tutorials, videos, and automation vignettes.
Google Scholar reports that Cytoscape was cited in over 10,000 in academic papers in 2019, most of which executed Cytoscape via the traditional mouse and keyboard. py4cytoscape can automate these results as a means of achieving reproducible science.
Python¶
Python is a powerful programming language that allows simple and flexible representations of networks as well as clear and concise expressions of network algorithms. Python has a vibrant and growing ecosystem of packages that can be used in combination with py4cytoscape to integrate with traditional workflow engines (e.g., Gene Pattern and Galaxy) to produce robust end-to-end workflows.
In order to make the most out of py4cytoscape you should know how to write basic programs in Python. Among the many guides to Python, we recommend the Python documentation and Python in a Nutshell.
Free Software¶
py4cytoscape is free software; you can redistribute it and/or modify it under the terms of the License. We welcome contributions. Join us on GitHub.
History¶
The original Python libraries for Cytoscape were written by Keiichiro Ono in 2015 as an interface to the then-new CyREST automation interface. Its original name was py2cytoscape. It was further evolved through 2019 by Kozo Nishida and Jorge Bouças.
In late 2019, py4cytoscape was undertaken by Barry Demchak as a replacement for py2cytoscape. It implemented the API defined by RCy3, an R package in Bioconductor developed by a Cytoscape Automation working group consisting of Alex Pico (primary author), Mark Grimes, Julia Gustavsen, Shraddha Pai, Ruth Isserlin, and Barry Demchak. RCy3 was based on prior work contributed by Paul Shannon, Tanja Muetze, Georgi Kolishkovski and Keiichiro Ono.
We intend to keep the function definitions available through py4cytoscape and RCy3 consistent and synchronized going forward, and to re-integrate unique features found only in py2cytoscape. This common interface is called the Cytoscape Automation API Definition.
Documentation¶
- Release
0.0.9
- Date
Jun 03, 2021
Install¶
Note
This section pertains to executing Python from a command line, with the Python program importing py4cytoscape
and then using its functions to call Cytoscape. If you intend to run Python in a Jupyter Notebook instead,
the installation instructions are much simpler, and can be found in the
Jupyter Notebook section of the
Concepts chapter. The section below doesn’t apply to you.
py4cytoscape
requires Python 3.6 or later. If you do not already
have a Python environment configured on your computer, please see the
instructions for installing the full scientific Python stack.
Note
If you are on Windows and want to install optional packages (e.g., scipy), then you will need to install a Python distributions such as Anaconda, Enthought Canopy, Python(x,y), WinPython, or Pyzo. If you use one of these Python distribution, please refer to their online documentation.
PyCharm and other integrated development environments often install their own Python distributions.
Below we assume you have a suitable Python environment already configured on
your computer and you intend to install py4cytoscape
inside of it. If you want
to create and work with Python virtual environments, please follow instructions
on venv and virtual
environments.
First, make sure you have the latest version of pip
(the Python package manager)
installed. If you do not, refer to the Pip documentation and install pip
first.
Cytoscape Prerequisite¶
To exercise py4cytoscape
, you must first have downloaded, installed, and
executed Cytoscape. If you have not already done this, please refer to the Launching
Cytoscape
instructions.
Note
These instructions assume Cytoscape and py4cytoscape
are running on the same
workstation or virtual machine. py4cytoscape
communicates with Cytoscape
via a localhost (127.0.0.1) connection, which precludes py4cytoscape
from
accessing Cytoscape remotely.
To overcome this limitation, you can execute your Python/py4cytoscape
workflow
on a remote Jupyter Notebook server (e.g., Google Colab
or GenePattern Notebook)
as described in
the Jupyter Notebook section.
Install the latest version (Python Console)¶
Install the current release of py4cytoscape
with pip
:
pip install python-igraph requests pandas networkx
pip install py4cytoscape
Install the development version (Python Console)¶
To install the latest py4cytoscape development version, instead
of pip install py4cytoscape
, use:
pip install python-igraph requests pandas networkx
git clone git://github.com/cytoscape/py4cytoscape
Verify Cytoscape connection¶
To verify that py4cytoscape
is properly installed and able to communicate with
Cytoscape, execute the following in a Python Console (after starting Cytoscape):
import py4cytoscape as py4
dir(py4)
py4.cytoscape_ping()
py4.cytoscape_version_info()
This will import py4cytoscape
into the Python namespace, print a (long) list
of py4cytoscape
entrypoints, and then demonstrate a connection to Cytoscape
by collecting Cytoscape information.
Testing (command line)¶
py4cytoscape
uses the Python unittest
testing package. You can learn more
about unittest
on its homepage.
To execute tests from an OS command line, set the current directory to
the py4cytoscape
package directory. Then, establish the execution environment:
cd py4cytoscape
cd tests
set PYTHONPATH=..
Note
You must start Cytoscape before executing any tests.
Executing just a sanity test takes only a few minutes:
runsanitytests.bat
You should be able to see Cytoscape load small networks and manipulate them.
Deep testing (command line)¶
The main py4cytoscape
test suite consists of a number of sub-suites. Executing all
of them can take an hour or two, depending on your workstation.
To execute all tests that don’t require user interaction, establish the environment (if you haven’t already done so):
cd py4cytoscape
cd tests
set PYTHONPATH=..
Note
You must start Cytoscape before executing any tests.
Run all test sub-suites:
runalltests.bat
Note that runalltests
executes without any console output. Instead, it sends normal console
output to the cons
file, and standard error output to the err
file. The err
contains normal test failures, but also contains a summary report of any failures once
all tests have been run.
Executing one or two tests is relatively quick. To execute a single sub-suite
(e.g., test_apps.py
):
python -m unittest test_apps.py
To execute more than one sub-suite (e.g., test_apps.py
and test_filters.py
):
python -m unittest test_apps.py test_filters.py
To execute all sub-suites:
python -m unittest
To execute a single test (e.g., test_get_app_information) in a single sub-suite:
python -m unittest test_apps.AppsTests.test_get_app_information
Note
To send test output to a file, redirect stderr and console:
python -m unittest 2>stderr.log 1>cons.log
Note
Some tests require console input, and without console prompts, the tests will appear to stall. To avoid executing such tests, set the PY4CYTOSCAPE_SKIP_UI_TESTS environment variable described below.
Note
To execute tests with less console debug output, set this environment variable before executing tests:
set PY4CYTOSCAPE_SUMMARY_LOGGER=FALSE
To further configure logging, see the Logging file.
Note
To execute tests without showing test names as tests execute, set this environment variable before executing the tests:
set PY4CYTOSCAPE_SHOW_TEST_PROGRESS=FALSE
Note
To skip execution of tests that require user input, set this environment variable before executing tests:
set PY4CYTOSCAPE_SKIP_UI_TESTS=TRUE
Note
When executing a large number of tests, we recommend that all three environment variables be set as described above.
Note
When executing tests in PyCharm, you can set environment
variables using the Run | Edit Configurations...
menu item.
Tutorials¶
You can try the following tutorials with Cytoscape Desktop + Google Colab.
Install Cytoscape in your local desktop environment and launch it.
Install FileTransfer App with Cytoscape App Manager (by clicking the
Apps
in the Cytoscape menu bar ->App Manager
..)

Click on the following Colab link for the tutorial you would like to try.
01. Overview of py4cytoscape ~25 min
Read only docs (of the above notebook for Colab)¶
Overview of py4cytoscape¶
by Kozo Nishida, Alexander Pico, Tanja Muetze, Georgi Kolishovski, Paul Shannon, Barry Demchak
Package
py4cytoscape 0.0.8
Cytoscape is a well-known bioinformatics tool for displaying and exploring biological networks. Python is a powerful programming language and environment for statistical and exploratory data analysis. py4cytoscape uses CyREST to communicate between Python and Cytoscape, allowing any graphs (e.g., igraph or dataframes) to be viewed, explored and manipulated with the Cytoscape point-and-click visual interface. Thus, via py4cytoscape, these two quite different, quite useful bioinformatics software environments are connected, mutually enhancing each other, providing new possibilities for exploring biological data.
Installation¶
%%capture
!python3 -m pip install python-igraph requests pandas networkx
!python3 -m pip install py4cytoscape
Prerequisites¶
In addition to this package (py4cytoscape), you will need:
Cytoscape 3.8.1 or greater + FileTransfer App, which can be downloaded from http://www.cytoscape.org/download.php. Simply follow the installation instructions on screen.
Once you have Cytoscape installed in your desktop environment, launch Cytoscape and keep it running whenever using py4cytoscape.
In addition to that, if you are now running this Notebook on Google Colab, you need to run the code below. (If you’re running this notebook on your local Jupyter, you don’t need to.)
import IPython
import py4cytoscape as p4c
print(f'Loading Javascript client ... {p4c.get_browser_client_channel()} on {p4c.get_jupyter_bridge_url()}')
browser_client_js = p4c.get_browser_client_js()
IPython.display.Javascript(browser_client_js) # Start browser client
Getting started¶
First, confirm that you have everything installed and running:
p4c.cytoscape_ping()
p4c.cytoscape_version_info()
My first network¶
Let’s create a Cytoscape network from some basic Python objects
import pandas as pd
nodes = pd.DataFrame(data={'id': ["node 0","node 1","node 2","node 3"], 'group': ["A","A","B","B"], 'score': [20,10,15,5]})
edges = pd.DataFrame(data={'source': ["node 0","node 0","node 0","node 2"], 'target': ["node 1","node 2","node 3","node 3"], 'interaction': ["inhibits","interacts","activates","interacts"], 'weight': [5.1,3.0,5.2,9.9]})
p4c.create_network_from_data_frames(nodes, edges, title="my first network", collection="DataFrame Example")
Create your own style with node attribute fill mappings and some defaults
style_name = "myStyle"
defaults = {'NODE_SHAPE': "diamond", 'NODE_SIZE': 30, 'EDGE_TRANSPARENCY': 120, 'NODE_LABEL_POSITION': "W,E,c,0.00,0.00"}
nodeLabels = p4c.map_visual_property('node label','id','p')
nodeFills = p4c.map_visual_property('node fill color','group','d',["A","B"], ["#FF9900","#66AAAA"])
arrowShapes = p4c.map_visual_property('Edge Target Arrow Shape','interaction','d',["activates","inhibits","interacts"],["Arrow","T","None"])
edgeWidth = p4c.map_visual_property('edge width','weight','p')
p4c.create_visual_style(style_name, defaults, [nodeLabels,nodeFills,arrowShapes,edgeWidth])
p4c.set_visual_style(style_name)
Pro-tip: if you want to set NODE_WIDTH and NODE_HEIGHT independently, you also need to unlock the node dimensions with…
p4c.lock_node_dimensions(False, style_name)
Biological graph example¶
Here we create a 4-node graph in Python, send it to Cytoscape for display and layout. For the sake of simplicity, no node attributes and no visual styles are included; those topics are covered in subsequent steps.
nodes = pd.DataFrame(data={'id': ["A", "B", "C", "D"]})
edges = pd.DataFrame(data={'source': ["C", "B", "B", "B"], 'target': ["D", "A", "D", "C"]})
p4c.create_network_from_data_frames(nodes, edges, title="simple network", collection="Biological Example")
You should now have the structure of this 4-node graph with a basic, default style. Fortunately, Cytoscape has some built-in rendering rules in which (and unless instructed otherwise) nodes and edges are rendered and a default (user-preference) layout algorithm is applied.
We often know quite a lot about the nodes and edges in our graphs. By conveying this information visually, the graph will be easier to explore. For instance, we may know that protein A phosphorylates protein B, that A is a kinase and B a transcription factor, and that their mRNA expression (compared to a control) is a log2 fold change of 1.8 and 3.2 respectively. One of the core features of Cytoscape is visual styles, which allow you to specify how data values (e.g., kinase,transcription factor; expression ratios) should be conveyed in the visual properties of the graph (e.g., node shape, node color or size).
We continue with the simple 4-node graph, adding two kinds data values (moleculeType and log2fc). The easiest way to do this is via pandas DataFrame s. However, you can also include attributes together with the original graph models as igraph s or pandas DataFrame s and then use the provided create functions to create and load in a single step (see p4c.create_network_from_igraph() and p4c.create_network_from_data_frames() functions). Check out the other Notebooks for more examples.
df = pd.DataFrame(data={'moleculeType': ['kinase','TF','cytokine','cytokine'], 'log2fc': [1.8,3.0,-1.2,-2.5]})
df.index = ['A','B','C','D']
p4c.load_table_data(df)
Note that adding the attributes does not in itself cause the appearance of the graph to change. Such a change requires that you specify and apply visual style mappings, which will be explained in the next section. You can, however, examine these attributes in Cytoscape, using Cytoscape’s the Data Panel to display data values associated with selected nodes immediately below the Cytoscape window.
py4cytoscape provides an easy way to not only change the default styles, but more interestingly, py4cytoscape also provides easy access to mapping your data to visual styles, e.g., allowing the size, shape and color of nodes and edges to be determined by the data you have associated with those nodes and edges.
First, let’s change the the defaults.
p4c.set_node_shape_default('OCTAGON')
p4c.set_node_color_default('#AAFF88')
p4c.set_node_size_default(60)
p4c.set_node_font_size_default(30)
Now we will add some visual mappings. Let’s map `moleculeType’ to node shapes. First, we can see which shapes are available in Cytoscape, then we can define the mapping with paired lists.
p4c.get_node_shapes()
column = 'moleculeType'
values = ['kinase', 'TF', 'cytokine']
shapes = ['DIAMOND', 'TRIANGLE', 'RECTANGLE']
p4c.set_node_shape_mapping(column, values, shapes)
The node shape mapping is an example of a discrete mapping, where a style is defined for each, discrete value. This is useful for categorical data (like type) where there is only a limited set of possible values. This is in contast to the other two other types of mappings: continuous and passthrough. In the case of expression values, for example, we will want to use continuous mapping (e.g., to node color), defining a small set of control points, rather than an explicit color for each possible data value. Cytoscape will simply interpolate between the control points to provide a gradient of colors. Let’s try that one now
column = 'log2fc'
control_points = [-3.0, 0.0, 3.0]
colors = ['#5588DD', '#FFFFFF', '#DD8855']
p4c.set_node_color_mapping(column, control_points, colors)
Note that there are three colors and three control points. However, you can also specify two additional colors beyond the number of control points if you want to set extreme (or out-of-bounds) colors for values less than or greater than your control points.
control_points = [-2.0, 0.0, 2.0]
colors = ['#2255CC', '#5588DD', '#FFFFFF', '#DD8855', '#CC5522']
p4c.set_node_color_mapping(column, control_points, colors)
Now, add a node size rule, using log2fc again as controlling node values.
control_points = [-3.0, 2.0, 3.0]
sizes = [20, 80, 90]
p4c.set_node_size_mapping(column, control_points, sizes)
If you recall the third type of mapping, passthrough, we can see it already working in our current network example. The node labels! By default, the name column is mapped to the node label property using passthrough logic: the value is passed directly to the style property.
Let us now try selecting nodes in Cytoscape from Python. Select the C node by name:
p4c.select_nodes('C', 'name')
p4c.get_selected_nodes()
Now we wish to extend the selected nodes to include the first neighbors of the already-selected node B. This is a common operation: for instance, after selecting one or more nodes based on experimental data or annotation, you may want to explore these in the context of interaction partners (in a protein-protein network) or in relation to upstream and downstream partners in a signaling or metabolic network. Type:
p4c.select_first_neighbors()
You will see that three nodes are now selected. Get their names back to Python as a list:
node_names = p4c.get_selected_nodes()
node_names
And, finally, deselection works as you’d expect by means of a general p4c.clearSelection() function:
p4c.clear_selection()
?p4c.clear_selection
Browse available functions, commands and arguments¶
py4cytoscape functions
help(p4c)
dir(p4c)
Category |
Description |
Examples |
---|---|---|
apps |
Inspecting and managing apps for Cytoscape. |
install_app disable_app get_installed_apps |
collections |
Getting information about network collections. |
get_collection_list get _collection_networks |
commands |
Constructing any arbitrary CyREST API or Commands API method via standard GET, PUT, POST and DELETE protocols. |
cyrest_get commands_post cyrest_api commands_run |
cy_ndex |
Communicating with NDEx from within Cytoscape. |
imp ort_network_from_ndex ex port_network_to_ndex |
cytoscape_system |
Checking Cytoscape System information, including versions and memory usage. |
cytoscape_ping cy toscape_version_info |
filters |
Selecting nodes and edges based on filter criteria. |
create_degree_filter create_column_filter |
groups |
Working with groups in Cytoscape. |
create_group collapse_group |
layouts |
Performing layouts in addition to getting and setting layout properties. |
layout_network get_layout_names |
networks |
Creating and managing networks and retrieving information on networks, nodes and edges. |
*create_network_from… create…_from_network get_network_suid export_network get_all_nodes get_edge_count get_first_neighbors* |
network_selection |
Manipulating selection of nodes and edges in networks. |
select_nodes invert_node_selection se lect_first_neighbors |
network_views |
Performing view operations in addition to getting and setting view properties. |
fit_content export_image tog gle_graphics_details |
sandbox |
Control staging of files when running scripts as Notebooks |
sandbox_send_to sandbox_get_from sandbox_url_to |
session |
Managing Cytoscape sessions, including save, open and close. |
open_session save_session close_session |
style_bypasses |
Setting and clearing bypass values for visual properties. |
set_node_color_bypass set_e dge_line_style_bypass hide_nodes* |
style_defaults |
Getting and setting default values for visual properties. |
s et_node_shape_default set_edg e_line_width_default |
style_dependencies |
Getting and setting style dependencies. |
lock_node_dimensions* |
style_mappings |
Defining mappings between table column values and visual properties. |
map_visual_property update_style_mapping set_node_size_mapping se t_edge_color_mapping |
styles |
Managing styles and retrieving general lists of properties relevant to multiple style modes. |
create_visual_style set_visual_style export_visual_styles get_arrow_shapes |
style_values |
Retrieving current values for visual properties. |
get_node_width get_edge_color get_network_zoom |
tables |
Managing table columns and table column functions, like map and rename, as well as loading and extracting table data in Cytoscape. |
get_table_columns rename_table_column load_table_data map_table_column |
tools |
Performing actions found in the Tools Menu in Cytoscape. |
cybrowser_dialog diffusion_basic |
user_interface |
Controling the panels in the Cytoscape user interface. |
hide_panel float_panel dock_panel |
More examples¶
The Cytoscape team is collecting scripts from the community in a public GitHub repository at https://github.com/cytoscape/cytoscape-automation/tree/master/for-scripters/Python.
Development¶
The py4cytoscape project code and documentation is maintained at GitHub: https://github.com/cytoscape/py4cytoscape. All bugs and feature requests are tracked as Issues, https://github.com/cytoscape/py4cytoscape/issues.
Credits¶
Paul Shannon’s generous advice and mentorship was very important for transforming this package from using XMLRPC and CytoscapeRPC to using CyREST.
David Otasek, Keiichiro Ono and Barry Demchak kindly provided CyREST as well as help and support for new functionalities and changes.
Mark Grimes and Ruth Isserlin kindly provided helpful user feedback.
Julia Gustavsen generously developed various use cases/examples for using RCy3 with biological data during GSOC 2016, https://github.com/jooolia/gsoc_Rcy3_vignettes/blob/master/blog_post_drafts/final_work_submission.md.
Tanja Muetze provided many years of development, design, maintenance and documentation for the RCy3 project.
All contributors, new and old, are dynamically acknowledged in our Contributor Graph, https://github.com/cytoscape/py4cytoscape/graphs/contributors
References¶
Shannon P, Markiel A, Ozier O, Baliga NS, Wang JT, Ramage D, Amin N, Schwikowski B, Ideker T. 2003. Cytoscape: a software environment for integrated models of biomolecular interaction networks. Genome Res. Nov;13(11):2498-504
Huber W, Carey VJ, Long L, Falcon S, Gentleman R. 2007. Graphs in molecular biology. BMC Bioinformatics. 2007 Sep 27;8.
Ono K, Muetze T, Kolishovski G, Shannon P, Demchak, B. CyREST: Turbocharging Cytoscape Access for External Tools via a RESTful API [version 1; referees: 2 approved]. F1000Research 2015, 4:478.
Cytoscape and igraph¶
by Kozo Nishida, Alexander Pico, Barry Demchak
2021-04-11
Package
py4cytoscape 0.0.9
This notebook will show you how to convert networks between igraph and Cytoscape.
Installation¶
%%capture
!python3 -m pip install python-igraph requests pandas networkx
!python3 -m pip install git+https://github.com/cytoscape/py4cytoscape.git@0.0.9
Required Software¶
In addition to this package (py4cytoscape), you will need:
Cytoscape 3.8.2 or greater + FileTransfer App, which can be downloaded from http://www.cytoscape.org/download.php. Simply follow the installation instructions on screen.
Once you have Cytoscape installed in your desktop environment, launch Cytoscape and keep it running whenever using py4cytoscape.
In addition to that, if you are now running this Notebook on Google Colab, you need to run the code below. (If you’re running this notebook on your local Jupyter, you don’t need to.)
import IPython
import py4cytoscape as p4c
print(f'Loading Javascript client ... {p4c.get_browser_client_channel()} on {p4c.get_jupyter_bridge_url()}')
browser_client_js = p4c.get_browser_client_js()
IPython.display.Javascript(browser_client_js) # Start browser client
p4c.cytoscape_ping()
From igraph to Cytoscape¶
The igraph package is a popular network tool among Python users. With py4cytoscape, you can easily translate igraph networks to Cytoscape networks!
Here is a basic igraph network construction from the Graph.DataFrame docs, https://igraph.org/python/doc/tutorial/generation.html#from-pandas-dataframe-s
import pandas as pd
from igraph import Graph
actors = pd.DataFrame(data={'name': ["Alice", "Bob", "Cecil", "David", "Esmeralda"],
'age': [48,33,45,34,21],
'gender': ["F","M","F","M","F"]
})
relations = pd.DataFrame(data={'from': ["Bob", "Cecil", "Cecil", "David", "David", "Esmeralda"],
'to': ["Alice", "Bob", "Alice", "Alice", "Bob", "Alice"],
'same_dept': [False, False, True, False, False, True],
'friendship': [4,5,5,2,1,1],
'advice': [4,5,5,4,2,3]
})
ig = Graph.DataFrame(relations, directed=True, vertices=actors)
You now have an igraph network, ig. In order to translate the network together with all vertex (node) and edge attributes over to Cytoscape, simply use:
p4c.create_network_from_igraph(ig, "myIgraph")
From Cytoscape to igraph¶
Inversely, you can use create_igraph_from_network() in py4cytoscape to retrieve vertex (node) and edge data.frames to construct an igraph network.
ig2 = p4c.create_igraph_from_network("myIgraph")
Compare the round-trip result for yourself…
print(ig)
print(ig2)
Note that a few additional attributes are present which are used by Cytoscape to support node/edge selection and network collections.
Also note: All networks in Cytoscape are implicitly modeled as directed. This means that if you start with an undirected network in igraph and then convert it round-trip (like described above), then you will end up with a directed network.
Concepts¶
py4cytoscape is a Python module that interfaces with Cytoscape to enable researchers to write reproducible sequences of network manipulations, visualizations and analyses. py4cytoscape includes functions that accomplish network operations common to many kinds of workflows. Using py4cytoscape, a Python application can:
load a network (from a file, from the NDEx or STRING repositories, or from local Python variables)
operate on the network
retrieve results
The Python application can perform several rounds of network analysis and results retrieval, and mix visualization and analyses with existing Python libraries. Finally, it can repeat the process for one network after another.
py4cytoscape works by connecting to Cytoscape’s CyREST feature, which is the foundation of Cytoscape Automation (FullPaper or WikiPages). The connection is based on standard HTTP networking protocols. For py4cytoscape to work, you must have Cytoscape running on your workstation.
Your Python application can be run in several modes:
Standalone on the workstation that’s already running Cytoscape
In a Jupyter Notebook running on the same workstation as your Cytoscape
In a Jupyter Notebook running on a remote server (e.g., Google Colab or GenePattern Notebook)
This section discusses conceptual and miscellaneous topics relating to py4cytoscape use:
Missing Functions shows how to call Cytoscape functions not covered in py4cytoscape.
Calling Cytoscape Apps shows how to call Cytoscape apps that support automation.
Jupyter Notebook shows how to use py4cytoscape from within a Jupyter Notebook.
Sandboxing shows how to limit Cytoscape to accessing files in particular directories.
Value Generators shows how to automatically generate colors, sizes, shapes, etc. for style mappings.
Missing Functions¶
While py4cytoscape provides hundreds of functions, there are still many Cytoscape operations for which py4cytoscape does not provide an equivalent function. However, it does provide mechanisms for you to write your own functions that can invoke many of these Cytoscape operations.
The complete list of invokable Cytoscape operations (either in py4cytoscape or not) is spread across two web pages, differing by the mechanism you would use to invoke them. Using the Cytoscape menus:
Help | Automation | CyREST API
Help | Automation | CyREST Commands API
Both pages enable you to try Cytoscape operations out directly from the web page (via the Swagger interface). Additionally, the Commands panel (View | Show Commands Panel) contains the same material as the CyREST Commands API page, but uses a command line oriented interface for experimentation.
For example, there is no py4cytoscape function for finding the name of
the Cytoscape session. However, the CyREST API page lists this function under the
Session
heading as GET /v1/session/name
. You can
try this function under Swagger by clicking the Try it now! button.
For operations on the CyREST API page, you can write your own Python functions by using one of the following py4cytoscape functions, according to the label on the CyREST API Swagger page:
commands.cyrest_get()
commands.cyrest_post()
commands.cyrest_put()
commands.cyrest_delete()
For the session rename operation, the py4cytoscape call would be:
commands.cyrest_get('session/name', {})
The {} value reflects that there are no parameters to the session/name
operation.
If there were parameters, they would be passed as Python dictionary values (e.g.,
{'param1': 'value1', 'param2': 'value2'}
).
As another example, there is no py4cytoscape function for renaming a filter.
However, the CyREST Commands API page lists this operation under the filter
heading as
POST /v1/commands/filter/rename
. You can try this operation yourself
on the CyREST Commands API page by using Swagger to specify the container
,
name
and newName
parameters and clicking the
Try it now! button. You can do the same thing in the Commands panel by first
entering help filter rename
to find the parameter names and then something like:
filter rename container='filter' name='affinity' newName='myAffinity'
For operations on the CyREST Commands API page, you can write your own Python functions by using one of the following py4cytoscape functions, according to the label on the CyREST Commands API Swagger page:
commands.commands_get()
commands.commands_post()
For the filter rename operation, the py4cytoscape call would be:
commands.commands_post('filter rename container="filter" name="affinity" newName="myAffinity"')
For commands.cyrest* and commands.commands* functions, you can determine the return result by trying the equivalent Cytoscape operation using Swagger’s Try it now! button.
Calling Cytoscape Apps¶
py4cytoscape includes operations corresponding to functions in a number of apps delivered with Cytoscape. However, there are many more App Store apps for which py4cytoscape provides no function. You can still call these apps’ functions using the techniques described in the Missing Functions section.
To find out which apps are automation-enabled, you can visit the App Store and click on the automation category on the left. At this writing, there are over 40 apps, only a few of which are delivered with Cytoscape – see the end of this section for a list.
You can also determine whether a specific app (e.g., MCODE) is enabled for automation by viewing its App Store page (e.g., http://apps.cytoscape.org/apps/mcode). If the gear icon appears below the page title, the app has functions callable via CyREST.
To determine which functions and parameters an app offers, first install the app in Cytoscape (using the Apps | App Manager menu), and then look for the app’s category in either the CyREST Commands API or the Commands panel as described in the Missing Functions section.
For example, to call the MCODE cluster function:
commands.commands_post('mcode cluster degreeCutoff=2 fluff=true fluffNodeDensityCutoff=0.1 haircut=true includeLoops=false kCore=2 maxDepthFromStart=100 network=current nodeScoreCutoff=0.2 scope=NETWORK')
Automation-enabled apps:
aMatReader
Analyzer
AutoAnnotate
autoHGPEC
cddApp
chemViz2
ClueGO
clusterMaker2
copycatLayout
CyAnimator
cyBrowser
cyChart
cyNDEx-2
Cyni Toolbox
Cyrface
CyTargetLinker
CytoCopteR
Diffusion
enhancedGraphics
EnrichmentMap
eXamine
GeneMANIA
ID Mapper
KEGGscape
MCODE
Motif-Discovery
Omics Visualizer
PathLinker
PSFC
ReactomeFIPlugin
RINalyzer
RINspector
RWRMTN
scNetViz
setsApp
stringApp
structureViz2
Synapse Client
WikiPathways
wk-shell-decomposition
WordCloud
Jupyter Notebook¶
Jupyter Notebooks can be executed on a number of platforms, including:
Your Cytoscape workstation (via PyCharm, Anaconda, and others)
Private Notebook servers (e.g., GenePattern Notebook)
Public Notebook servers (e.g., Google Collaboratory)
In each case, your Jupyter Notebook can call py4cytoscape functions that are executed by Cytoscape running on your own workstation.
To call py4cytoscape from a Notebook running on your Cytoscape workstation (a so-called local Notebook), simply use your Python environment to install the py4cytoscape library, then create a Notebook cell that imports the py4cytoscape library and calls a py4cytoscape function:
import py4cytoscape as p4c
p4c.cytoscape_version_info()
Alternatively, you can create a Notebook cell to directly install the py4cytoscape library, and then import it and call a test function:
import sys
!{sys.executable} -m pip uninstall -y py4cytoscape
!{sys.executable} -m pip install py4cytoscape
import py4cytoscape as p4c
p4c.cytoscape_version_info()
Alternatively, you can create a Notebook cell to load an unreleased version of the py4cytoscape library:
import sys
!{sys.executable} -m pip uninstall -y py4cytoscape
!{sys.executable} -m pip install --upgrade git+https://github.com/cytoscape/py4cytoscape
import py4cytoscape as p4c
p4c.cytoscape_version_info()
Note
To get Jupyter to recognize a py4cytoscape library different from the one first used by your Notebook, you may need to restart the Python kernel – see your Jupyter Notebook documentation.
Jupyter Notebooks that run on remote (private or public) servers can use py4cytoscape to execute Cytoscape functions on your workstation via the Jupyter-Bridge. To use the Jupyter-Bridge, you must create a different cell at the beginning of your Notebook:
import sys, IPython
!{sys.executable} -m pip uninstall -y py4cytoscape
# Comment this out to avoid installing the release py4cytoscape
!{sys.executable} -m pip install --upgrade py4cytoscape
# Uncomment this to install the development py4cytoscape
# !{sys.executable} -m pip install --upgrade git+https://github.com/cytoscape/py4cytoscape
import py4cytoscape as p4c
print(f'Loading Javascript client ... {p4c.get_browser_client_channel()} on {p4c.get_jupyter_bridge_url()}')
browser_client_js = p4c.get_browser_client_js()
IPython.display.Javascript(browser_client_js) # Start browser client
All of these scenarios will result in Jupyter Notebook that can call functions executed on the Cytoscape executing in your workstation. Note, though, that without an extra step, Cytoscape generally can’t access files stored in a remote Notebook’s file system, and a remote Notebook can’t access files created by Cytoscape.
See the Sandboxing section (below) for an explanation of the file sharing protocol.
See the Sanity Test examples to see how to use sandboxing in different situations.
Note
All Notebooks, whether running on a local or remote Jupyter server must use the Sandboxing protocol for sharing Notebook files with Cytoscape and vice-versa.
Note
In all cases, py4cytoscape calls the Cytoscape running on your private workstation. Cytoscape is not a full server, and can support exactly one Notebook running at a time – multiple simultaneous Notebooks are not supported.
Note
The Jupyter-Bridge can reach your Cytoscape workstation whether or not it’s behind a firewall.
Sandboxing¶
If you use py4cytoscape to create and run a Python workflow on the same workstation as your Cytoscape instance and not in a Jupyter Notebook, you may not need sandbox features (but they may make your Python coding simpler). If you use py4cytoscape from a Jupyter Notebook running on a remote server or on your Cytoscape workstation, you very likely need sandboxing.
For context, py4cytoscape functions (e.g., open_session()
, save_session()
and export_image()
) access files in either Cytoscape’s current working directory or
in a location given by a full path. When a non-Notebook Python workflow starts, its working directory
is the Python kernel’s working directory, which may contain user data files. Calls to py4cytoscape functions
may contain paths relative to this directory, or may be full paths on the Cytoscape workstation.
Full paths work well only as long as the workflow executes on the same workstation as it was written. It raises a number of problems:
Workflows with hard-coded paths are not likely to be portable to other Cytoscape workstations, which may have their own (different) file system layouts. This applies equally to both to workflows running on other Cytoscape workstations and those running in a remote Jupyter Notebook server.
To enable collaboration, workflows running on a remote Jupyter Notebook server likely prefer to store Cytoscape data and output on the Notebook server. As the server’s file system is inaccessible to the Cytoscape running on your workstation, there is no path the workflow can pass to make Cytoscape read or write those files.
Sandboxing solves these problems by defining a dedicated folder on the Cytoscape workstation (in the
user’s CytoscapeConfiguration/filetransfer
folder); files
read and written by Cytoscape are all contained with the folder (aka sandbox).
Sandboxing functions allow files to be transferred
between the Jupyter Notebook server’s native file system
and the sandbox. Thus, a Notebook-based workflow can maintain Cytoscape files on the
Notebook server, and transfer them to/from the Cytoscape workstation (in the sandbox) at
will.
A sandbox can contain both files and directories (which can contain files and directories, too).
Sandboxing applies to Notebooks running either either on a remote Jupyter server or a Jupyter server running on the Cytoscape workstation. Thus, workflows written for one environment can work seamlessly on the other.
A useful side effect of sandboxing is that workflows that use them stand little chance of inadvertantly (or maliciously) corrupting the Cytoscape workstation’s file system. This safety further encourages sharing of workflows between collaboratating researchers.
Notebook workflows are automatically provisioned with a default sandbox (called
default_sandbox
). To get the same effect with Python running standalone on the
Cytoscape workstation, you can explicitly create the default sandbox. (See vignettes below.)
Note
By default, a sandbox is pre-loaded with a copy of Cytoscape’s sampleData
files. This makes it easy for workflow writers to experiment on sample data. For example,
calling open_session('sampleData/sessions/Affinity Purification')
opens a sandbox-based sample session
provided with Cytoscape.
A workflow can define any number of sandboxes and even switch between them. This promotes modularity by facilitating the creation of different sub-workflows with some certainty that a sub-workflow’s files aren’t accidentally corrupted by other sub-workflows over time.
See the Sanity Test examples to see how to use sandboxing in different situations.
Vignette 1: A workstation-based non-Notebook Python workflow calling Cytoscape to load a session and create a network image.
Without sandboxing, the workflow must specify Cytoscape files as either relative to the Python kernel’s current directory or as full (non-portable) paths.
open_session('mySession')
# ...
export_image('myImage.png')
# ... use Python to do something with the .png
or
open_session('C:\Users\Me\Documents\CyFiles\mySession')
# ...
export_image('C:\Users\Me\Documents\CyFiles\myImage.png')
# ... use Python to do something with the .png
When using full paths, this workflow is portable only to workstations that have their Cytoscape files in the
C:\Users\Me\Documents\CyFiles
, which doesn’t seem like a good assumption for many workstations.
Vignette 2: A Notebook-based version of Vignette 1 … data files on a Jupyter server.
A sandbox is automatically created for Notebook-based workflows whether they execute on a remote Jupyter server or a Jupyter server on the Cytoscape workstation. The workflow must transfer a session file from the Notebook’s file system to the sandbox, call Cytoscape, and then transfer the result back to the Notebook’s file system for further processing.
sandbox_send_to('./mySession.cys') # copy session file from Notebook directory to workstation
open_session('mySession')
# ...
export_image('myImage.png')
sandbox_get_from('myImage.png', './myImage.png') # copy image file to Notebook directory
# ... do something with the .png
This workflow can run on any Notebook server and Cytoscape workstation without knowledge of or risk to the workstation’s file system. Various Python-based libraries can process the .png after it is copied to the Notebook’s file system.
When calling sandbox functions, if you don’t specify the name of a sandbox, the operation
is performed on the “current sandbox”, which is the default_sandbox
folder or whatever sandbox you
set by calling the sandbox_set()
function.
Sandbox functions and Notebook-based py4cytoscape functions don’t accept full paths for files, as they would create non-portable code and pose a security risk to the Cytoscape workstation.
Vignette 3: A Notebook-based version of Vignette 1 … data files on a cloud service.
This vignette is the same as Vignette 2, except the session file resides on a cloud service (i.e., GitHub, Dropbox, OneDrive, Google Drive, or elsewhere). In this case, the workflow must transfer the file from the cloud service (instead of the Notebook’s file system) to the sandbox, and then proceed as in Vignette 2.
# copy session file from cloud service to workstation
sandbox_url_to('https://www.dropbox.com/s/r15azh0xb534mu1/mySession.cys?dl=0')
open_session('mySession')
# ...
export_image('myImage.png')
sandbox_get_from('myImage.png', './myImage.png') # copy image file to Notebook directory
# ... do something with the .png
Vignette 4: A workstation-based non-Notebook Python workflow accesses sandbox-based files
Sandboxes are stored as directories under the user’s CytoscapeConfiguration/filetransfer
folder. You can
choose to maintain your Cytoscape files in a sandbox folder (instead of elsewhere in the
Cytoscape workstation file system). If you do this, you get all of the benefits of sandboxing without having to specify non-portable
file paths.
sandbox_set('mySandbox', copy_samples=False, reinitialize=False)
open_session('mySession')
# ...
export_image('myImage.png')
# ... do something with the .png
If Cytoscape files reside in the sandbox a priori, no sandbox_send_to()
or
sandbox_get_from()
calls are needed. Note that to make a standalone Python workflow run in a remote
Notebook, you’ll have to add sandbox calls (as in Vignette 2). Why not start by using sandboxes in anticipation
of publishing a workflow as a Notebook?
Warning
The reinitialize=False
parameter is needed to prevent the sandbox_set()
call from erasing the sandbox folder’s contents, which is its default behavior.
Note
- Sandbox functions allow the following operations on files and sandboxes:
sandbox_set()
: Create a new sandbox or makes another sandbox the “current sandbox”sandbox_remove()
: Delete a sandbox and its files and directoriessandbox_send_to()
: Transfer a Notebook file to a sandboxsandbox_url_to()
: Transfer for a cloud-based file to a sandboxsandbox_get_from()
: Transfer a sandbox file to the Notebook file systemsandbox_get_file_info()
: Get sandbox file metadatasandbox_remove_file()
: Remove a sandbox file
Value Generators¶
You can set visual graph attributes (e.g., color, size, opacity and shapes) according to attribute data assigned to
nodes or edges by using Style Mapping functions such as set_node_color_mapping()
or set_node_size_mapping()
.
As described in the Cytoscape Manual, there
are three different ways to map node or edge attributes to visual attributes.
Briefly:
continuous mappings map a range of values to a color gradient or a range of sizes, opacities et al
discrete mappings allow specific values to map to specific colors, sizes, opacities et al
passthrough mappings allow node or edge labels to be taken from node or edge attributes
A value generator makes discrete or continuous mappings more convenient by automatically mapping attribute data values to visual attributes. It first determines the unique data values for a given node or edge attribute, then allows you to choose a mapping to colors, sizes, opacities or shapes. For example, you can use a value generator to map a node with a Degree attribute having values 1, 10 and 20 to node fill colors of Red, Blue or Green … or to a node size of 100, 150 or 200 … or to circle, square or diamond shapes.
Essentially, a value generator spares you from having to know both the specific values of a node or edge attribute and the specifics of the visual attributes to display … it lets you focus on whether to render the attribute as a color, size, opacity or shape.
For example, to set a node’s fill color based on its Degree attribute using a discrete style mapping function, you could use the longhand (without value generator) where you know the unique Degree values in advance and choose specific colors to represent them:
set_node_color_mapping('Degree',
['1', '10', '20'],
['#FF0000', '#00FF00', '#0000FF],
mapping_type='d',
style_name='galFiltered Style')
Instead, you could use a color value generator that determines the unique Degree values and assigns each to a different color in a Brewer palette:
set_node_color_mapping(**gen_node_color_map('Degree',
mapping_type='d',
style_name='galFiltered Style'))
set_node_color_mapping(**gen_node_color_map('Degree',
palette_color_brewer_q_Accent(),
mapping_type='d',
style_name='galFiltered Style'))
The first form uses a default Brewer palette (Set2), and the second form shows how you can choose a different Brewer palette (Accent).
Note
For color-oriented visual attributes, py4cytoscape offers a wide range of Brewer palettes, which are widely regarded as aesthetic and visually effective.
Note
Brewer palettes appropriate for discrete mappings are called qualititive palettes, and are distinguished in py4cytoscape by the “_q_” in the palette name.
To map attributes to a gradient of colors, sizes, opacities, etc, use continuous mapping:
set_node_color_mapping(**gen_node_color_map('Degree',
style_name='galFiltered Style'))
set_node_color_mapping(**gen_node_color_map('Degree',
palette_color_brewer_s_YlGn(),
style_name='galFiltered Style'))
The first form uses a default Brewer palette (GnBu), and the second form shows how you can choose a different Brewer palette (YlGn).
Note
Brewer palettes appropriate for continuous mappings of same-signed values are called sequential palettes, and are distinguished in py4cytoscape by the “_s_” in the palette name.
Note
Brewer palettes appropriate for continuous mappings of mixed-signed values are called divergent palettes, and are distinguished in py4cytoscape by the “_d_” in the palette name.
It’s likely that the Degree attribute would have only positive values, so a sequential Brewer palette would be appropriate. When the distribution of attribute data values isn’t known in advance, you can provide both a sequential and divergent palette and let py4cytoscape choose between them based on the data values it finds:
set_node_color_mapping(**gen_node_color_map('Expressed',
style_name='galFiltered Style'))
set_node_color_mapping(**gen_node_color_map('Expressed',
(palette_color_brewer_s_YlGn(), palette_color_brewer_d_Spectral()),
style_name='galFiltered Style'))
The first form uses default sequential and divergent palettes (GnBu and RdYlBu), and the second form shows how to use a tuple to specify which sequential and divergent palettes to use.
The general methodology is to use the value generator (e.g., gen_node_color_map()
) as the sole parameter to a
style mapping function, binding it by using the Python ** operator. py4cytoscape provides color generators (for use with
color mapping functions (e.g., set_node_color_mapping()
), opacity generators (for use with opacity mapping
functions (e.g., set_node_opacity_mapping()
), and other generators (e.g., size, width, height, shapes).
Each generator accepts all of the same parameters as the corresponding style mapping functions, and provides the same defaults for them. So,
set_node_color_mapping(**gen_node_color_map('Degree',
palette_color_brewer_q_Accent(),
mapping_type='d',
style_name='galFiltered Style'))
is the equivalent of:
set_node_color_mapping(table_column='Degree',
table_column_values=['8', '7', '6', '5', '4', '3', '2', '1'],
colors=['#7FC97F', '#BEAED4', '#FDC086', '#FFFF99', '#386CB0', '#F0027F', '#BF5B17', '#666666'],
mapping_type='d',
default_color=None,
style_name='galFiltered Style',
network=None,
base_url:'http://127.0.0.1:1234/v1')
py4cytoscape provides numerous automatic value generators for discrete mappings:
8 qualitative Brewer palettes (for color mappings)
a random palette (
palette_color_random()
, for color mappings)node shapes, edge arrow shapes, and edge line styles
ranges and random distributions
It also provides automatic value generators for continuous mappings:
18 sequential Brewer palettes (for color mappings for same-signed data)
9 divergent Brewer palettes (for color mappings for mixed-signed data)
Examples of non-color mappings that use ranges and random distributions include:
set_node_fill_opacity_mapping(**gen_node_opacity_map('Degree',
mapping_type='d',
style_name='galFiltered Style'))
set_node_fill_opacity_mapping(**gen_node_opacity_map('Degree',
scheme_d_number_series(start_value=100, step=20),
mapping_type='d',
style_name='galFiltered Style'))
set_node_fill_opacity_mapping(**gen_node_opacity_map('Degree',
scheme_d_number_random(min_value=10, max_value=120),
mapping_type='d',
style_name='galFiltered Style'))
set_node_fill_opacity_mapping(**gen_node_opacity_map('Expressed',
scheme_c_number_continuous(start_value=50, end_value=200),
style_name='galFiltered Style'))
Note that the default value generator for a numeric attribute is scheme_d_number_series(start_value=0, step=10). The default range for a random distribution is 0..255.
Note that the last form shows a continuous mapping where the node opacity is set to range from 50 to 200, depending on the value of the Expressed attribute. The normal range defaults to 10..30.
Shape generators don’t require a scheme
parameter, and automatically have a mapping_type
of ‘d’. For example:
set_node_shape_mapping(**gen_node_shape_map('Degree',
style_name='galFiltered Style'))
set_edge_source_arrow_shape_mapping(**gen_edge_arrow_map('interaction',
style_name='galFiltered Style'))
set_edge_target_arrow_shape_mapping(**gen_edge_arrow_map('interaction',
style_name='galFiltered Style'))
Reference¶
- Release
0.0.9
- Date
Jun 03, 2021
Apps¶
Functions for inspecting and managing apps for Cytoscape.
Local Apps¶
|
Disable App. |
|
Enable App. |
|
Retrieve the current status of a Cytoscape app: Installed, Uninstalled or Disabled. |
|
Retrieve list of currently installed Cytoscape apps with updates available. |
|
Retrieve list of currently disabled apps in Cytoscape. |
|
Retrieve list of currently installed apps in Cytoscape. |
|
Retrieve list of apps not currently installed in Cytoscape. |
|
Installs an app in Cytoscape |
|
Uninstall an app from Cytoscape. |
|
Update a Cytoscape app to the latest available version. |
App Store¶
|
Retrieve the name, brief description and version of a Cytoscape app. |
|
Retrieve a list of apps available for installation in Cytoscape. |
|
Opens the Cytoscape App Store in a new tab in your default browser. |
Collections¶
Functions for getting information about network COLLECTIONS.
Collections¶
|
Get Collection List. |
|
Get Collection Name. |
|
Get Collection Networks. |
|
Get Collection Suid. |
Commands¶
Functions for constructing any arbitrary CyREST API or Commands API method via standard GET, PUT, POST and DELETE protocols. These functions handle marshalling and unmarshalling of urls, parameters and returns so that higher-level functions can work with Python-friendly arguments and returns.
CyREST API functions
Commands API functions
Internal functions
CyREST API¶
|
Construct a query, make DELETE call and process the result. |
|
Construct a query, make GET call and process the result. |
|
Construct a query and body, make POST call and process the result. |
|
Construct a query and body, make PUT call and process the result. |
Cytoscape Commands API¶
|
Commands GET. |
|
Commands Help. |
|
Commands POST. |
|
Run a Command. |
Cytoscape Commands¶
|
Command Echo. |
|
Command Open Dialog. |
|
Command Pause. |
|
Command Quit. |
|
Command Run File. |
|
Command Sleep. |
Swagger API-level Documentation¶
|
Open Swagger docs for CyREST Commands API. |
|
Open Swagger docs for CyREST API. |
CyNDEx¶
Functions for communicating with NDEx from within Cytoscape.
Read/Write¶
|
Send a copy of a Cytoscape network to NDEx as a new submission. |
|
Import a network from the NDEx database into Cytoscape. |
|
Update Network In NDEx. |
Utility¶
|
Get Network NDEx Id. |
Cytoscape System¶
Functions for inspecting and managing apps for Cytoscape.
Resources¶
|
Manually call Java’s garbage collection |
|
Returns the memory resources of the server running Cytoscape. |
|
Returns the processor resources of the server running Cytoscape. |
System¶
|
Get the list of available CyREST API versions. |
|
Ping Cytoscape |
|
Return the versions of the current Cytoscape and CyREST API. |
Exceptions¶
Error classes for py4cytoscape.
Filters¶
Functions for working with FILTERS for the selection of nodes and edges in networks, including operations to import and export filters. In the Cytoscape user interface, filters are managed in the Select tab of the Control Panel.
Existing Filters¶
|
Run an existing filter by supplying the filter name. |
|
Saves filters to file in JSON format. |
|
Retrieve list of named filters in current session |
|
Loads filters from a file in JSON format. |
New Filters¶
|
Create Column Filter. |
|
Combine filters to control node and edge selection based on previously created filters. |
|
Create Degree Filter. |
Groups¶
Functions for working with GROUPS in Cytoscape.
Add/Remove Groups and Nodes¶
|
Add the specified nodes and edges to the specified group. |
|
Create a group from the specified nodes. |
|
Create a group of nodes defined by a column value. |
|
Delete one or more groups, while leaving member nodes intact. |
|
Remove the specified nodes and edges from the specified group. |
Existing Groups¶
|
Replace the representation of all of the nodes and edges in a group with a single node. |
|
Replaces the group node with member nodes for a set of groups. |
|
Retrieve information about a group by name or identifier. |
|
Retrieve a list of all group SUIDs in a network. |
Layouts¶
Functions for performing LAYOUTS in addition to getting and setting layout properties.
Perform layout functions
Get layout properties
Set layout properties
Perform Layout¶
|
Apply edge bundling to the network specified. |
|
Clear all edge bends created from edge bundling. |
|
Copy a layout from one network to another. |
|
Apply a layout to a network. |
Layout Properties¶
|
Get Layout Name Mapping. |
|
Retrieve the names of the currently supported layout algorithms. |
|
Returns a list of the tunable properties for the specified layout. |
|
Returns the type of one of the tunable properties (property_name) for the specified layout. |
|
Returns the appropriately typed value of the specified tunable property for the specified layout. |
|
Sets the specified properties for the specified layout. |
Networks¶
Basic Networks¶
Functions for NETWORK management and retrieving information on networks, nodes and edges. Includes all functions that result in the creation of a new network in Cytoscape, in addition to funcitons that extract network models into other useful objects.
General network functions
General node functions
General edge functions
Network creation
Network extraction
Internal functions
Note
See the Network Selection
section for all selection-related functions.
See the Utils
section for functions that convert node and edge names to SUIDs, and vice versa.
Nodes¶
|
Add one or more nodes to a Cytoscape network. |
|
Retrieve the names of all the nodes in the network. |
|
Returns a non-redundant list of first neighbors of the supplied list of nodes or current node selection. |
|
Reports the number of nodes in the network. |
Edges¶
|
Add one or more edges to a Cytoscape network by listing source and target node pairs. |
|
Retrieve the names of all the edges in the network. |
|
Reports the number of the edges in the network. |
|
Returns source, target and edge table row values. |
Network Management¶
|
Makes a copy of a Cytoscape Network with all of its edges and nodes. |
|
Copies a subset of nodes and edges into a newly created subnetwork. |
|
Delete all networks from the current Cytoscape session. |
|
Delete a network from the current Cytoscape session. |
|
Get the number of Cytoscape networks in the current Cytoscape session. |
|
Returns the list of Cytoscape network names in the current Cytoscape session. |
|
Get the name of a network. |
|
Get the SUID of a network. |
|
Sets a new name for a network. |
|
Selects the given network as “current”. |
Import/Export¶
|
Create an igraph network from a Cytoscape network. |
|
Create a network from data frames. |
|
Create a Cytoscape network from an igraph network. |
|
Create a Cytoscape network from a NetworkX graph. |
|
Return the Cytoscape network as a networkx multi-di-graph. |
|
Export a network to one of mulitple file formats. |
|
Loads a network from specified file. |
|
Loads a network from specified file. |
Network Selection¶
Functions for working with SELECTIONS of nodes and edges in networks, including operations that perform selection and rely on prior selection events.
General selection functions
Node selection functions
Edge selection functions
Nodes¶
|
If any nodes are selected in the network, they will be unselected. |
|
Delete currently selected nodes from the network. |
|
Returns the number of nodes currently selected in the network. |
|
Retrieve the names of all the nodes selected in the network. |
|
Select all nodes that were not selected and deselect all nodes that were selected. |
|
Selects all nodes in a Cytoscape Network. |
|
Select nodes directly connected to currently selected nodes. |
|
Select nodes in the network by SUID, name or other column values. |
Take currently selected edges and extends the selection to connected nodes, regardless of directionality. |
Edges¶
|
If any nodes are selected in the network, they will be unselected. |
|
Remove edges with duplicate names. |
|
Delete the currently selected edges in the network. |
|
Removes edges that connect to a single node as both source and target. |
|
Return the number of edges currently selected in the network. |
|
Retrieve the names of all the edges selected in the network. |
|
Select all edges that were not selected and deselect all edges that were selected. |
|
Selects all edges in a Cytoscape Network. |
|
Select edges in the network by SUID, name or other column values. |
Take currently selected nodes and add to the selection all edges connected to those nodes, regardless of directionality. |
|
Select edges in a Cytoscape Network connecting the selected nodes, including self loops connecting single nodes. |
Network Views¶
Functions for performing VIEW operations in addition to getting and setting view properties.
Views¶
|
Save the current network view as an image file. |
|
Zoom and pan network view to maximize either height or width of current network window. |
|
Retrieve the SUID of a network view. :param network: Name or SUID of the network or view. Default is the “current” network active in Cytoscape. If a network view SUID is provided, then it is validated and returned. :type network: str or SUID or None :param base_url: Ignore unless you need to specify a custom domain, port or version to connect to the CyREST API. Default is http://127.0.0.1:1234 and the latest version of the CyREST API supported by this version of py4cytoscape. :type base_url: str. |
|
Retrieve list of network view SUIDs. |
|
Set which network view is “current”. |
|
Toggle Graphics Details. |
Sandbox¶
Functions for performing file operations within a sandbox.
A sandbox is a directory on the Cytoscape workstation that is guaranteed writeable and is guaranteed to be isolated from the whole file system. All file operations are carried out relative to the “current sandbox”. Generally, a Notebook-based workflow doesn’t have to do anything to set up a sandbox … the default sandbox is automatically set up as part of py4cytoscape startup. However, the workflow can set different sandboxes, and can even switch between them. A sandbox can contain both files and directories, and the user can transfer files between a sandbox and the workflow’s native file system (e.g., a remote Notebook’s server).
If a sandbox is defined, all Cytoscape functions read and write files to it by default.
Thus, is it possible to build workflows that don’t depend on the structure of the Cytoscape workstation’s file system. Such workflows can store workflow data files along with other workflow files on a remote Notebook server, then transfer them to a sandbox only when Cytoscape will need them. Conversely, when Cytoscape creates a file in a sandbox (e.g., exporting an image), the workflow can transfer the file to workflow storage.
A special case is when py4cytoscape is running on the same workstation as Cytoscape. The default sandbox is considered to be directory that’s current for the Python kernel. Alternatively, the workflow could also define a sandbox, and then move files in and out of it just as a remote Notebook would.
- See Also:
Sandboxing in the Concepts section in the py4cytoscape User Manual.
Sandbox¶
|
Set a new default sandbox, creating it if necessary. |
|
Delete sandbox contents and remove its directory. |
|
Get metadata on file in sandbox (or entire sandbox). |
|
Transfer a file to a sandbox. |
|
Transfer a cloud-based file to a sandbox. |
|
Transfer a file from a sandbox. |
|
Remove a file from a sandbox. |
Session¶
Functions for managing Cytoscape SESSIONS, including save, open and close.
Session¶
|
Close the current session in Cytoscape, destroying all unsaved work. |
|
Open Session File or URL. |
|
Saves the current Cytoscape session as a CYS file. |
Styles¶
Basic Styles¶
Functions for managing STYLES and retrieving general lists of properties relevant to multiple style modes. Functions specific to Default, Mapping, Bypass, Dependencies and Values are in separate files.
Style management functions
General property functions
Style Management¶
|
Create a new visual style by copying a specified style. |
|
Create a style from defaults and predefined mappings. |
|
Delete the specified visual style from current session. |
|
Save one or more visual styles to file. |
|
Retrieve a list of all visual style names. |
|
Load styles from an XML file and returns the names of the loaded styles. |
|
Apply a visual style to a network. |
|
Get the current visual style applied to a network. |
Visual Property Names and Values¶
|
Get Arrow Shapes. |
|
Get Line Styles. |
|
Get Node Shapes. |
|
Retrieve the names of all possible visual properties. |
Style Automatic Mappings¶
Functions for defining automatic MAPPINGS between table column values and visual properties, organized into sections:
Palettes for color mapping generators
Schemes for discrete and numerical mapping generators
Functions for automatically mapping discrete values to colors, opacities, sizes, heights, widths and shapes
See style_mappings for manual mapping generation
Node Style Mapping Generators¶
|
Generate color map parameters for discrete or continuous values in a node table |
|
Generate height map parameters for discrete or continuous values in a node table |
|
Generate opacity map parameters for discrete or continuous values in a node table |
|
Generate shape map parameters for discrete values in a node table |
|
Generate size map parameters for discrete or continuous values in a node table |
|
Generate width map parameters for discrete or continuous values in a node table |
Edge Style Mapping Generators¶
|
Generate arrow shape map parameters for discrete values in an edge table |
|
Generate color map parameters for discrete or continuous values in an edge table |
|
Generate line style map parameters for discrete values in an edge table |
|
Generate opacity map parameters for discrete or continuous values in an edge table |
|
Generate size map parameters for discrete or continuous values in an edge table |
|
Generate width map parameters for discrete or continuous values in an edge table |
Schemes for Discrete Shape and Numeric Generators¶
|
Generate a continuous series |
Generate list of arrow shapes of a given size |
|
Generate list of line styles of a given size |
|
|
Generate list of random integers in a given range |
|
Generate list of numbers in a given series |
Generate list of node shapes of a given size |
Palettes for Discrete (Qualitative) Color Generators¶
Generate accent Brewer palette of a given size . |
|
Generate pastel2 Dark2 palette of a given size . |
|
Generate paired Brewer palette of a given size . |
|
Generate pastel1 Brewer palette of a given size . |
|
Generate pastel2 Brewer palette of a given size . |
|
Generate set1 Brewer palette of a given size . |
|
Generate set2 Brewer palette of a given size . |
|
Generate set3 Brewer palette of a given size . |
|
Generate random color map of a given size |
Palettes for One-Tailed Continuous (Sequential) Color Generators¶
Generate Blues Brewer palette of a given size . |
|
Generate BuGn Brewer palette of a given size . |
|
Generate BuPu Brewer palette of a given size . |
|
Generate GnBu Brewer palette of a given size . |
|
Generate Greens Brewer palette of a given size . |
|
Generate Greys Brewer palette of a given size . |
|
Generate Oranges Brewer palette of a given size . |
|
Generate OrRd Brewer palette of a given size . |
|
Generate PuBu Brewer palette of a given size . |
|
Generate PuBuGn Brewer palette of a given size . |
|
Generate RdPu Brewer palette of a given size . |
|
Generate PuRd Brewer palette of a given size . |
|
Generate Purples Brewer palette of a given size . |
|
Generate Reds Brewer palette of a given size . |
|
Generate YlGn Brewer palette of a given size . |
|
Generate YlGnBu Brewer palette of a given size . |
|
Generate YlOrBr Brewer palette of a given size . |
|
Generate YlOrRd Brewer palette of a given size . |
Palettes for Two-Tailed Continuous (Diverging) Color Generators¶
Generate BrBG Brewer palette of a given size . |
|
Generate PiYG Brewer palette of a given size . |
|
Generate PRGn Brewer palette of a given size . |
|
Generate PuOr Brewer palette of a given size . |
|
Generate RdBu Brewer palette of a given size . |
|
Generate RdGy Brewer palette of a given size . |
|
Generate RdYlBu Brewer palette of a given size . |
|
Generate RdYlGn Brewer palette of a given size . |
|
Generate Spectral Brewer palette of a given size . |
Style Bypasses¶
Functions for getting and setting BYPASS values for visual properties, organized into sections:
General functions for setting/clearing node, edge and network properties
Specific functions for setting particular node, edge and network properties
NOTE: The CyREST ‘bypass’ endpoint is essential to properly set values that will persist for a given network independent of applied style and style changes, and from session to session if saved.
General Style Bypasses¶
|
Set Node Property Bypass. |
|
Set Edge Property Bypass. |
Node Style Bypasses¶
|
Clear Node Opacity Bypass. |
|
Clear Node Property Bypass. |
|
Hide Nodes. |
|
Hide Selected Nodes. |
|
Override the border color for particular nodes. |
|
Override the border opacity for particular nodes. |
|
Override the border width for particular nodes. |
|
Set the bypass value for fill color for the specified node or nodes. |
|
Override the fill opacity for particular nodes. |
|
Override the font face for particular nodes. |
|
Override the font size for particular nodes. |
|
Override the height for particular nodes. |
|
Override the label for particular nodes. |
|
Override the label color for particular nodes. |
|
Override the label opacity for particular nodes. |
|
Set the bypass value for node fill, label and border opacity for the specified node or nodes. |
|
Override the shape for particular nodes |
|
Set Node Size Bypass. |
|
Sets a bypass tooltip for one or more nodes. |
|
Override the width for particular nodes. |
|
Unhide Nodes. |
Edge Style Bypasses¶
|
Clear Edge Property Bypass. |
|
Hide Edges. |
|
Hide Selected Edges. |
|
Set the bypass value for fill color for the specified edge or edges. |
|
Override the font face for particular edges. |
|
Override the font size for particular edges. |
|
Override the label for particular edges. |
|
Override the label color for particular edges. |
|
Override the label opacity for particular edges. |
|
Override the style for particular edges. |
|
Override the width for particular edges. |
|
Override the opacity for particular edges. |
Override the target arrow color for particular edges. |
|
Override the source arrow shape for particular edges. |
|
Override the target arrow color for particular edges. |
|
Override the target arrow shape for particular edges. |
|
|
Sets a bypass tooltip for one or more edges. |
|
Unhide Edges. |
Network Style Bypasses¶
|
Clear the bypass value for center x and y for the network, effectively restoring prior default values. |
|
Clear Network Property Bypass. |
|
Clear the bypass value for the scale factor for the network, effectively restoring prior default values. |
|
Set the bypass value for center x and y for the network. |
|
Set Network Property Bypass. |
|
Set the bypass value for scale factor for the network. |
|
Unhide all previously hidden nodes and edges, by clearing the Visible property bypass value. |
Style Defaults¶
Functions for getting and setting DEFAULT values for visual properties, organized into sections:
General functions for setting node, edge and network defaults
Specific functions for setting particular node, edge and network defaults
General Style Defaults¶
|
Retrieve the default value for a visual property. |
|
Set the default value for a visual property. |
|
Update the default values of visual properties in a style. |
Custom Graphics¶
|
Remove Node Custom Graphics. |
|
Set Node Custom Bar Chart. |
|
Set Node Custom Box Chart. |
|
Set Node Custom HeatMap Chart. |
|
Set Node Custom Line Chart. |
|
Set Node Custom Linear Gradient. |
|
Set Node Custom Pie Chart. |
|
Set Node Custom Position. |
|
Set Node Custom Radial Gradient. |
|
Set Node Custom Ring Chart. |
Node Style Defaults¶
Retrieve the default selection node color. |
|
|
Set the default node border color. |
|
Set defaults opacity value for all unmapped node borders. |
|
Set the default node border width. |
|
Set the default node color. |
|
Set default opacity value for all unmapped nodes. |
|
Set the default node font. |
|
Set the default node font size. |
|
Set the default node height. |
|
Set the default node label color. |
|
Set the default node label. |
|
Set default opacity value for all unmapped node labels. |
|
Set the default node border color. |
|
Set the default node shape. |
|
Set the default node font size. |
|
Set the default node tooltip. |
|
Set the default node width. |
Edge Style Defaults¶
Retrieve the default selected edge color. |
|
|
Set the default edge color. |
|
Set the default edge font. |
|
Set the default edge font size. |
|
Set the default edge label color. |
|
Set the default edge label. |
|
Set default opacity value for all unmapped edges. |
|
Set the default edge style. |
|
Set the default edge width. |
|
Set default opacity value for all unmapped edges. |
|
Set the default selected edge color. |
|
Set the default edge source arrow color. |
|
Set the default edge source arrow shape. |
|
Set the default edge target arrow color. |
|
Set the default edge target arrow shape. |
|
Set the default edge tooltip. |
Network Style Defaults¶
|
Retrieve the default background color. |
|
Set the default background color. |
Style Dependencies¶
# Functions for getting and setting style DEPEDENDENCIES, organized into sections:
General functions for getting and setting dependencies
Specific functions for setting particular dependencies
General Style Dependencies¶
|
Get the values of dependencies in a style. |
|
Set the values of dependencies in a style, overriding any prior setting. |
Custom Graphics¶
|
Set a boolean value to have the size of custom graphics match that of the node. |
Node Style Dependencies¶
|
Set a boolean value to have node width and height fixed to a single size value. |
Edge Style Dependencies¶
|
Set a boolean value to have arrow shapes share the same color as the edge. |
Style Mappings¶
Functions for defining MAPPINGS between table column values and visual properties, organized into sections:
General functions for creating and applying mappings for node, edge and network properties
Specific functions for defining particular node, edge and network properties
See style_auto_mappings for automatic mapping generation
General Style Mappings¶
|
Delete a specified visual style mapping from specified style. |
|
Fetch all visual property mapping in a style. |
|
Fetch a visual property mapping in a style. |
|
Create a mapping between an attribute and a visual property. |
|
Update a visual property mapping in a style. |
Node Style Mappings¶
|
Map table column values to colors to set the node border color. |
|
Set opacity for node border only. |
|
Map table column values to widths to set the node border width. |
|
Map table column values to colors to set the node fill color. |
|
Set opacity for node fill, border and label all together. |
|
Set opacity for node fill only. |
|
Sets font face for node labels. |
|
Map table column values to sizes to set the node size. |
|
Map table column values to the node heights. |
|
Map table column values to colors to set the node border color. |
|
Pass the values from a table column to display as node labels. |
|
Sets opacity for node label only. |
|
Map table column values to shapes to set the node shape. |
|
Map table column values to node sizes. |
|
Pass the values from a table column to display as node tooltips. |
|
Map table column values to the node widths. |
Edge Style Mappings¶
|
Map table column values to colors to set the edge color. |
|
Sets font face for edge labels. |
|
Map table column values to sizes to set the edge size. |
|
Map table column values to colors to set the edge border color. |
|
Pass the values from a table column to display as edge labels. |
|
Sets opacity for edge label only. |
|
Map table column values to styles to set the edge style. |
|
Map table column values to widths to set the node border width. |
|
Map table column values to opacities to set the edge opacity. |
|
Map table column values to colors to set the source arrow color. |
|
Map table column values to shapes to set the source arrow shape. |
|
Map table column values to colors to set the source arrow color. |
|
Map table column values to colors to set the target arrow color. |
|
Map table column values to shapes to set the target arrow shape. |
|
Map table column values to colors to set the target arrow color. |
|
Pass the values from a table column to display as edge tooltips. |
Style Values¶
Functions for retrieving current values for visual properties.
General functions for getting node, edge and network properties
Specific functions for getting particular node, edge and network properties
Node Style Values¶
|
Retrieve the actual fill color of specified nodes. |
|
Retrieve the actual height of specified nodes. |
|
Retrieve the actual x,y position of specified nodes. |
|
Get values for any node property of the specified nodes. |
|
Retrieve the actual size of specified nodes. |
|
Retrieve the actual width of specified nodes. |
Edge Style Values¶
|
Retrieve the actual line color of specified edges. |
|
Retrieve the actual line style of specified edges. |
|
Retrieve the actual line width of specified edge. |
|
Get values for any edge property of the specified edges. |
|
Retrieve the actual target arrow shape of specified edges. |
Network Style Values¶
|
Retrieve the center of specified network. |
|
Get values for any network property. |
|
Retrieve the scale factor of specified network. |
Tables¶
Functions for managing TABLE columns and table column functions, like map and rename, as well as loading and extracting table data in Cytoscape.
Column Manipulation¶
|
Delete a column from node, edge or network tables. |
|
Retrieve the names of all columns in a table. |
|
Retrieve the types of all columns in a table. |
|
Retrieve one or more columns of data from node, edge or network tables. |
|
Set a new name for a column. |
Column Mapping¶
|
Map Table Column. |
Data Values¶
|
Retrieve the value from a specific row and column from node, edge or network tables. |
|
Loads data into Cytoscape tables keyed by row. |
|
Loads data into Cytoscape tables from a tabular file. |
Tools¶
Functions related to TOOLS found in the Tools Menu in Cytoscape.
Browser Control¶
|
Cybrowser Close. |
|
Launch Cytoscape’s internal web browser in a separate window |
|
Cybrowser Hide. |
|
Cybrowser List. |
|
Cybrowser Send. |
|
Cybrowser Show. |
|
Display the version of the CyBrowser app. |
Diffusion¶
|
Diffusion Advanced. |
|
Diffusion Basic. |
Misc¶
|
Calculate various network statistics. |
|
Merge Networks. |
User Interface¶
Functions affecting the USER INTERFACE, such as panel management.
Panels¶
|
Dock a panel back into the UI of Cytoscape. |
|
Pop out a panel from the UI of Cytoscape. |
|
Hide control, table, tool and results panels. |
|
Hide a panel in the UI of Cytoscape. |
Utils¶
Utility functions useful across multiple modules.
Translation to/from SUIDs¶
|
Translate one edge name or a list of edge names into a list of SUIDs. |
|
Translate one edge SUID or a list of edge SUIDs into a list of names. |
|
Translate one node name or a list of node names into a list of SUIDs. |
|
Translate one node SUID or a list of node SUIDs into a list of names. |
Miscellaneous¶
|
Append a command (if it exists) to a base URL. |
|
Supply a set of colors from Brewer palettes (without requiring rColorBrewer). |
|
Checks to see if a particular column name exists in the specific table. |
|
Throws exception if min supported versions of api and cytoscape are not running. |
Logging¶
py4cytoscape logging is based on the Python logging
package, which is based on Java’s logging
framework.
py4cytoscape emits log entries in SysLog format. For example:
[INFO] py4...S: ǀHTTP DELETE(http://localhost:1234/v1/networks)
[INFO] py4...S: ǀOK[200]
[INFO]
is the priority level.
py4...S
the name of the py4cytoscape package.
The count of |
indicates the nesting level of the currently executing code, where ||
indicates log entries called from code at the |
level.
The remainder of the message contains the logged information. In the example above, an HTTP DELETE call is logged along with the HTTP server’s reply.
Logger configuration is available in the py4cytoscape_logger_settings.py
module. py4cytoscape emits two independent logging streams: Summary (to the console) and Detail (to a file in the logs
directory).
By default, Summary logging is the short form (priority INFO
), which shows HTTP calls and results. You can disable Summary logging by setting _SUMMARY_LOG_LEVEL
to NOTSET
, and you can enable full logging by setting it to DEBUG
.
By default, Detail logging is the long form (priority DEBUG
), and is controlled by the _DETAIL_LOG_LEVEL
setting.
Here is an example of Detail logging involving nested calls:
2020-06-06 15:29:55,721 [DEBUG] py4...: ǀCalling cytoscape_version_info(base_url='http://localhost:1234/v1')
2020-06-06 15:29:55,721 [DEBUG] py4...: ǀǀCalling cyrest_get('version', base_url='http://localhost:1234/v1')
2020-06-06 15:29:55,721 [DEBUG] py4...: ǀǀHTTP GET(http://localhost:1234/v1/version)
2020-06-06 15:29:55,737 [DEBUG] py4...: ǀǀOK[200], content: {"apiVersion":"v1","cytoscapeVersion":"3.9.0-SNAPSHOT"}
2020-06-06 15:29:55,738 [DEBUG] py4...: ǀǀReturning 'cyrest_get': {'apiVersion': 'v1', 'cytoscapeVersion': '3.9.0-SNAPSHOT'}
2020-06-06 15:29:55,738 [DEBUG] py4...: ǀReturning 'cytoscape_version_info': {'apiVersion': 'v1', 'cytoscapeVersion': '3.9.0-SNAPSHOT'}
py4cytoscape
logs are stored in the logs
directory relative to the Python workflow’s
current directory.
Runtime Control¶
For convenience, Summary logging can be controlled using an environment variable or at execution time. By default, Summary logging is disabled, but can be enabled:
set PY4CYTOSCAPE_SUMMARY_LOGGER=True
At execution time, it can be enabled by calling set_summary_logger()
. This is handy within a busy code block or when running in a Notebook environment. For example:
old_state = set_summary_logger(True)
# ... make several py4cytoscape calls ...
set_summary_logger(old_state)
Release Log¶
py4cytoscape 0.0.9¶
Release date: 3 Jun 2021
Updated documentation and tutorials
Reworked iGraph support to track RCy3 implementation
Added iGraph support for Graph, DiGraph, MultiGraph, MultiDiGraph
Updated node/edge-to-suid functions to allow detection of multiple copies of a node/edge
Enabled delete_duplicate_edges to ignore edge direction
Added support for discrete and continuous value generators (as gen* functions in new style_auto_mappers module)
Release notes¶
Announcement: py4cytoscape 0.0.9¶
We’re happy to announce the release of py4cytoscape 0.0.9!
py4cytoscape is a Python package that communicates with Cytoscape via its REST API, providing access to a set over 250 functions that enable control of Cytoscape from within standalone and Notebook Python programming environments. It provides nearly identical functionality to RCy3, an R package in Bioconductor available to R programmers.
Highlights¶
This themes for this release are:
Improved documentation and tutorials
Improved iGraph support (consistent with RCy3)
Allow edge direction to be ignored when deleting duplicate edges
Automatic value generators (including Brewer colors) for style mappings
Many of these themes support the definition and execution of the GangSu workflows.
API Changes¶
Added style_auto_mappers.py module to support automatic value generators
Added ignore_direction=False parameter for delete_duplicate_edges
Added unique_list=True to node/edge_name_to_suid utility functions
Added Value Generators section in Concepts documentation
Added iGraph support for Graph, DiGraph, MultiGraph, MultiDiGraph in create_network_from_networkx
Deprecations¶
None
Contributors to this release¶
Barry Demchak
Yihang Xin
Alex Pico
Kozo Nishida
Pull requests merged in this release¶
#46 by Kozo Nishida
#47 by Kozo Nishida
#48 by Kozo Nishida
#50 by Kozo Nishida
#51 by Kozo Nishida
Issues closed in this release¶
#41 by Alex Pico
#43 by Barry Demchak
#45 by Kozo Nishida
#49 by Jiafi
py4cytoscape 0.0.8¶
Release date: 26 Mar 2021
Added parameters in CyNDEX functions to support subdomains
Added apply= parameter in filter definition functions to support Cytoscape v3.9.0 separating apply from definition
Added overwrite_file parameter to export functions
Added Sandbox direct download from URL
Added functions for import network from tabular file & get current style, etc
Fixes that allow commands_help to work
Release notes¶
Announcement: py4cytoscape 0.0.8¶
We’re happy to announce the release of py4cytoscape 0.0.8!
py4cytoscape is a Python package that communicates with Cytoscape via its REST API, providing access to a set over 250 functions that enable control of Cytoscape from within standalone and Notebook Python programming environments. It provides nearly identical functionality to RCy3, an R package in Bioconductor available to R programmers.
Highlights¶
This themes for this release are:
Enable access to NDEx subdomains
Support Cytoscape v3.9 separation of filter definition from execution
Enable export functions to avoid popping a confirmation dialog
Enable cloud files to be downloaded directly to Sandbox
Fixes that allow commands_help to work
Many of these themes support the definition and execution of the GangSu workflows.
API Changes¶
Added parameters in CyNDEX functions to support subdomains
Added apply= parameter in filter definition functions to support Cytoscape v3.9.0 separating apply from definition
Added overwrite_file parameter to export functions
Added Sandbox direct download from URL
Added functions for import network from tabular file & get current style, etc
Deprecations¶
None
Contributors to this release¶
Barry Demchak
Yihang Xin
Alex Pico
Pull requests merged in this release¶
py4cytoscape 0.0.7¶
Release date: 08 Jan 2021
Compatibility of node, edge and group parameter with RCy3 formats
Improved verify_supported_versions parsing for Cytoscape 3.10 and beyond
Release notes¶
Announcement: py4cytoscape 0.0.7¶
We’re happy to announce the release of py4cytoscape 0.0.7!
py4cytoscape is a Python package that communicates with Cytoscape via its REST API, providing access to a set over 250 functions that enable control of Cytoscape from within standalone and Notebook Python programming environments. It provides nearly identical functionality to RCy3, an R package in Bioconductor available to R programmers.
Highlights¶
This themes for this release are:
Compatibility of node, edge and group parameter with RCy3 formats
Improved verify_supported_versions parsing for Cytoscape 3.10 and beyond
API Changes¶
None
Deprecations¶
None
Contributors to this release¶
Barry Demchak
Jorge Boucas
Kozo Nishida
Pull requests merged in this release¶
py4cytoscape 0.0.6¶
Release date: 30 Oct 2020
Made default directory for standalone Python the same as the Python kernel directory
Shortened delays that wait for Cytoscape to stabilize, removed NDEx function delays
Began docker support
Improved sandboxing and Jupyter Notebook documentation
Added shorter test (test_sanity) for quick installation verification
Release notes¶
Announcement: py4cytoscape 0.0.6¶
We’re happy to announce the release of py4cytoscape 0.0.6!
py4cytoscape is a Python package that communicates with Cytoscape via its REST API, providing access to a set over 250 functions that enable control of Cytoscape from within standalone and Notebook Python programming environments. It provides nearly identical functionality to RCy3, an R package in Bioconductor available to R programmers.
Highlights¶
This themes for this release are:
Improved sandboxing and Jupyter Notebook documentation
Shortened execution delays
Docker support
More rational default directory for standalone Python execution
API Changes¶
None
Deprecations¶
None
Contributors to this release¶
Barry Demchak
Jorge Boucas
Kozo Nishida
Pull requests merged in this release¶
#17 Jorge Boucas
#18 Jorge Boucas
py4cytoscape 0.0.5¶
Release date: 15 Oct 2020
Referenced Concepts:Sandboxing from documentation for sandbox functions
Updated installation and logging documentation
Updated test to detect Colab shell
Release notes¶
Announcement: py4cytoscape 0.0.5¶
We’re happy to announce the release of py4cytoscape 0.0.5!
py4cytoscape is a Python package that communicates with Cytoscape via its REST API, providing access to a set over 250 functions that enable control of Cytoscape from within standalone and Notebook Python programming environments. It provides nearly identical functionality to RCy3, an R package in Bioconductor available to R programmers.
Highlights¶
This themes for this release are:
Improved sandboxing documentation
Updated test for Colab shell to track Colab internal evolution
API Changes¶
None
Deprecations¶
None
Contributors to this release¶
Barry Demchak
Pull requests merged in this release¶
None
py4cytoscape 0.0.4¶
Release date: 05 Oct 2020
Corrected a build problem that stopped 0.0.3 from initializing
Release notes¶
Announcement: py4cytoscape 0.0.4¶
We’re happy to announce the release of py4cytoscape 0.0.4!
py4cytoscape is a Python package that communicates with Cytoscape via its REST API, providing access to a set over 250 functions that enable control of Cytoscape from within standalone and Notebook Python programming environments. It provides nearly identical functionality to RCy3, an R package in Bioconductor available to R programmers.
Highlights¶
This themes for this release are:
Correct a build problem that left 0.0.3 unable to initialize
API Changes¶
None
Deprecations¶
None
Contributors to this release¶
Barry Demchak
Pull requests merged in this release¶
None
py4cytoscape 0.0.3¶
Release date: 05 Oct 2020
Conform to Cytoscape Automation API Definition
Change CyError logger to write exceptions to stderr
Add Sandboxing interface and functions
Add merge_network() and analyze_network()
Add Jupyter-bridge, Cytoscape Automation API, py4cytoscape versions to cytoscape_version_info
Add support for Jupyter-bridge
Add Concepts section to documentation
Release notes¶
Announcement: py4cytoscape 0.0.3¶
We’re happy to announce the release of py4cytoscape 0.0.3!
py4cytoscape is a Python package that communicates with Cytoscape via its REST API, providing access to a set over 250 functions that enable control of Cytoscape from within standalone and Notebook Python programming environments. It provides nearly identical functionality to RCy3, an R package in Bioconductor available to R programmers.
Highlights¶
This themes for this release are:
Add support for remote Notebook execution (via Jupyter-Bridge)
Sync with changes made to RCy3 since Jan 1, 2020
Remote Notebook execution involves a round trip between the Python kernel running on a remote server and Cytoscape running on a private workstation. The main component is Jupyter-Bridge, which routes py4cytoscape requests through the user’s browser and on to Cytoscape, and then returns the result in the reverse direction. Requests and responses are routed through the Jupyter-Bridge server, which is an independent entity on the web.
For most Cytoscape operations, it’s necessary to transfer files from the Notebook server so that Cytoscape can load them, or to transfer files created by Cytoscape to the Notebook server so Python can analyze them. Sandboxing was implemented to enable these transfers, and to enable portability of workflows across different Cytoscape workstations.
Finally, py4cytoscape functions and definitions were sync’d with RCy3 changes since 1/1/20, and a reference interface spec was created independent of py4cytoscape and RCy3: Conform to Cytoscape Automation API Definition.
API Changes¶
Add tools.merge_networks() and tools.analyze_network()
Add sandbox.* functions
Added a number of maintenance functions in commands and py4cytoscape_sandbox modules
Deprecations¶
None
Contributors to this release¶
Barry Demchak
Alex Pico
Kozo Nashida
Chris Churas
Yasir Demirtaş
Pull requests merged in this release¶
None
py4cytoscape 0.0.1¶
Release date: 21 Aug 2020
Initial release, matches API signatures for RCy3
Release notes¶
Announcement: py4cytoscape 0.0.1¶
We’re happy to announce the release of py4cytoscape 0.0.1!
py4cytoscape is a Python package that communicates with Cytoscape via its REST API, providing access to a set over 250 functions that enable control of Cytoscape from within standalone and Notebook Python programming environments. It provides nearly identical functionality to RCy3, an R package in Bioconductor available to R programmers.
Highlights¶
This themes for this release are:
Reproduce RCy3 functions
Create a testing system for all functions
Create the py4cytoscape user documentation
API Changes¶
None
Deprecations¶
None
Contributors to this release¶
Barry Demchak
Alex Pico
Kozo Nashida
Jorge Bouças
Stevan Georg
Chris Churas
Pull requests merged in this release¶
Set dependencies #10
Fixed broken link to the tutorials page on readthedocs #9
In the Verify Cytoscape connection code fragment made file path platform agnostic #8
Add how to try tutorial without installation (by using Binder) #6
Add a tutorial ipynb file to the Sphinx source #5
Move python-igraph from extras_require to install_requires #4
Rename the package name #3
Add How to install and use #2
License¶
Released under the MIT License:
Copyright (c) 2018-2020 The Cytoscape Consortium
Barry Demchak <bdemchak@ucsd.edu>
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Credits¶
py4cytoscape
was originally written by Barry Demchak with the help of many others, particularly the developers
of RCy3, on which py4cytoscape
is based.
Thanks to everyone who has
improved py4cytoscape
by contributing code, bug reports (and fixes), documentation,
and input on design, features, and the future of py4cytoscape
.
Contributions¶
This section aims to provide a list of people and projects that have
contributed to py4cytoscape
. It is intended to be an inclusive list, and
anyone who has contributed and wishes to make that contribution known is
welcome to add an entry into this file. Generally, no name should be added to
this list without the approval of the person associated with that name.
Creating a comprehensive list of contributors can be difficult, and the list within this file is almost certainly incomplete. Contributors include testers, bug reporters, contributors who wish to remain anonymous, funding sources, academic advisors, end users, and even build/integration systems.
Do you want to make your contribution known? If you have commit access, edit this file and add your name. If you do not have commit access, feel free to open an issue, submit a pull request, or get in contact with one of the official team members.
Original Authors¶
Contributors¶
Optionally, add your desired name and include a few relevant links. The order is partially historical, and now, mostly arbitrary.
Keiichiro Ono, GitHub: keiono
Jorge Bouças, GitHub: jorgeboucas
Kozo Nishida, GitHub: kozo2
Barry Demchak, GitHub: bdemchak
Alex Pico, GitHub: AlexanderPico
Mark Grimes, GitHub: mark-grimes
Julia Gustavsen, GitHub: jooolia
Shraddha Pai, GitHub: shraddhapai
Ruth Isserlin, GitHub: risserlin
Paul Shannon, GitHub: paul-shannon
Tanja Muetze, GitHub: tmuetze
Georgi Kolishkovski
David Otasek, GitHub: dotasek
Yihang Xin, Github: yihangx
The NetworkX documentation is excellent, and we borrowed both wording and structure liberally.
Support¶
py4cytoscape
and those who have contributed to py4cytoscape
have received
support throughout the years from a variety of sources. We list them below.
If you have provided support to py4cytoscape
and a support acknowledgment does
not appear below, please help us remedy the situation, and similarly, please
let us know if you’d like something modified or corrected.
Funding¶
py4cytoscape
acknowledges support from the following:
US National Institute of General Medical Sciences (NIGMS), award number R01 GM070743, PI: Trey Ideker
National Resource for Network Biology (NRNB), award number P41 GM103504, PI: Trey Ideker
Torrey Pines Software, Inc, President: Barry Demchak
Citing¶
There is no paper (yet) that describes py4cytoscape.