py4cytoscape.filters.create_degree_filter

create_degree_filter(filter_name, criterion, predicate='BETWEEN', edge_type='ANY', hide=False, network=None, base_url='http://127.0.0.1:1234/v1', *, apply=True)[source]

Create Degree Filter.

Creates a filter to control node selection base on in/out degree.

Parameters
  • filter_name (str) – Name for new filter.

  • criterion (list) – A two-element vector of numbers, example: [1,5].

  • predicate (str) – BETWEEN (default) or IS_NOT_BETWEEN

  • edgeType (str) – Type of edges to consider in degree count: ANY (default), UNDIRECTED, INCOMING, OUTGOING, DIRECTED

  • hide (bool) – Whether to hide filtered out nodes and edges. Default is FALSE. Ignored if all nodes or edges are filtered out. This is an alternative to filtering for node and edge selection.

  • network (SUID or str or None) – Name or SUID of the network. 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://localhost:1234 and the latest version of the CyREST API supported by this version of py4cytoscape.

  • apply (bool) – True to execute filter immediately; False to define filter but not execute it

Returns

{‘nodes’: <node list>, ‘edges’: <edge list>} returns list of nodes and edges selected after filter executes; None if filter wasn’t applied

Return type

dict

Raises
  • CyError – if criterion is not list of two values or filter couldn’t be applied

  • requests.exceptions.RequestException – if can’t connect to Cytoscape or Cytoscape returns an error

Examples

>>> create_degree_filter('myFilter', [2, 5]) # filter on any nodes having between 2 and 5 edges
{'nodes': ['YDR395W', 'YLR362W', 'YPL248C', 'YGL035C'], 'edges': None}
>>> create_degree_filter('myFilter', [2, 5], predicate='IS_NOT_BETWEEN') # filter for edges < 2 or > 5
{'nodes': ['YDR395W', 'YLR362W', 'YPL248C', 'YGL035C'], 'edges': None}
>>> create_column_filter('myFilter', [2, 5], edge_type='INCOMING') # filter for between 2 and 5 incoming edges
{'nodes': ['YDR395W', 'YLR362W', 'YPL248C', 'YGL035C'], 'edges': None}
>>> create_column_filter('myFilter', [2, 5], hide=True) # filter for between 2 and 5 edges, and hide them
{'nodes': ['YDR395W', 'YLR362W', 'YPL248C', 'YGL035C'], 'edges': None}
>>> create_column_filter('myFilter', [2, 5], apply=False) # define filter for between 2 and 5 edges, and hide them
{'nodes': ['YDR395W', 'YLR362W', 'YPL248C', 'YGL035C'], 'edges': None}