py4cytoscape.filters.create_column_filter

create_column_filter(filter_name, column, criterion, predicate, caseSensitive=False, anyMatch=True, type='nodes', hide=False, network=None, base_url='http://127.0.0.1:1234/v1', *, apply=True)[source]

Create Column Filter.

Create a filter to control node or edge selection. Works on columns of boolean, string, numeric and lists. Note the unique restrictions for criterion and predicate depending on the type of column being filtered.

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

  • column (str) – Table column to base filter upon.

  • criterion (list, bool, str, int or float) – For boolean columns: True or False. For string columns: a string value, e.g., “hello”. If the predicate is REGEX then this can be a regular expression as accepted by the Java Pattern class (https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html). For numeric columns: If the predicate is BETWEEN or IS_NOT_BETWEEN then this is a two-element list of numbers, example: [1,5], otherwise a single number.

  • predicate (str) – For boolean columns: IS, IS_NOT. For string columns: IS, IS_NOT, CONTAINS, DOES_NOT_CONTAIN, REGEX. For numeric columns: IS, IS_NOT, GREATER_THAN, GREATER_THAN_OR_EQUAL, LESS_THAN, LESS_THAN_OR_EQUAL, BETWEEN, IS_NOT_BETWEEN.

  • caseSensitive (bool) – If string matching should be case sensitive. Default is FALSE.

  • anyMatch (bool) – Only applies to List columns. If true then at least one element in the list must pass the filter, if false then all the elements in the list must pass the filter. Default is TRUE.

  • type (str) – Apply filter to “nodes” (default) or “edges”.

  • 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 column doesn’t exist in the table named by type or filter couldn’t be applied

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

Examples

>>> create_column_filter('myFilter', 'log2FC', [-1,1], "IS_NOT_BETWEEN") # filter on numeric value log2FC
{'nodes': ['YDR395W', 'YLR362W', 'YPL248C', 'YGL035C'], 'edges': None}
>>> create_column_filter('myFilter', 'pValue', 0.05, "LESS_THAN") # Filter on floating point column pValue
{'nodes': ['YDR395W', 'YLR362W', 'YPL248C', 'YGL035C'], 'edges': None}
>>> create_column_filter('myFilter', 'function', "kinase", "CONTAINS", False) # Function on string column name
{'nodes': ['YDR395W', 'YLR362W', 'YPL248C', 'YGL035C'], 'edges': None}
>>> create_column_filter('myFilter', 'name', "^Y.*C$", "REGEX") # Filter on string column name
{'nodes': ['YDR395W', 'YLR362W', 'YPL248C', 'YGL035C'], 'edges': None}
>>> create_column_filter('myFilter', 'isTarget', True , "IS") # Filter on boolean column isTarget
{'nodes': ['YDR395W', 'YLR362W', 'YPL248C', 'YGL035C'], 'edges': None}
>>> create_column_filter('myFilter', 'isTarget', True , "IS", hide=True) # Filter on boolean column isTarget
{'nodes': ['YDR395W', 'YLR362W', 'YPL248C', 'YGL035C'], 'edges': None}
>>> create_column_filter('myFilter', 'Betweenness', [300, 600] , "BETWEEN", type='edges') # Filter edges
{'nodes': None, 'edges': [{'YPR119W (pd) YMR043W', 'YDR412W (pp) YPR119W'}]}
>>> create_column_filter('myFilter', 'Betweenness', [300, 600] , "BETWEEN", type='edges', apply=False) # Define filter
{'nodes': None, 'edges': [{'YPR119W (pd) YMR043W', 'YDR412W (pp) YPR119W'}]}