Skip to content

Commit e1d730b

Browse files
authored
docs: Move pileup example to Examples section (#166)
1 parent 80011f7 commit e1d730b

File tree

3 files changed

+49
-48
lines changed

3 files changed

+49
-48
lines changed

docs/examples.rst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,51 @@ Create the viewer:
9696
ts.track("horizontal-stacked-bar", height=50),
9797
)
9898
view.domain(x=[0, 1000000])
99+
100+
Pileup track
101+
------------
102+
103+
The **higlass-python** package also provides a way to include custom tracks in
104+
your view configuration. These tracks are defined in a separate (JavaScript)
105+
package, and can be included in Python in with some additional setup.
106+
107+
The ``PluginTrack`` provides a mechanism to hook into the schema validation
108+
as well as provide the plugin source for the renderer. The ``plugin_url`` is a
109+
special field which points to the JavaScript source code.
110+
111+
A plugin can be created by subclassing ``hg.PluginTrack`` and specifying the ``type``
112+
and ``plugin_url``. For example,
113+
114+
.. code-block:: python
115+
116+
from typing import Literal, ClassVar
117+
import higlass as hg
118+
119+
class PileupTrack(hg.PluginTrack):
120+
type: Literal["pileup"] = "pileup"
121+
plugin_url: ClassVar[str] = "https://unpkg.com/higlass-pileup/dist/higlass-pileup.min.js"
122+
123+
124+
# Specify the track-specific data
125+
pileup_data = {
126+
"type": "bam",
127+
"url": "https://pkerp.s3.amazonaws.com/public/bamfile_test/SRR1770413.sorted.bam",
128+
"chromSizesUrl": "https://pkerp.s3.amazonaws.com/public/bamfile_test/GCF_000005845.2_ASM584v2_genomic.chrom.sizes",
129+
"options": {"maxTileWidth": 30000},
130+
}
131+
132+
# Create and use the custom track
133+
pileup_track = PileupTrack(data=pileup_data, height=180).opts(
134+
axisPositionHorizontal="right",
135+
axisLabelFormatting="normal",
136+
showCoverage=True,
137+
colorScale=[
138+
"#2c7bb6","#92c5de","#ffffbf","#fdae61","#808080", "#DCDCDC",
139+
],
140+
)
141+
142+
view = hg.view((pileup_track, "top")).domain(x = [1_636_200, 1_636_800])
143+
view
144+
145+
.. image:: img/jupyter-pileup-2025.png
146+

docs/getting_started.rst

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -634,51 +634,4 @@ Then we can define the data and tell the server how to render it.
634634
ts.track("heatmap", height=250).opts(valueScaleMax=0.5),
635635
)
636636
637-
.. image:: img/eggholder-function.png
638-
639-
640-
Plugin Tracks
641-
"""""""""""""
642-
643-
The **higlass-python** package also provides a way to include custom tracks in
644-
your view configuration. These tracks are defined in a separate (JavaScript)
645-
package, and can be included in Python in with some additional setup.
646-
647-
The ``PluginTrack`` provides a mechanism to hook into the schema validation
648-
as well as provide the plugin source for the renderer. The ``plugin_url`` is a
649-
special field which points to the JavaScript source code.
650-
651-
A plugin can be created by subclassing ``hg.PluginTrack`` and specifying the ``type``
652-
and ``plugin_url``. For example,
653-
654-
.. code-block:: python
655-
656-
import higlass as hg
657-
658-
from typing import ClassVar, Literal
659-
660-
class PileupTrack(hg.PluginTrack):
661-
type: Literal["pileup"] = "pileup"
662-
plugin_url: ClassVar[str] = "https://unpkg.com/higlass-pileup/dist/higlass-pileup.min.js"
663-
664-
# Specify the track-specific data
665-
pileup_data = {
666-
"type": "bam",
667-
"url": "https://pkerp.s3.amazonaws.com/public/bamfile_test/SRR1770413.sorted.bam",
668-
"chromSizesUrl": "https://pkerp.s3.amazonaws.com/public/bamfile_test/GCF_000005845.2_ASM584v2_genomic.chrom.sizes",
669-
"options": {"maxTileWidth": 30000},
670-
}
671-
672-
# Create and use the custom track
673-
pileup_track = PileupTrack(data=pileup_data, height=180).opts(
674-
axisPositionHorizontal="right",
675-
axisLabelFormatting="normal",
676-
showCoverage=True,
677-
colorScale=[
678-
"#2c7bb6","#92c5de","#ffffbf","#fdae61","#808080", "#DCDCDC",
679-
],
680-
)
681-
682-
hg.view((pileup_track, "center"))
683-
684-
.. image:: img/jupyter-pileup-no-code.png
637+
.. image:: img/eggholder-function.png

docs/img/jupyter-pileup-2025.png

49.2 KB
Loading

0 commit comments

Comments
 (0)