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.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.

  • 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:

    1. a list of (View, Track) tuples
    2. a list of Tracks (assumes that there is only one view)
    3. 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.

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.viewer.save_b64_image_to_png(filename, b64str)[source]

Save a base64 encoded image to a file.


class higlass.client.Track(track_type=None, position=None, tileset=None, file_url=None, filetype=None, options=None, **kwargs)[source]

Configure a Track

  • 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

Change an attribute of this track and return a new copy.


Change one of the track’s options in the viewconf

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

  • 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.

  • 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 in track. If it does not exist, we fall back on a default position if the track type has one.

Convert the existing track to a JSON representation.

class higlass.client.ViewConf(views=[], location_syncs=[], value_scale_syncs=[], zoom_syncs=[])[source]

Configure a dashboard


Add a new view

Parameters:view (View) – View object to add

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.


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.

  • 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.

Return the chromosome sizes from the given filename

start(debug=False, **kwargs)[source]

Start a lightweight higlass server.

  • debug (bool) – Run the server in debug mode. Default is False.
  • kwargs – Additional options to pass to

Stop this server so that the calling process can exit

tiles(uid, z, x, y=None)[source]

Return tiles from the specified dataset (uid) at the given position (z,x,[u])


Return the tileset info for the given tileset