py4cytoscape.style_auto_mappings.gen_edge_color_map

gen_edge_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 an edge 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 the mapping_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 edge 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_edge_color_map('interaction', mapping_type='d')
{'table_column': 'interaction', 'table_column_values': ['pp', 'pd'], 'colors': ['#66C2A5', '#FC8D62'], 'mapping_type': 'd', 'default_color': None, 'style_name': None, 'network': None, 'base_url': 'http://127.0.0.1:1234/v1'}
>>> gen_edge_color_map('interaction', palette_color_brewer_q_Accent(), mapping_type='d')
{'table_column': 'interaction', 'table_column_values': ['pp', 'pd'], 'colors': ['#7FC97F', '#BEAED4'], 'mapping_type': 'd', 'default_color': None, 'style_name': None, 'network': None, 'base_url': 'http://127.0.0.1:1234/v1'}
>>> gen_edge_color_map('EdgeBetweenness')
{'table_column': 'EdgeBetweenness', 'table_column_values': [2.0, 9591.11110001, 19180.22220002], 'colors': ['#E0F3DB', '#A8DDB5', '#43A2CA'], 'mapping_type': 'c', 'default_color': None, 'style_name': None, 'network': None, 'base_url': 'http://127.0.0.1:1234/v1'}
>>> gen_edge_color_map('EdgeBetweenness', palette_color_brewer_s_Blues())
{'table_column': 'EdgeBetweenness', 'table_column_values': [2.0, 9591.11110001, 19180.22220002], 'colors': ['#DEEBF7', '#9ECAE1', '#3182BD'], 'mapping_type': 'c', 'default_color': None, 'style_name': None, 'network': None, 'base_url': 'http://127.0.0.1:1234/v1'}
>>> gen_edge_color_map('EdgeBetweenness', (palette_color_brewer_s_Blues(), palette_color_brewer_d_BrBG()))
{'table_column': 'EdgeBetweenness', 'table_column_values': [2.0, 9591.11110001, 19180.22220002], 'colors': ['#DEEBF7', '#9ECAE1', '#3182BD'], 'mapping_type': 'c', 'default_color': None, 'style_name': None, 'network': None, 'base_url': 'http://127.0.0.1:1234/v1'}

See also

set_edge_color_mapping(), set_edge_label_color_mapping(), set_edge_source_arrow_color_mapping(), set_edge_target_arrow_color_mapping()

See also

Value Generators in the Concepts section in the py4cytoscape User Manual.