Open manzt opened 1 year ago
Another option would be to create a top-level hg.tileset
(akin to hg.view
and hg.track
) that deals with the server behind the scenes:
import higlass as hg
tileset = hg.tileset("./data.mcool", type="cooler")
track = tileset.track("heatmap")
hg.view(track)
The server is not a detail we can really hide, so I'd prefer a more explicit API like the first proposal. With the alternative one, most users would be surprised that simply creating a tileset is having server manipulation side effects behind the scenes.
Motivation
The existing approach of adding multiple tileset helpers (e.g.,
hg.cooler
,hg.bigwig
, etc.) to thehg.server
facilitates the creation and addition of tilesets. Although this method is works "fine", it has some potential drawbacks and I'm not thrilled with the inconsistency of the API.Issues
Confusing Usage / Naming Around Tilesets
Our present system exports all tileset helpers from a top-level flat namespace for convenience. However, it fails to distinguish "tilesets" from other API components associated with view configuration such as
hg.view
orhg.track
. For context, this caused confusion in a code snippet I shared at ISMB conference, where the similar functions ofhg.remote
andhg.cooler
were unclear.A potential solution could involve grouping tilesets under a separate namespace like
hg.tilesets.cooler
, but I also see drawbacks in this approach (beyond being more verbose – see next).Limited Scalability and Extensibility
We aim to simplify the implementation of custom tilesets, however, the current system further convolutes that folks actually have control over the server due to the differences in the API. The tileset helpers hide the server, but if you want a custom tileset you need to find the server. E.g.,
Additionally adding nice tileset helpers requires making changes to
higlass-python
. I think the best user experience would be to let someonepip install custom-tileset
and this now works like our builtin tilesets.Ideas
I'm been mulling over what a plugin-system / registry for tilesets could look like. I think ideally the end-user API could look something like:
You could imagine a registry of tileset helpers per server instance that know how to handle an object:
And then plugins could register themselves for the
hg.server
: