py4cytoscape.filters.create_composite_filter

create_composite_filter(filter_name, filter_list, type='ALL', hide=False, network=None, base_url='http://127.0.0.1:1234/v1', *, apply=True)[source]

Combine filters to control node and edge selection based on previously created filters.

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

  • filter_list (list) – List of names of filters to combine.

  • type (str) – Type of composition, requiring ALL (default) or ANY filters to pass for final node and edge selection.

  • 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 filter list contains less than one filter or has filters that don’t exist, or filter couldn’t be applied

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

Examples

>>> create_composite_filter('New Filter', ['degree filter 1x', 'degree filter 2x'])
{'nodes': ['YDR395W', 'YLR362W', 'YPL248C', 'YGL035C'], 'edges': None}
>>> create_composite_filter('New Filter', ['degree filter 1x', 'column filter 10x'], type='ANY', network="My network")
{'nodes': ['YDR395W', 'YLR362W', 'YPL248C', 'YGL035C'], 'edges': [{'YPR119W (pd) YMR043W', 'YDR412W (pp) YPR119W'}]}
>>> create_composite_filter('New Filter', ['degree filter 1x', 'degree filter 2x'], hide=True)
{'nodes': ['YDR395W', 'YLR362W', 'YPL248C', 'YGL035C'], 'edges': None}
>>> create_composite_filter('New Filter', ['degree filter 1x', 'degree filter 2x'], apply=False)
{'nodes': ['YDR395W', 'YLR362W', 'YPL248C', 'YGL035C'], 'edges': None}