py4cytoscape.networks.import_network_from_tabular_file

import_network_from_tabular_file(file=None, first_row_as_column_names=False, start_load_row=1, column_type_list='s,i,t', delimiters='\\,,\t', base_url='http://127.0.0.1:1234/v1')[source]

Loads a network from specified file.

Note

To load a tabular file from cloud storage, use the file’s URL and the sandbox_url_to function to download the file to a sandbox, and then use import_network_from_tabular_file to load it from there.

Parameters
  • file (str) – Name of file in any of the supported tabular formats (e.g., csv, tsv, Excel, etc).

  • first_row_as_column_names (bool) – True if first row contributes column names but no data values

  • start_load_row (int) – 1-based row to start reading data … after column name row, if present

  • column_type_list (str) – comma-separated map of column types ordered by column index (e.g. “source,target,interaction,source attribute,target attribute,edge attribute,skip” or just “s,t,i,sa,ta,ea,x”); defaults to “s,i,t”

  • delimiters (str) – comma-separated list of characters that can separate columns … \\, is a comma, \t is a tab

  • 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

{“networks”: [network suid], “views”: [suid for views]} where networks and views lists have length 1

Return type

dict

Raises
  • CyError – if file cannot be found or loaded, or if error in tabular_params list

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

Examples

>>> import_network_from_tabular_file('data/yeastHighQuality.sif') # import a SIF-formatted network
{'networks': [131481], 'views': [131850]}
>>> import_network_from_tabular_file('data/disease.net.default.xlsx') # import an Excel file that has no header row
{'networks': [131481], 'views': [131850]}
>>> import_network_from_tabular_file('data/disease.net.default.txt') # import a text file that has no header row
{'networks': [131481], 'views': [131850]}
>>> import_network_from_tabular_file('data/disease.net.interaction.txt', # import ' '-delimited header row and data
>>>                                  first_row_as_column_names=True,
>>>                                  start_load_row=1,
>>>                                  column_type_list='s,t,x,i',
>>>                                  delimiters=' ')
{'networks': [131481], 'views': [131850]}