ComplexHeatmap-py 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ComplexHeatmap.py +7 -0
- complexheatmap/__init__.py +221 -0
- complexheatmap/_base.py +56 -0
- complexheatmap/_options.py +165 -0
- complexheatmap/anno_funcs.py +2781 -0
- complexheatmap/annotations.py +1611 -0
- complexheatmap/colors.py +848 -0
- complexheatmap/data/dmr_summary/cgi_anno.csv +9 -0
- complexheatmap/data/dmr_summary/dist_tss.csv +9 -0
- complexheatmap/data/dmr_summary/gene_anno.csv +9 -0
- complexheatmap/data/dmr_summary/label.csv +9 -0
- complexheatmap/data/dmr_summary/mat_enrich_gf.csv +9 -0
- complexheatmap/data/dmr_summary/mat_enrich_st.csv +9 -0
- complexheatmap/data/dmr_summary/mat_pct_st.csv +9 -0
- complexheatmap/data/dmr_summary/mean_meth.csv +9 -0
- complexheatmap/data/dmr_summary/n_corr.csv +9 -0
- complexheatmap/data/dmr_summary/n_gr.csv +9 -0
- complexheatmap/data/gene_expression.csv +156 -0
- complexheatmap/data/gr.csv +2416 -0
- complexheatmap/data/measles.csv +60 -0
- complexheatmap/data/meth/enhancer.csv +1001 -0
- complexheatmap/data/meth/expr.csv +1001 -0
- complexheatmap/data/meth/meth.csv +1001 -0
- complexheatmap/data/meth/row_meta.csv +1001 -0
- complexheatmap/data/rand_mat.csv +19 -0
- complexheatmap/data/random_meth_expr_data/anno.csv +21 -0
- complexheatmap/data/random_meth_expr_data/anno_states.csv +1001 -0
- complexheatmap/data/random_meth_expr_data/mat_expr.csv +1001 -0
- complexheatmap/data/random_meth_expr_data/mat_meth.csv +1001 -0
- complexheatmap/data/random_meth_expr_data/row_meta.csv +1001 -0
- complexheatmap/data/sample_order.txt +172 -0
- complexheatmap/data/tcga_lung_adenocarcinoma.csv +27 -0
- complexheatmap/decorate.py +159 -0
- complexheatmap/dendrogram.py +937 -0
- complexheatmap/density.py +276 -0
- complexheatmap/genomic.py +348 -0
- complexheatmap/grid.py +1580 -0
- complexheatmap/heatmap.py +2244 -0
- complexheatmap/heatmap_list.py +1569 -0
- complexheatmap/legend.py +992 -0
- complexheatmap/oncoprint.py +488 -0
- complexheatmap/text.py +655 -0
- complexheatmap/three_d.py +188 -0
- complexheatmap/translate.py +338 -0
- complexheatmap/units.py +718 -0
- complexheatmap/upset.py +886 -0
- complexheatmap/utils.py +183 -0
- complexheatmap_py-0.1.0.dist-info/METADATA +96 -0
- complexheatmap_py-0.1.0.dist-info/RECORD +52 -0
- complexheatmap_py-0.1.0.dist-info/WHEEL +5 -0
- complexheatmap_py-0.1.0.dist-info/licenses/LICENSE +24 -0
- complexheatmap_py-0.1.0.dist-info/top_level.txt +2 -0
ComplexHeatmap.py
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"""ComplexHeatmap-py: Python port of R/Bioconductor ComplexHeatmap (v2.25.3)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__version__ = "0.1.0"
|
|
6
|
+
__upstream_r_version__ = "2.25.3"
|
|
7
|
+
|
|
8
|
+
# Core options, base infix operators, units & graphics
|
|
9
|
+
from ._base import AdditiveUnit, v
|
|
10
|
+
from ._options import GLOBAL_PADDING, _ENV, get_last_ht, ht_global_opt, ht_opt
|
|
11
|
+
from .colors import (
|
|
12
|
+
ColorMapping,
|
|
13
|
+
add_luminance,
|
|
14
|
+
add_transparency,
|
|
15
|
+
brewer_pal,
|
|
16
|
+
c_ColorMapping,
|
|
17
|
+
colorRamp2,
|
|
18
|
+
color_mapping_legend,
|
|
19
|
+
default_col,
|
|
20
|
+
grid_pretty,
|
|
21
|
+
hcl_colors,
|
|
22
|
+
map_to_colors,
|
|
23
|
+
pretty_breaks,
|
|
24
|
+
rand_color,
|
|
25
|
+
to_hex_rgba,
|
|
26
|
+
to_hex_rgba_list,
|
|
27
|
+
to_rgba_tuple,
|
|
28
|
+
)
|
|
29
|
+
from .grid import (
|
|
30
|
+
GTree,
|
|
31
|
+
Grob,
|
|
32
|
+
Viewport,
|
|
33
|
+
current_device,
|
|
34
|
+
current_viewport,
|
|
35
|
+
getXY_in_parent_vp,
|
|
36
|
+
grid,
|
|
37
|
+
grid_boxplot,
|
|
38
|
+
grid_circle,
|
|
39
|
+
grid_draw,
|
|
40
|
+
grid_grabExpr,
|
|
41
|
+
grid_lines,
|
|
42
|
+
grid_newpage,
|
|
43
|
+
grid_points,
|
|
44
|
+
grid_polygon,
|
|
45
|
+
grid_raster,
|
|
46
|
+
grid_rect,
|
|
47
|
+
grid_roundrect,
|
|
48
|
+
grid_segments,
|
|
49
|
+
grid_text,
|
|
50
|
+
grid_xaxis,
|
|
51
|
+
grid_yaxis,
|
|
52
|
+
grobHeight,
|
|
53
|
+
grobWidth,
|
|
54
|
+
linesGrob,
|
|
55
|
+
list_components,
|
|
56
|
+
max_text_height,
|
|
57
|
+
max_text_width,
|
|
58
|
+
pointsGrob,
|
|
59
|
+
polygonGrob,
|
|
60
|
+
popViewport,
|
|
61
|
+
pushViewport,
|
|
62
|
+
rectGrob,
|
|
63
|
+
roundrectGrob,
|
|
64
|
+
seekViewport,
|
|
65
|
+
segmentsGrob,
|
|
66
|
+
textGrob,
|
|
67
|
+
upViewport,
|
|
68
|
+
viewport,
|
|
69
|
+
)
|
|
70
|
+
from .text import GridText, draw_richtext, grid_textbox, gt_render, smartAlign, smartAlign2, textbox_grob
|
|
71
|
+
from .units import (
|
|
72
|
+
Gpar,
|
|
73
|
+
Unit,
|
|
74
|
+
as_unit,
|
|
75
|
+
check_gp,
|
|
76
|
+
convertHeight,
|
|
77
|
+
convertWidth,
|
|
78
|
+
convertX,
|
|
79
|
+
convertY,
|
|
80
|
+
gpar,
|
|
81
|
+
is_abs_unit,
|
|
82
|
+
is_unit,
|
|
83
|
+
merge_gp,
|
|
84
|
+
recycle_gp,
|
|
85
|
+
subset_gp,
|
|
86
|
+
unit,
|
|
87
|
+
unit_c,
|
|
88
|
+
unit_max,
|
|
89
|
+
unit_min,
|
|
90
|
+
unit_pmax,
|
|
91
|
+
unit_pmin,
|
|
92
|
+
unit_rep,
|
|
93
|
+
unit_sum,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Dendrogram & clustering
|
|
97
|
+
from .dendrogram import (
|
|
98
|
+
Dendrogram,
|
|
99
|
+
DistMatrix,
|
|
100
|
+
Hclust,
|
|
101
|
+
adjust_dend_by_x,
|
|
102
|
+
as_dendrogram,
|
|
103
|
+
as_dist,
|
|
104
|
+
cluster_between_groups,
|
|
105
|
+
cluster_within_group,
|
|
106
|
+
color_branches,
|
|
107
|
+
cut_dendrogram,
|
|
108
|
+
cutree,
|
|
109
|
+
dend_heights,
|
|
110
|
+
dend_xy,
|
|
111
|
+
dendrogramGrob,
|
|
112
|
+
dist,
|
|
113
|
+
dist2,
|
|
114
|
+
grid_dendrogram,
|
|
115
|
+
hclust,
|
|
116
|
+
merge_dendrogram,
|
|
117
|
+
nobs,
|
|
118
|
+
order_dendrogram,
|
|
119
|
+
reorder_dendrogram,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
# Legends
|
|
123
|
+
from .legend import Legend, Legends, packLegend
|
|
124
|
+
|
|
125
|
+
# Annotations (always import annotations before anno_funcs)
|
|
126
|
+
from .annotations import (
|
|
127
|
+
AnnotationFunction,
|
|
128
|
+
HeatmapAnnotation,
|
|
129
|
+
SingleAnnotation,
|
|
130
|
+
anno_barplot,
|
|
131
|
+
anno_block,
|
|
132
|
+
anno_boxplot,
|
|
133
|
+
anno_customize,
|
|
134
|
+
anno_density,
|
|
135
|
+
anno_empty,
|
|
136
|
+
anno_histogram,
|
|
137
|
+
anno_horizon,
|
|
138
|
+
anno_image,
|
|
139
|
+
anno_joyplot,
|
|
140
|
+
anno_lines,
|
|
141
|
+
anno_link,
|
|
142
|
+
anno_mark,
|
|
143
|
+
anno_numeric,
|
|
144
|
+
anno_oncoprint_barplot,
|
|
145
|
+
anno_points,
|
|
146
|
+
anno_simple,
|
|
147
|
+
anno_summary,
|
|
148
|
+
anno_text,
|
|
149
|
+
anno_textbox,
|
|
150
|
+
anno_zoom,
|
|
151
|
+
annotation_axis_grob,
|
|
152
|
+
c_HeatmapAnnotation,
|
|
153
|
+
columnAnnotation,
|
|
154
|
+
construct_axis_grob,
|
|
155
|
+
default_axis_param,
|
|
156
|
+
grid_annotation_axis,
|
|
157
|
+
rowAnnotation,
|
|
158
|
+
row_anno_barplot,
|
|
159
|
+
row_anno_boxplot,
|
|
160
|
+
row_anno_density,
|
|
161
|
+
row_anno_histogram,
|
|
162
|
+
row_anno_points,
|
|
163
|
+
row_anno_text,
|
|
164
|
+
validate_axis_param,
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
# Heatmap, HeatmapList & Decorations
|
|
168
|
+
from .decorate import (
|
|
169
|
+
decorate_annotation,
|
|
170
|
+
decorate_column_dend,
|
|
171
|
+
decorate_column_names,
|
|
172
|
+
decorate_column_title,
|
|
173
|
+
decorate_dend,
|
|
174
|
+
decorate_dimnames,
|
|
175
|
+
decorate_heatmap_body,
|
|
176
|
+
decorate_row_dend,
|
|
177
|
+
decorate_row_names,
|
|
178
|
+
decorate_row_title,
|
|
179
|
+
decorate_title,
|
|
180
|
+
)
|
|
181
|
+
from .heatmap import Heatmap
|
|
182
|
+
from .heatmap_list import (
|
|
183
|
+
HeatmapList,
|
|
184
|
+
add_heatmap,
|
|
185
|
+
attach_annotation,
|
|
186
|
+
column_dend,
|
|
187
|
+
column_order,
|
|
188
|
+
draw,
|
|
189
|
+
ht_size,
|
|
190
|
+
row_dend,
|
|
191
|
+
row_order,
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
# High-level plots, genomic utilities, translations & helpers
|
|
195
|
+
from .density import densityHeatmap, frequencyHeatmap, ks_dist
|
|
196
|
+
from .genomic import GRanges, IRanges, bin_genome, findOverlaps, generateRandomBed, normalize_genomic_signals_to_bins
|
|
197
|
+
from .oncoprint import alter_graphic, default_get_type, oncoPrint, test_alter_fun, unify_mat_list
|
|
198
|
+
from .three_d import Heatmap3D, bar3D
|
|
199
|
+
from .translate import compare_heatmap, compare_heatmap_2, compare_pheatmap, heatmap, heatmap_2, pheatmap
|
|
200
|
+
from .upset import (
|
|
201
|
+
CombMat,
|
|
202
|
+
UpSet,
|
|
203
|
+
comb_degree,
|
|
204
|
+
comb_name,
|
|
205
|
+
comb_size,
|
|
206
|
+
complement_size,
|
|
207
|
+
extract_comb,
|
|
208
|
+
full_comb_code,
|
|
209
|
+
list_to_matrix,
|
|
210
|
+
make_comb_mat,
|
|
211
|
+
normalize_comb_mat,
|
|
212
|
+
order_comb_mat,
|
|
213
|
+
set_name,
|
|
214
|
+
set_size,
|
|
215
|
+
upset_left_annotation,
|
|
216
|
+
upset_right_annotation,
|
|
217
|
+
upset_top_annotation,
|
|
218
|
+
)
|
|
219
|
+
from .utils import c, dim, height, load_dataset, names, ncol, nrow, pindex, restore_matrix, set_names, size, summary, t, width
|
|
220
|
+
|
|
221
|
+
__all__ = [name for name in globals() if not name.startswith("_")]
|
complexheatmap/_base.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""Base AdditiveUnit class and horizontal (`+`) / vertical (`%v%`, `/`) concatenation hooks."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class _VerticalInfix:
|
|
9
|
+
"""Infix sentinel enabling R-like `ht1 %v% ht2` vertical heatmap concatenation."""
|
|
10
|
+
|
|
11
|
+
def __rmod__(self, left: Any) -> "_PendingVertical":
|
|
12
|
+
return _PendingVertical(left)
|
|
13
|
+
|
|
14
|
+
def __repr__(self) -> str:
|
|
15
|
+
return "<ComplexHeatmap vertical operator %v%>"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class _PendingVertical:
|
|
19
|
+
def __init__(self, left: Any) -> None:
|
|
20
|
+
self.left = left
|
|
21
|
+
|
|
22
|
+
def __mod__(self, right: Any) -> Any:
|
|
23
|
+
from .heatmap_list import add_heatmap
|
|
24
|
+
return add_heatmap(self.left, right, direction="vertical")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
v = _VerticalInfix()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class AdditiveUnit:
|
|
31
|
+
"""Superclass for Heatmap, HeatmapAnnotation, and HeatmapList supporting `+`, `%v%`, `/`."""
|
|
32
|
+
|
|
33
|
+
def __add__(self, other: Any) -> Any:
|
|
34
|
+
from .heatmap_list import add_heatmap
|
|
35
|
+
return add_heatmap(self, other, direction="horizontal")
|
|
36
|
+
|
|
37
|
+
def __radd__(self, other: Any) -> Any:
|
|
38
|
+
if other is None:
|
|
39
|
+
from .heatmap_list import add_heatmap
|
|
40
|
+
return add_heatmap(None, self, direction="horizontal")
|
|
41
|
+
return NotImplemented
|
|
42
|
+
|
|
43
|
+
def __truediv__(self, other: Any) -> Any:
|
|
44
|
+
from .heatmap_list import add_heatmap
|
|
45
|
+
return add_heatmap(self, other, direction="vertical")
|
|
46
|
+
|
|
47
|
+
def __rtruediv__(self, other: Any) -> Any:
|
|
48
|
+
if other is None:
|
|
49
|
+
from .heatmap_list import add_heatmap
|
|
50
|
+
return add_heatmap(None, self, direction="vertical")
|
|
51
|
+
return NotImplemented
|
|
52
|
+
|
|
53
|
+
def __mod__(self, other: Any) -> Any:
|
|
54
|
+
if isinstance(other, _VerticalInfix):
|
|
55
|
+
return _PendingVertical(self)
|
|
56
|
+
return NotImplemented
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"""Global configuration options (`ht_opt`) and shared internal runtime state."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from contextlib import contextmanager
|
|
6
|
+
import itertools
|
|
7
|
+
from typing import Any, Iterator
|
|
8
|
+
|
|
9
|
+
from .units import Gpar, Unit, check_gp, unit
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
_DEFAULTS: dict[str, Any] = {
|
|
13
|
+
"heatmap_row_names_gp": None,
|
|
14
|
+
"heatmap_column_names_gp": None,
|
|
15
|
+
"heatmap_row_title_gp": None,
|
|
16
|
+
"heatmap_column_title_gp": None,
|
|
17
|
+
"legend_title_gp": None,
|
|
18
|
+
"legend_title_position": None,
|
|
19
|
+
"legend_labels_gp": None,
|
|
20
|
+
"legend_grid_height": None,
|
|
21
|
+
"legend_grid_width": None,
|
|
22
|
+
"legend_border": None,
|
|
23
|
+
"legend_gap": unit([4.0, 4.0], "mm"),
|
|
24
|
+
"merge_legends": False,
|
|
25
|
+
"heatmap_border": None,
|
|
26
|
+
"annotation_border": None,
|
|
27
|
+
"fast_hclust": False,
|
|
28
|
+
"show_parent_dend_line": True,
|
|
29
|
+
"verbose": False,
|
|
30
|
+
"message": True,
|
|
31
|
+
"show_vp": False,
|
|
32
|
+
"simple_anno_size": unit(5.0, "mm"),
|
|
33
|
+
"DENDROGRAM_PADDING": unit(0.5, "mm"),
|
|
34
|
+
"DIMNAME_PADDING": unit(1.0, "mm"),
|
|
35
|
+
"TITLE_PADDING": None,
|
|
36
|
+
"COLUMN_ANNO_PADDING": unit(1.0, "mm"),
|
|
37
|
+
"ROW_ANNO_PADDING": unit(1.0, "mm"),
|
|
38
|
+
"HEATMAP_LEGEND_PADDING": unit(2.0, "mm"),
|
|
39
|
+
"ANNOTATION_LEGEND_PADDING": unit(2.0, "mm"),
|
|
40
|
+
"save_last": False,
|
|
41
|
+
"validate_names": True,
|
|
42
|
+
"raster_temp_image_max_width": 30000,
|
|
43
|
+
"raster_temp_image_max_height": 30000,
|
|
44
|
+
"COLOR": ["blue", "#EEEEEE", "red"],
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
GLOBAL_PADDING = unit([5.5, 5.5, 5.5, 5.5], "points")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _filter_option(key: str, val: Any) -> Any:
|
|
51
|
+
if key not in _DEFAULTS:
|
|
52
|
+
raise KeyError(f"Unknown ComplexHeatmap option: {key!r}")
|
|
53
|
+
if val is None:
|
|
54
|
+
return None
|
|
55
|
+
if key == "legend_gap":
|
|
56
|
+
u = val if isinstance(val, Unit) else unit(val, "mm")
|
|
57
|
+
if len(u) == 1:
|
|
58
|
+
return unit([u.to_mm_scalar("x"), u.to_mm_scalar("x")], "mm")
|
|
59
|
+
return u[:2]
|
|
60
|
+
if key == "TITLE_PADDING":
|
|
61
|
+
u = val if isinstance(val, Unit) else unit(val, "mm")
|
|
62
|
+
if len(u) == 1:
|
|
63
|
+
return unit([u.to_mm_scalar("y"), u.to_mm_scalar("y")], "mm")
|
|
64
|
+
return u[:2]
|
|
65
|
+
if key.endswith("_gp"):
|
|
66
|
+
return check_gp(val)
|
|
67
|
+
if key in ("simple_anno_size", "legend_grid_height", "legend_grid_width") or key.endswith("_PADDING"):
|
|
68
|
+
return val if isinstance(val, Unit) else unit(val, "mm")
|
|
69
|
+
if key in ("verbose", "message", "fast_hclust", "merge_legends", "show_parent_dend_line", "show_vp", "save_last", "validate_names"):
|
|
70
|
+
return bool(val)
|
|
71
|
+
return val
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class _OptionsManager:
|
|
75
|
+
"""Global options container supporting attribute, dict, and call syntax like R `ht_opt`."""
|
|
76
|
+
|
|
77
|
+
def __init__(self) -> None:
|
|
78
|
+
object.__setattr__(self, "_opts", dict(_DEFAULTS))
|
|
79
|
+
|
|
80
|
+
def reset(self) -> None:
|
|
81
|
+
self._opts.clear()
|
|
82
|
+
self._opts.update(_DEFAULTS)
|
|
83
|
+
|
|
84
|
+
def __call__(self, *args: str, RESET: bool = False, **kwargs: Any) -> Any:
|
|
85
|
+
if RESET:
|
|
86
|
+
self.reset()
|
|
87
|
+
return None
|
|
88
|
+
if args and not kwargs:
|
|
89
|
+
if len(args) == 1:
|
|
90
|
+
return self._opts[args[0]]
|
|
91
|
+
return {k: self._opts[k] for k in args}
|
|
92
|
+
if kwargs:
|
|
93
|
+
old = {k: self._opts[k] for k in kwargs if k in self._opts}
|
|
94
|
+
for k, v in kwargs.items():
|
|
95
|
+
self._opts[k] = _filter_option(k, v)
|
|
96
|
+
return old
|
|
97
|
+
return dict(self._opts)
|
|
98
|
+
|
|
99
|
+
def __getattr__(self, name: str) -> Any:
|
|
100
|
+
opts = object.__getattribute__(self, "_opts")
|
|
101
|
+
if name in opts:
|
|
102
|
+
return opts[name]
|
|
103
|
+
raise AttributeError(f"No option named {name!r}")
|
|
104
|
+
|
|
105
|
+
def __setattr__(self, name: str, value: Any) -> None:
|
|
106
|
+
self._opts[name] = _filter_option(name, value)
|
|
107
|
+
|
|
108
|
+
def __getitem__(self, name: str) -> Any:
|
|
109
|
+
return self._opts[name]
|
|
110
|
+
|
|
111
|
+
def __setitem__(self, name: str, value: Any) -> None:
|
|
112
|
+
self._opts[name] = _filter_option(name, value)
|
|
113
|
+
|
|
114
|
+
def get(self, name: str, default: Any = None) -> Any:
|
|
115
|
+
return self._opts.get(name, default)
|
|
116
|
+
|
|
117
|
+
def keys(self):
|
|
118
|
+
return self._opts.keys()
|
|
119
|
+
|
|
120
|
+
def items(self):
|
|
121
|
+
return self._opts.items()
|
|
122
|
+
|
|
123
|
+
@contextmanager
|
|
124
|
+
def local(self, **overrides: Any) -> Iterator[None]:
|
|
125
|
+
saved: dict[str, Any] = {}
|
|
126
|
+
for k, v in overrides.items():
|
|
127
|
+
if v is not None and k in self._opts:
|
|
128
|
+
saved[k] = self._opts[k]
|
|
129
|
+
self._opts[k] = _filter_option(k, v)
|
|
130
|
+
try:
|
|
131
|
+
yield
|
|
132
|
+
finally:
|
|
133
|
+
for k, v in saved.items():
|
|
134
|
+
self._opts[k] = v
|
|
135
|
+
|
|
136
|
+
def __repr__(self) -> str:
|
|
137
|
+
lines = [" Option Value", " -----------------------------:--------------------------------"]
|
|
138
|
+
for k, v in self._opts.items():
|
|
139
|
+
lines.append(f" {k:<29} {v!r}")
|
|
140
|
+
return "\n".join(lines)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
ht_opt = _OptionsManager()
|
|
144
|
+
ht_global_opt = ht_opt
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class _RuntimeEnv:
|
|
148
|
+
def __init__(self) -> None:
|
|
149
|
+
self.current_annotation_which: str | None = None
|
|
150
|
+
self.current_heatmap: Any = None
|
|
151
|
+
self.last: Any = None
|
|
152
|
+
self.heatmap_counter = itertools.count(1)
|
|
153
|
+
self.anno_counter = itertools.count(1)
|
|
154
|
+
self.oncoprint_counter = itertools.count(1)
|
|
155
|
+
self.chr_window: Any = None
|
|
156
|
+
|
|
157
|
+
def next_heatmap_index(self) -> int:
|
|
158
|
+
return next(self.heatmap_counter)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
_ENV = _RuntimeEnv()
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def get_last_ht() -> Any:
|
|
165
|
+
return _ENV.last
|