Python API¶
The HiGlass python API provides a functionality for starting a lightweight server, creating viewconfs and displaying a HiGlass component within Jupyter.
higlass.viewer¶
-
higlass.viewer.
display
(views, location_syncs=[], value_scale_syncs=[], zoom_syncs=[], host='localhost', server_port=None, dark_mode=False, log_level=40, fuse=True, auth_token=None)[source]¶ Instantiate a HiGlass display with the given views.
Parameters: - views – A list of views to display. If the items in the list are lists themselves, then automatically create views out of them.
- location_syncs – A list of lists, each containing a list of views which will scroll together.
- value_scale_syncs –
A list containing the value scale syncs. Each sync can be one of:
- a list of (View, Track) tuples
- a list of Tracks (assumes that there is only one view)
- a list of strings of the form “{viewUid}.{trackUid}”
- zoom_syncs – A list of lists, each containing a list of views that will zoom together.
- host – The host on which the internal higlass server will be running on.
- server_port – The port on which the internal higlass server will be running on.
- dark_mode – Whether to use dark mode or not.
- log_level – Level of logging to perform.
- fuse – Whether to mount the fuse filesystem. Set to False if not loading any data over http or https.
Returns: HiGlassDisplay, server: higlass.server.Server, higlass.client.viewconf) tuple Display is an object used to create a HiGlass viewer within a Jupyter notebook. The server object encapsulates a Flask instance of a higlass server and the viewconf is a Python object containing the viewconf describing the higlass dashboard.
Return type:
higlass.client¶
-
class
higlass.client.
Track
(track_type=None, position=None, tileset=None, file_url=None, filetype=None, options=None, **kwargs)[source]¶ Configure a Track
Parameters: - track_type (str) – The type of track (e.g. ‘heatmap’, ‘line’)
- position (str) – The position of the track (e.g. ‘top’)
- tileset (
Tileset
) – A Tileset being displayed in this track - file_url (str) – An http accessible tileset file
- filetype (str) – The type of the remote tilesets (e.g. ‘bigwig’, ‘cooler’, etc…)
- server (str, optional) – The server name (usually just ‘localhost’)
- height (int, optional) – The height of the track (in pixels)
- width (int, optional) – The width of the track (in pixels)
- options (dict, optional) – The options to pass onto the track
-
class
higlass.client.
View
(tracks=[], x=0, y=0, width=12, height=6, initialXDomain=None, initialYDomain=None, uid=None, overlays=[], chrominfo=None, geneinfo=None)[source]¶ Configure a View
Parameters: - tracks ([]) – A list of Tracks to include in this view
- x (int) – The position of this view on the grid
- y (int) – The position of this view on the grid
- width (int) – The width of this of view on a 12 unit grid
- height (int) – The height of the this view. The height is proportional to the height of all the views present.
- initialXDoamin ([int, int]) – The initial x range of the view
- initialYDomain ([int, int]) – The initial y range of the view
- uid (string) – The uid of new view
-
add_track
(track, position=None)[source]¶ Add a track to a position.
Parameters: - track (
Track
) – Track to add. - position ({'top', 'bottom', 'center', 'left', 'right'}) – Location of track on the view. If not provided, we look for an
assigned
position
attribute intrack
. If it does not exist, we fall back on a default position if the track type has one.
- track (
-
class
higlass.client.
ViewConf
(views=[], location_syncs=[], value_scale_syncs=[], zoom_syncs=[])[source]¶ Configure a dashboard
-
default_view
¶ Default view of the view config
The default view equals the first view if only one view exist.
Returns: View – View instance or None
if more than one view exists.
-
higlass.server¶
-
class
higlass.server.
Server
(tilesets, host='localhost', port=None, name=None, fuse=True, tmp_dir='/tmp', log_level=20, log_file=None)[source]¶ A lightweight HiGlass server.
Parameters: - tilesets (list) – A list of tilesets to serve (see higlass.tilesets)
- host (str, optional) – The host this server is running on. Usually just localhost.
- port (int, optional) – The port that this server will run on.
- name (str, optional) – A name for the Flask app being served. If not provided, a unique name will be generated. The app’s logger inherits this name.
- fuse (bool, optional) – Whether to mount http(s) resources using FUSE.
- tmp_dir (string, optional) – A temporary directory for FUSE to mount the http(s) files and for caching.
- log_level (logging.*) – What level to log at
- log_file (str, optional) – Where to write diagnostic log files. Default is to use a StringIO stream in memory.
-
start
(debug=False, **kwargs)[source]¶ Start a lightweight higlass server.
Parameters: - debug (bool) – Run the server in debug mode. Default is False.
- kwargs – Additional options to pass to app.run