py4cytoscape.style_auto_mappings.gen_node_color_map¶
-
gen_node_color_map
(table_column, palette={'c': (('palette_color_brewer_s_GnBu', 'sequential', <function palette_color_brewer_s_GnBu.<locals>.<lambda>>), ('palette_color_brewer_d_RdYlBu', 'divergent', <function palette_color_brewer_d_RdYlBu.<locals>.<lambda>>)), 'd': ('palette_color_brewer_q_Set2', 'qualitative', <function palette_color_brewer_q_Set2.<locals>.<lambda>>)}, mapping_type='c', default_color=None, style_name=None, network=None, base_url='http://127.0.0.1:1234/v1')[source]¶ Generate color map parameters for discrete or continuous values in a node table
A basic palette is a tuple containing the palette function name, palette type, and a lambda resolving to an actual Brewer palette. There are a few ways a palette can be encoded in the
palette
parameter. The most generic is a dictionary that identifies which basic palette to use if themapping_type
is discrete or continuous. Or the basic palette can be provided directly (without being in a dict). Either way, For discrete mappings, the basic palette that should be qualitative. For continuous mappings, either one or two basic palettes can be provided. If only one, that basic palette will be used whether the Cytoscape column data turns out to be 1-tailed or 2-tailed. If two basic palettes are provided, the second will be used if the Cytoscape column data turns out to be 2-tailed. Basic palettes for 1-tailed data should be sequential palettes, and for 2-tailed data should be divergent palettes.- Parameters
table_column (str) – Name of Cytoscape node table column to map values from
palette (dict or tuple) – Descriptor for functions that return a color list of a given length
mapping_type (str) – continuous or discrete (c, d); default is continuous
default_color (str) – Hex color to set as default
style_name (str) – name for style
network (SUID or str or None) – Name or SUID of a network or view. Default is the “current” network active in Cytoscape.
base_url (str) – 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.
- Returns
Collection of parameter values suitable for passing to a color style_mappings setter function
- Return type
dict
- Raises
CyError – if network doesn’t exist, or mapping_type is unsupported, or continuous mapping attempted on non-numeric values
requests.exceptions.RequestException – if can’t connect to Cytoscape or Cytoscape returns an error
Examples
>>> gen_node_color_map('newcol', mapping_type='d') {'table_column': 'newcol', 'table_column_values': ['3'], 'colors': ['#66C2A5'], 'mapping_type': 'd', 'default_color': None, 'style_name': None, 'network': None, 'base_url': 'http://127.0.0.1:1234/v1'} >>> gen_node_color_map('newcol', palette_color_brewer_q_Accent(), mapping_type='d', default_color='#00FF00', style_name='galFiltered Style', network='galFiltered.sif') {'table_column': 'newcol', 'table_column_values': ['3'], 'colors': ['#7FC97F'], 'mapping_type': 'd', 'default_color': '#00FF00', 'style_name': 'galFiltered Style', 'network': 'galFiltered.sif', 'base_url': 'http://127.0.0.1:1234/v1'} >>> gen_node_color_map('newcol', style_name='galFiltered Style') {'table_column': 'newcol', 'table_column_values': [1, 4.5, 8], 'colors': ['#E0F3DB', '#A8DDB5', '#43A2CA'], 'mapping_type': 'c', 'default_color': None, 'style_name': 'galFiltered Style', 'network': None, 'base_url': 'http://127.0.0.1:1234/v1'}
See also
set_node_border_color_mapping()
,set_node_color_mapping()
,set_node_label_color_mapping()
See also
Value Generators in the Concepts section in the py4cytoscape User Manual.