py4cytoscape.tables.load_table_data

load_table_data(data, data_key_column='row.names', table='node', table_key_column='name', namespace='default', network=None, base_url='http://127.0.0.1:1234/v1')[source]

Loads data into Cytoscape tables keyed by row.

This function loads data into Cytoscape node/edge/network tables provided a common key, e.g., name. Data.frame column names will be used to set Cytoscape table column names. Numeric values will be stored as Doubles in Cytoscape tables. Integer values will be stored as Integers. Character or mixed values will be stored as Strings. Logical values will be stored as Boolean. Lists are stored as Lists by CyREST v3.9+. Existing columns with the same names will keep original type but values will be overwritten.

Parameters
  • data (dataframe) – each row is a node and columns contain node attributes

  • data_key_column (str) – name of data.frame column to use as key; ‘ default is “row.names”

  • table (str) – name of Cytoscape table to load data into, e.g., node, edge or network; default is “node”

  • table_key_column (str) – name of Cytoscape table column to use as key; default is “name”

  • namespace (str) – Namespace of table. Default is “default”.

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

Returns

‘Success: Data loaded in <table name> table’ or ‘Failed to load data: <reason>’

Return type

str

Raises
  • HTTPError – if table or namespace or table doesn’t exist in network

  • CyError – if network name or SUID doesn’t exist

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

Examples

>>> data = df.DataFrame(data={'id':['New1','New2','New3'], 'newcol':[1,2,3]})
>>> load_table_data(data, data_key_column='id', table='node', table_key_column='name')
'Failed to load data: Provided key columns do not contain any matches'
>>> data = df.DataFrame(data={'id':['YDL194W','YDR277C','YBR043C'], 'newcol':[1,2,3]})
>>> load_table_data(data, data_key_column='id', table='node', table_key_column='name', network='galfiltered.sif')
'Success: Data loaded in defaultnode table'