Skip to content

Commit 379b584

Browse files
committed
Merge branch 'master' into fuse-unmount
2 parents b7046c9 + 4681b78 commit 379b584

File tree

9 files changed

+513
-643
lines changed

9 files changed

+513
-643
lines changed

.github/workflows/docs.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Deploy static content to Pages
2+
3+
on:
4+
# Runs on pushes targeting the default branch
5+
push:
6+
branches: master
7+
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
# Allow one concurrent deployment
18+
concurrency:
19+
group: "pages"
20+
cancel-in-progress: true
21+
22+
jobs:
23+
# Single deploy job since we're just deploying
24+
deploy:
25+
environment:
26+
name: github-pages
27+
url: ${{ steps.deployment.outputs.page_url }}
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v3
32+
33+
- name: Set up Python
34+
uses: actions/setup-python@v4
35+
with:
36+
python-version: "3.x"
37+
38+
- name: Install dependencies
39+
run: |
40+
python -m pip install --upgrade pip
41+
pip install hatch
42+
43+
- name: Build
44+
run: hatch run docs:build
45+
46+
- name: Setup Pages
47+
uses: actions/configure-pages@v3
48+
49+
- name: Upload artifact
50+
uses: actions/upload-pages-artifact@v1
51+
with:
52+
# Upload entire repository
53+
path: './docs/_build/html'
54+
55+
- name: Deploy to GitHub Pages
56+
id: deployment
57+
uses: actions/deploy-pages@v1
58+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ __pycache__/
66
.ipynb_checkpoints/
77
demo/
88
notebooks/mnt/
9+
docs/_build/
910
dist/
1011

1112
hg/_version.py

README.md

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,40 @@ view_lock = hg.lock(view1, view2)
4141

4242
## Development
4343

44-
Create a virtual environment with Jupyter installed.
44+
**higlass-python** uses [the recommended](https://packaging.python.org/en/latest/flow/#) `hatchling` build-system,
45+
which is convenient to use via the [`hatch` CLI](https://hatch.pypa.io/latest/). We recommend installing `hatch`
46+
globally (e.g., via `pipx`) and running the various commands defined within `pyproject.toml`. `hatch` will take care
47+
of creating and synchronizing a virtual environment with all dependencies defined in `pyproject.toml`.
4548

46-
```bash
47-
conda create -n higlass python=3.11 jupyterlab
48-
```
49+
### Commands Cheatsheet
4950

50-
Install the package in _editable_ mode. The `.[dev]` ensures that you also install linting/testing tools.
51+
All commands are run from the root of the project, from a terminal:
5152

52-
```bash
53-
pip install -e ".[dev]"
54-
```
53+
| Command | Action |
54+
| :--------------------- | :------------------------------------------------------------------ |
55+
| `hatch run fix` | Format project with `black .` and apply linting with `ruff --fix .` |
56+
| `hatch run lint` | Lint project with `ruff .`. |
57+
| `hatch run test` | Run unit tests with `pytest` in latest Python version. |
58+
| `hatch run test:test` | Run unit tests with `pytest` in all target Python versions. |
59+
| `hatch run docs:build` | Build the documentation in `docs/_build/html`. |
60+
| `hatch run docs:serve` | Start an dev-server for live editing RST files in `docs/`. |
5561

56-
Our CI checks formatting (`black .`), linting (`ruff .`), and tests (`pytest`).
62+
> **Note**: `hatch build` and `hatch publish` are available to build and publish the project to
63+
PyPI, but all releases are handled automatically via CI.
5764

58-
## Editing the docs
65+
Alternatively, you can develop **higlass-python** by manually creating a virtual environment and
66+
managing installation and dependencies with `pip`. For example, create a virtual environment
67+
with `conda`:
5968

60-
To work on the docs, start the autoserver and edit the rst files in the `docs` directory:
69+
```bash
70+
conda create -n higlass python=3.11
71+
conda activate higlass
72+
```
73+
74+
and install **higlass-python** in _editable_ mode with all optional dependencies:
6175

6276
```bash
63-
cd docs
64-
./serve.sh
77+
pip install -e ".[dev,fuse,docs]"
6578
```
79+
80+
Our CI checks formatting (`black .`), linting (`ruff .`), and tests (`pytest`).

docs/conf.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from docutils import nodes
55
from docutils.parsers.rst import Directive, directives
6+
from higlass import __version__
7+
from pkg_resources import parse_version
68

79
# -*- coding: utf-8 -*-
810
#
@@ -58,24 +60,24 @@
5860

5961
# General information about the project.
6062
project = "HiGlass"
61-
copyright = "2017-2020 HiGlass Authors"
63+
copyright = "2017-2023 HiGlass Authors"
6264
author = "HiGlass Authors"
6365

6466
# The version info for the project you're documenting, acts as replacement for
6567
# |version| and |release|, also used in various other places throughout the
6668
# built documents.
6769
#
6870
# The short X.Y version.
69-
version = "v1.0"
71+
version = parse_version(__version__).base_version
7072
# The full version, including alpha/beta/rc tags.
71-
release = "v1.0"
73+
release = __version__
7274

7375
# The language for content autogenerated by Sphinx. Refer to documentation
7476
# for a list of supported languages.
7577
#
7678
# This is also used if you do content translation via gettext catalogs.
7779
# Usually you set "language" from the command line for these cases.
78-
language = None
80+
language = "en"
7981

8082
# List of patterns, relative to source directory, that match files and
8183
# directories to ignore when looking for source files.
@@ -108,7 +110,7 @@
108110
# Add any paths that contain custom static files (such as style sheets) here,
109111
# relative to this directory. They are copied after the builtin static files,
110112
# so a file named "default.css" will overwrite the builtin "default.css".
111-
html_static_path = ["_static"]
113+
html_static_path = []
112114

113115
# Custom sidebar templates, must be a dictionary that maps document names
114116
# to template names.
@@ -254,3 +256,6 @@ class Vimeo(IframeVideo):
254256
def setup(builder):
255257
directives.register_directive("youtube", Youtube)
256258
directives.register_directive("vimeo", Vimeo)
259+
260+
261+
autodoc_typehints = "none"

docs/examples.rst

Lines changed: 39 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -5,80 +5,36 @@ Synchronizing location, zoom and value scales
55
---------------------------------------------
66

77
To synchronize, the locations, zoom levels and value scales, use the provided
8-
``location_syncs``, ``zoom_syncs`` and ``value_scale_syncs`` parameters of
9-
the of the ``display`` function.
10-
11-
The ``location_syncs`` and ``zoom_syncs`` parameters both take a list of lists
12-
of views which will have their location and / or zoom synchronized. While the
13-
HiGlass implementation allows for synching of location and zoom independently
14-
at a given offset, the Python API currently only allows synchronization at
15-
the same location and / or same zoom level. It is highly recommended that the
16-
zoom and location syncs are both provided and identical to ensure that zoom
17-
and location change together in the provided list of views.
18-
19-
.. code-block:: python
20-
21-
from higlass.client import View, Track
22-
import higlass
23-
24-
t1 = Track(track_type='top-axis', position='top')
25-
t2 = Track(track_type='heatmap', position='center',
26-
tileset_uuid='CQMd6V_cRw6iCI_-Unl3PQ',
27-
server="http://higlass.io/api/v1/")
28-
29-
# the entire viewport has a width of 12 so a width of 6 for
30-
# each view means they take up half the width
31-
view1 = View([t1, t2], width=6)
32-
view2 = View([t1, t2], width=6, x=6)
33-
34-
display, server, viewconf = higlass.display(
35-
[view1, view2],
36-
location_syncs = [[view1, view2]],
37-
zoom_syncs = [[view1, view2]],
38-
value_scale_syncs = [[(view1, t2), (view2, t2)]])
39-
display
40-
41-
42-
BAM Files
43-
---------
44-
45-
View sequencing read mappings. First we must load the `higlass-pileup plugin track <https://github.com/higlass/higlass-pileup>`_:
8+
``hg.lock`` to create a lock object and then register the given lock for the
9+
visualization with ``hg.Viewconf.locks()``.
4610

4711
.. code-block:: python
4812
49-
%%javascript
50-
51-
require(["https://unpkg.com/higlass-pileup/dist/higlass-pileup.min.js"],
52-
function(hglib) {
13+
import higlass as hg
5314
54-
});
55-
56-
And then we can view pileups:
57-
58-
.. code-block:: python
15+
ts = hg.remote(
16+
uid='CQMd6V_cRw6iCI_-Unl3PQ',
17+
server="http://higlass.io/api/v1/",
18+
)
5919
60-
import higlass
61-
from higlass.tilesets import Tileset, bam
62-
from higlass.client import Track, View
20+
# the entire viewport has a width of 12 so a width of 6 for
21+
# each view means they take up half the width
22+
view1 = hg.view(
23+
ts.track("chromosome-labels"),
24+
ts.track("heatmap"),
25+
width=6,
26+
)
6327
64-
filename = '../data/ont.10K.bam'
65-
indexfile = '../data/ont.10K.bam.bai'
28+
view2 = hg.view(
29+
ts.track("chromosome-labels"),
30+
ts.track("heatmap"),
31+
width=6,
32+
)
6633
67-
bam_ts = bam(filename, indexfile)
34+
lock = hg.lock(view1, view2)
6835
69-
display, server, viewconf = higlass.display(
70-
[View([
71-
Track('top-axis', height=20),
72-
Track(track_type="pileup",
73-
position='top', tileset=bam_ts, height=50 )
74-
], initialXDomain = [
75-
0,
76-
2000
77-
])]
78-
)
79-
display
36+
(view1 | view2).locks(lock)
8037
81-
.. image:: img/jupyter-pileup-no-code.png
8238
8339
Multivec Files
8440
---------------
@@ -98,70 +54,30 @@ Create the multivec and output file:
9854

9955
.. code-block:: python
10056
101-
from clodius.multivec import create_multivec_multires
102-
from higlass.tilesets import multivec
57+
from clodius.multivec import create_multivec_multires
10358
104-
output_file = "/Users/pete/tmp/my_file.multires.hdf5"
59+
output_file = "/Users/pete/tmp/my_file.multires.hdf5"
10560
106-
create_multivec_multires(
107-
array,
108-
[('chr1', chrom_len)],
109-
agg=lambda x: np.nansum(x.T.reshape((x.shape[1], -1, 2)), axis=2).T,
110-
starting_resolution=1,
111-
row_infos = ["match", 'a', 'g', 't'],
112-
output_file=output_file,
113-
tile_size=256
114-
)
61+
create_multivec_multires(
62+
array,
63+
[('chr1', chrom_len)],
64+
agg=lambda x: np.nansum(x.T.reshape((x.shape[1], -1, 2)), axis=2).T,
65+
starting_resolution=1,
66+
row_infos = ["match", 'a', 'g', 't'],
67+
output_file=output_file,
68+
tile_size=256
69+
)
11570
116-
ts = multivec(output_file)
11771
11872
Create the viewer:
11973

12074
.. code-block:: python
12175
122-
import higlass
123-
from higlass.client import Track, View
124-
125-
display, server, viewconf = higlass.display(
126-
[View([
127-
Track('top-axis', height=20),
128-
Track(track_type="horizontal-stacked-bar", position='top', tileset=ts, height=50 )
129-
], initialXDomain = [
130-
0,
131-
1000000
132-
])]
133-
)
134-
display
135-
136-
Bed-like data
137-
-------------
138-
139-
If you have data representing intervals in a Python object, you can load it
140-
directly into higlass using the `bedtiles` helper function:
141-
142-
.. image:: img/beditems.png
143-
144-
.. code-block:: python
145-
146-
from higlass.client import View, Track
147-
from higlass.inline_tiles import bedtiles
148-
import higlass
149-
150-
bed = [['chr1', 1000, 2000, 'item #1', '.', '+'],
151-
['chr2', 3000, 3500, 'item #1', '.', '-']]
152-
153-
chroms = [['chr1', 2100], ['chr2', 4000]]
154-
155-
156-
data = bedtiles(bed, chroms)
157-
track = Track(track_type='bedlike', position='top',
158-
height=50, data=data, options={"minusStrandColor": "red"})
159-
160-
161-
d,s,v = higlass.display([[track]])
162-
d
163-
76+
import higlass as hg
16477
165-
Note that this function loads all the data into the viewconf and does
166-
not use a server. Do not use this function with more than ~3000 items of
167-
data.
78+
ts = multivec(output_file)
79+
view = hg.view(
80+
hg.track("top-axis", height=20),
81+
ts.track("horizontal-stacked-bar", height=50),
82+
)
83+
view.domain(x=[0, 1000000])

0 commit comments

Comments
 (0)