@@ -5,80 +5,36 @@ Synchronizing location, zoom and value scales
5
5
---------------------------------------------
6
6
7
7
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() ``.
46
10
47
11
.. code-block :: python
48
12
49
- %% javascript
50
-
51
- require([" https://unpkg.com/higlass-pileup/dist/higlass-pileup.min.js" ],
52
- function(hglib) {
13
+ import higlass as hg
53
14
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
+ )
59
19
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
+ )
63
27
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
+ )
66
33
67
- bam_ts = bam(filename, indexfile )
34
+ lock = hg.lock(view1, view2 )
68
35
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)
80
37
81
- .. image :: img/jupyter-pileup-no-code.png
82
38
83
39
Multivec Files
84
40
---------------
@@ -98,70 +54,30 @@ Create the multivec and output file:
98
54
99
55
.. code-block :: python
100
56
101
- from clodius.multivec import create_multivec_multires
102
- from higlass.tilesets import multivec
57
+ from clodius.multivec import create_multivec_multires
103
58
104
- output_file = " /Users/pete/tmp/my_file.multires.hdf5"
59
+ output_file = " /Users/pete/tmp/my_file.multires.hdf5"
105
60
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
+ )
115
70
116
- ts = multivec(output_file)
117
71
118
72
Create the viewer:
119
73
120
74
.. code-block :: python
121
75
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
164
77
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