... | ... |
@@ -145,8 +145,6 @@ export("densityHeatmap") |
145 | 145 |
export("dist2") |
146 | 146 |
export("grid.boxplot") |
147 | 147 |
export("grid.dendrogram") |
148 |
-export("height") |
|
149 |
-export("height<-") |
|
150 | 148 |
export("ht_global_opt") |
151 | 149 |
export("ht_opt") |
152 | 150 |
export("is_abs_unit") |
... | ... |
@@ -165,14 +163,10 @@ export("row_anno_histogram") |
165 | 163 |
export("row_anno_link") |
166 | 164 |
export("row_anno_points") |
167 | 165 |
export("row_anno_text") |
168 |
-export("size") |
|
169 |
-export("size<-") |
|
170 | 166 |
export("subset_gp") |
171 | 167 |
export("subset_matrix_by_row") |
172 | 168 |
export("subset_vector") |
173 | 169 |
export("unify_mat_list") |
174 |
-export("width") |
|
175 |
-export("width<-") |
|
176 | 170 |
exportClasses("AdditiveUnit") |
177 | 171 |
export("AdditiveUnit") |
178 | 172 |
exportClasses("AnnotationFunction") |
... | ... |
@@ -215,7 +209,7 @@ exportMethods("make_layout") |
215 | 209 |
exportMethods("make_row_cluster") |
216 | 210 |
exportMethods("map_to_colors") |
217 | 211 |
exportMethods("prepare") |
218 |
-exportMethods("resize") |
|
212 |
+exportMethods("re_size") |
|
219 | 213 |
exportMethods("row_dend") |
220 | 214 |
exportMethods("row_order") |
221 | 215 |
exportMethods("set_component_height") |
... | ... |
@@ -2,13 +2,13 @@ setGeneric('map_to_colors', function(object, ...) standardGeneric('map_to_colors |
2 | 2 |
setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height')) |
3 | 3 |
setGeneric('draw_heatmap_body', function(object, ...) standardGeneric('draw_heatmap_body')) |
4 | 4 |
setGeneric('component_height', function(object, ...) standardGeneric('component_height')) |
5 |
+setGeneric('re_size', function(object, ...) standardGeneric('re_size')) |
|
5 | 6 |
setGeneric('make_layout', function(object, ...) standardGeneric('make_layout')) |
6 | 7 |
setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size')) |
7 | 8 |
setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list')) |
8 | 9 |
setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend')) |
9 | 10 |
setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster')) |
10 | 11 |
setGeneric('column_dend', function(object, ...) standardGeneric('column_dend')) |
11 |
-setGeneric('resize', function(object, ...) standardGeneric('resize')) |
|
12 | 12 |
setGeneric('row_order', function(object, ...) standardGeneric('row_order')) |
13 | 13 |
setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list')) |
14 | 14 |
setGeneric('row_dend', function(object, ...) standardGeneric('row_dend')) |
... | ... |
@@ -1,69 +1,24 @@ |
1 | 1 |
|
2 |
-# == title |
|
3 |
-# Generic Method for width() |
|
4 |
-# |
|
5 |
-# == param |
|
6 |
-# -x An object. |
|
7 |
-# -... Other arguments. |
|
8 |
-# |
|
9 | 2 |
width = function (x, ...) { |
10 | 3 |
UseMethod("width", x) |
11 | 4 |
} |
12 | 5 |
|
13 |
-# == title |
|
14 |
-# Generic Method for height() |
|
15 |
-# |
|
16 |
-# == param |
|
17 |
-# -x An object. |
|
18 |
-# -... Other arguments. |
|
19 |
-# |
|
20 | 6 |
height = function (x, ...) { |
21 | 7 |
UseMethod("height", x) |
22 | 8 |
} |
23 | 9 |
|
24 |
-# == title |
|
25 |
-# Generic Method for size() |
|
26 |
-# |
|
27 |
-# == param |
|
28 |
-# -x An object. |
|
29 |
-# -... Other arguments. |
|
30 |
-# |
|
31 | 10 |
size = function (x, ...) { |
32 | 11 |
UseMethod("size", x) |
33 | 12 |
} |
34 | 13 |
|
35 |
-# == title |
|
36 |
-# Generic Assignment Method for width() |
|
37 |
-# |
|
38 |
-# == param |
|
39 |
-# -x An object. |
|
40 |
-# -value The value |
|
41 |
-# -... Other arguments. |
|
42 |
-# |
|
43 | 14 |
"width<-" = function (x, ..., value) { |
44 | 15 |
UseMethod("width<-", x) |
45 | 16 |
} |
46 | 17 |
|
47 |
-# == title |
|
48 |
-# Generic Assignment Method for height() |
|
49 |
-# |
|
50 |
-# == param |
|
51 |
-# -x An object. |
|
52 |
-# -value The value |
|
53 |
-# -... Other arguments. |
|
54 |
-# |
|
55 | 18 |
"height<-" = function (x, ..., value) { |
56 | 19 |
UseMethod("height<-", x) |
57 | 20 |
} |
58 | 21 |
|
59 |
-# == title |
|
60 |
-# Generic Assignment Method for size() |
|
61 |
-# |
|
62 |
-# == param |
|
63 |
-# -x An object. |
|
64 |
-# -value The value |
|
65 |
-# -... Other arguments. |
|
66 |
-# |
|
67 | 22 |
"size<-" = function (x, ..., value) { |
68 | 23 |
UseMethod("size<-", x) |
69 | 24 |
} |
... | ... |
@@ -73,13 +28,16 @@ size = function (x, ...) { |
73 | 28 |
# |
74 | 29 |
# == param |
75 | 30 |
# -x A `AnnotationFunction-class` object. |
76 |
-# -... Other arguments |
|
31 |
+# -... Other arguments. |
|
32 |
+# |
|
33 |
+# == detail |
|
34 |
+# Internally used. |
|
77 | 35 |
# |
78 | 36 |
# == example |
79 | 37 |
# anno = anno_points(1:10) |
80 |
-# width(anno) |
|
38 |
+# ComplexHeatmap:::width(anno) |
|
81 | 39 |
# anno = anno_points(1:10, which = "row") |
82 |
-# width(anno) |
|
40 |
+# ComplexHeatmap:::width(anno) |
|
83 | 41 |
width.AnnotationFunction = function(x, ...) { |
84 | 42 |
x@width |
85 | 43 |
} |
... | ... |
@@ -92,6 +50,9 @@ width.AnnotationFunction = function(x, ...) { |
92 | 50 |
# -... Other arguments. |
93 | 51 |
# -value A `grid::unit` object. |
94 | 52 |
# |
53 |
+# == detail |
|
54 |
+# Internally used. |
|
55 |
+# |
|
95 | 56 |
"width<-.AnnotationFunction" = function(x, ..., value) { |
96 | 57 |
x@width = value |
97 | 58 |
x |
... | ... |
@@ -102,13 +63,16 @@ width.AnnotationFunction = function(x, ...) { |
102 | 63 |
# |
103 | 64 |
# == param |
104 | 65 |
# -x The `AnnotationFunction-class` object. |
105 |
-# -... Other arguments |
|
66 |
+# -... Other arguments. |
|
67 |
+# |
|
68 |
+# == detail |
|
69 |
+# Internally used. |
|
106 | 70 |
# |
107 | 71 |
# == example |
108 | 72 |
# anno = anno_points(1:10) |
109 |
-# height(anno) |
|
73 |
+# ComplexHeatmap:::height(anno) |
|
110 | 74 |
# anno = anno_points(1:10, which = "row") |
111 |
-# height(anno) |
|
75 |
+# ComplexHeatmap:::height(anno) |
|
112 | 76 |
height.AnnotationFunction = function(x, ...) { |
113 | 77 |
x@height |
114 | 78 |
} |
... | ... |
@@ -121,6 +85,9 @@ height.AnnotationFunction = function(x, ...) { |
121 | 85 |
# -value A `grid::unit` object. |
122 | 86 |
# -... Other arguments. |
123 | 87 |
# |
88 |
+# == detail |
|
89 |
+# Internally used. |
|
90 |
+# |
|
124 | 91 |
"height<-.AnnotationFunction" = function(x, ..., value) { |
125 | 92 |
x@height = value |
126 | 93 |
x |
... | ... |
@@ -136,11 +103,13 @@ height.AnnotationFunction = function(x, ...) { |
136 | 103 |
# == detail |
137 | 104 |
# It returns the width if it is a row annotation and the height if it is a column annotation. |
138 | 105 |
# |
106 |
+# Internally used. |
|
107 |
+# |
|
139 | 108 |
# == example |
140 | 109 |
# anno = anno_points(1:10) |
141 |
-# size(anno) |
|
110 |
+# ComplexHeatmap:::size(anno) |
|
142 | 111 |
# anno = anno_points(1:10, which = "row") |
143 |
-# size(anno) |
|
112 |
+# ComplexHeatmap:::size(anno) |
|
144 | 113 |
size.AnnotationFunction = function(x, ...) { |
145 | 114 |
if(x@which == "row") { |
146 | 115 |
x@width |
... | ... |
@@ -160,10 +129,12 @@ size.AnnotationFunction = function(x, ...) { |
160 | 129 |
# == detail |
161 | 130 |
# It assigns to the width if it is a row annotation and the height if it is a column annotation. |
162 | 131 |
# |
132 |
+# Internally used. |
|
133 |
+# |
|
163 | 134 |
# == example |
164 | 135 |
# anno = anno_points(1:10) |
165 |
-# size(anno) = unit(4, "cm") |
|
166 |
-# size(anno) |
|
136 |
+# ComplexHeatmap:::size(anno) = unit(4, "cm") |
|
137 |
+# ComplexHeatmap:::size(anno) |
|
167 | 138 |
"size<-.AnnotationFunction" = function(x, ..., value) { |
168 | 139 |
if(x@which == "row") { |
169 | 140 |
x@width = value |
... | ... |
@@ -182,6 +153,9 @@ size.AnnotationFunction = function(x, ...) { |
182 | 153 |
# -x The `SingleAnnotation-class` object. |
183 | 154 |
# -... Other arguments. |
184 | 155 |
# |
156 |
+# == detail |
|
157 |
+# Internally used. |
|
158 |
+# |
|
185 | 159 |
width.SingleAnnotation = function(x, ...) { |
186 | 160 |
x@width |
187 | 161 |
} |
... | ... |
@@ -194,6 +168,9 @@ width.SingleAnnotation = function(x, ...) { |
194 | 168 |
# -value A `grid::unit` object. |
195 | 169 |
# -... Other arguments. |
196 | 170 |
# |
171 |
+# == detail |
|
172 |
+# Internally used. |
|
173 |
+# |
|
197 | 174 |
"width<-.SingleAnnotation" = function(x, ..., value) { |
198 | 175 |
x@width = value |
199 | 176 |
if(inherits(x@fun, "AnnotationFunction")) { |
... | ... |
@@ -209,6 +186,9 @@ width.SingleAnnotation = function(x, ...) { |
209 | 186 |
# -x The `SingleAnnotation-class` object. |
210 | 187 |
# -... Other arguments. |
211 | 188 |
# |
189 |
+# == detail |
|
190 |
+# Internally used. |
|
191 |
+# |
|
212 | 192 |
height.SingleAnnotation = function(x, ...) { |
213 | 193 |
x@height |
214 | 194 |
} |
... | ... |
@@ -221,6 +201,9 @@ height.SingleAnnotation = function(x, ...) { |
221 | 201 |
# -value A `grid::unit` object. |
222 | 202 |
# -... Other arguments. |
223 | 203 |
# |
204 |
+# == detail |
|
205 |
+# Internally used. |
|
206 |
+# |
|
224 | 207 |
"height<-.SingleAnnotation" = function(x, ..., value) { |
225 | 208 |
x@height = value |
226 | 209 |
if(inherits(x@fun, "AnnotationFunction")) { |
... | ... |
@@ -239,6 +222,8 @@ height.SingleAnnotation = function(x, ...) { |
239 | 222 |
# == detail |
240 | 223 |
# It returns the width if it is a row annotation and the height if it is a column annotation. |
241 | 224 |
# |
225 |
+# Internally used. |
|
226 |
+# |
|
242 | 227 |
size.SingleAnnotation = function(x, ...) { |
243 | 228 |
if(x@which == "row") { |
244 | 229 |
x@width |
... | ... |
@@ -258,6 +243,8 @@ size.SingleAnnotation = function(x, ...) { |
258 | 243 |
# == detail |
259 | 244 |
# It assigns to the width if it is a row annotation and the height if it is a column annotation. |
260 | 245 |
# |
246 |
+# Internally used. |
|
247 |
+# |
|
261 | 248 |
"size<-.SingleAnnotation" = function(x, ..., value) { |
262 | 249 |
if(x@which == "row") { |
263 | 250 |
width(x) = value |
... | ... |
@@ -276,6 +263,9 @@ size.SingleAnnotation = function(x, ...) { |
276 | 263 |
# -x The `HeatmapAnnotation-class` object. |
277 | 264 |
# -... Other arguments. |
278 | 265 |
# |
266 |
+# == detail |
|
267 |
+# Internally used. |
|
268 |
+# |
|
279 | 269 |
width.HeatmapAnnotation = function(x, ...) { |
280 | 270 |
x@width |
281 | 271 |
} |
... | ... |
@@ -288,6 +278,9 @@ width.HeatmapAnnotation = function(x, ...) { |
288 | 278 |
# -value A `grid::unit` object. |
289 | 279 |
# -... Other arguments. |
290 | 280 |
# |
281 |
+# == detail |
|
282 |
+# Internally used. |
|
283 |
+# |
|
291 | 284 |
"width<-.HeatmapAnnotation" = function(x, ..., value) { |
292 | 285 |
|
293 | 286 |
if(x@which == "column") { |
... | ... |
@@ -296,7 +289,7 @@ width.HeatmapAnnotation = function(x, ...) { |
296 | 289 |
width(x@anno_list[[i]]) = value |
297 | 290 |
} |
298 | 291 |
} else { |
299 |
- x = resize(x, width = value) |
|
292 |
+ x = re_size(x, width = value) |
|
300 | 293 |
} |
301 | 294 |
x |
302 | 295 |
} |
... | ... |
@@ -309,6 +302,9 @@ width.HeatmapAnnotation = function(x, ...) { |
309 | 302 |
# -x The `HeatmapAnnotation-class` object. |
310 | 303 |
# -... Other arguments. |
311 | 304 |
# |
305 |
+# == detail |
|
306 |
+# Internally used. |
|
307 |
+# |
|
312 | 308 |
height.HeatmapAnnotation = function(x, ...) { |
313 | 309 |
x@height |
314 | 310 |
} |
... | ... |
@@ -321,6 +317,9 @@ height.HeatmapAnnotation = function(x, ...) { |
321 | 317 |
# -value A `grid::unit` object. |
322 | 318 |
# -... Other arguments. |
323 | 319 |
# |
320 |
+# == detail |
|
321 |
+# Internally used. |
|
322 |
+# |
|
324 | 323 |
"height<-.HeatmapAnnotation" = function(x, ..., value) { |
325 | 324 |
|
326 | 325 |
if(x@which == "row") { |
... | ... |
@@ -329,7 +328,7 @@ height.HeatmapAnnotation = function(x, ...) { |
329 | 328 |
height(x@anno_list[[i]]) = height |
330 | 329 |
} |
331 | 330 |
} else { |
332 |
- x = resize(x, height = value) |
|
331 |
+ x = re_size(x, height = value) |
|
333 | 332 |
} |
334 | 333 |
x |
335 | 334 |
} |
... | ... |
@@ -344,6 +343,8 @@ height.HeatmapAnnotation = function(x, ...) { |
344 | 343 |
# == detail |
345 | 344 |
# It returns the width if it is a row annotation and the height if it is a column annotation. |
346 | 345 |
# |
346 |
+# Internally used. |
|
347 |
+# |
|
347 | 348 |
size.HeatmapAnnotation = function(x, ...) { |
348 | 349 |
if(x@which == "row") { |
349 | 350 |
x@width |
... | ... |
@@ -363,6 +364,8 @@ size.HeatmapAnnotation = function(x, ...) { |
363 | 364 |
# == detail |
364 | 365 |
# It assigns the width if it is a row annotation and the height if it is a column annotation. |
365 | 366 |
# |
367 |
+# Internally used. |
|
368 |
+# |
|
366 | 369 |
"size<-.HeatmapAnnotation" = function(x, ..., value) { |
367 | 370 |
if(x@which == "row") { |
368 | 371 |
width(x) = value |
... | ... |
@@ -383,6 +386,10 @@ size.HeatmapAnnotation = function(x, ...) { |
383 | 386 |
# == value |
384 | 387 |
# The returned unit x is always in ``mm``. |
385 | 388 |
# |
389 |
+# == example |
|
390 |
+# lgd = Legend(labels = 1:10, title = "foo", gp = gpar(fill = "red")) |
|
391 |
+# width(lgd) |
|
392 |
+# |
|
386 | 393 |
width.Legends = function(x, ...) { |
387 | 394 |
s = attr(x@grob, "width") |
388 | 395 |
s |
... | ... |
@@ -399,8 +406,68 @@ width.Legends = function(x, ...) { |
399 | 406 |
# == value |
400 | 407 |
# The returned unit x is always in ``mm``. |
401 | 408 |
# |
409 |
+# == example |
|
410 |
+# lgd = Legend(labels = 1:10, title = "foo", gp = gpar(fill = "red")) |
|
411 |
+# height(lgd) |
|
412 |
+# |
|
402 | 413 |
height.Legends = function(x, ...) { |
403 | 414 |
s = attr(x@grob, "height") |
404 | 415 |
s |
405 | 416 |
} |
406 | 417 |
|
418 |
+ |
|
419 |
+# == title |
|
420 |
+# Width of the Heatmap List |
|
421 |
+# |
|
422 |
+# == param |
|
423 |
+# -x The `HeatmapList-class` object returned by `draw,HeatmapList-method`. |
|
424 |
+# -... Other arguments. |
|
425 |
+# |
|
426 |
+width.HeatmapList = function(x, ...) { |
|
427 |
+ if(object@layout$initialized) { |
|
428 |
+ x@ht_list_param$width |
|
429 |
+ } else { |
|
430 |
+ stop_wrap("width() can only be applied to the heatmap list object returned by draw().") |
|
431 |
+ } |
|
432 |
+} |
|
433 |
+ |
|
434 |
+ |
|
435 |
+# == title |
|
436 |
+# Height of the Heatmap List |
|
437 |
+# |
|
438 |
+# == param |
|
439 |
+# -x The `HeatmapList-class` object returned by `draw,HeatmapList-method`. |
|
440 |
+# -... Other arguments. |
|
441 |
+# |
|
442 |
+height.HeatmapList = function(x, ...) { |
|
443 |
+ if(object@layout$initialized) { |
|
444 |
+ x@ht_list_param$height |
|
445 |
+ } else { |
|
446 |
+ stop_wrap("height() can only be applied to the heatmap list object returned by draw().") |
|
447 |
+ } |
|
448 |
+} |
|
449 |
+ |
|
450 |
+ |
|
451 |
+# == title |
|
452 |
+# Width of the Heatmap |
|
453 |
+# |
|
454 |
+# == param |
|
455 |
+# -x The `HeatmapList-class` object returned by `draw,Heatmap-method`. |
|
456 |
+# -... Other arguments. |
|
457 |
+# |
|
458 |
+width.Heatmap = function(x, ...) { |
|
459 |
+ stop_wrap("width() can only be applied to the heatmap object returned by draw().") |
|
460 |
+} |
|
461 |
+ |
|
462 |
+ |
|
463 |
+# == title |
|
464 |
+# Height of the Heatmap |
|
465 |
+# |
|
466 |
+# == param |
|
467 |
+# -x The `HeatmapList-class` object returned by `draw,Heatmap-method`. |
|
468 |
+# -... Other arguments. |
|
469 |
+# |
|
470 |
+height.Heatmap = function(x, ...) { |
|
471 |
+ stop_wrap("height() can only be applied to the heatmap object returned by draw().") |
|
472 |
+} |
|
473 |
+ |
... | ... |
@@ -5,7 +5,7 @@ |
5 | 5 |
# == detail |
6 | 6 |
# This class is a super class for `Heatmap-class`, `HeatmapList-class` and |
7 | 7 |
# `HeatmapAnnotation-class` classes. It is only designed for ``+`` generic |
8 |
-# method so that above three classes can be appended to each other. |
|
8 |
+# method and the `\%v\%v` method so that above three classes can be appended to each other. |
|
9 | 9 |
# |
10 | 10 |
AdditiveUnit = setClass("AdditiveUnit") |
11 | 11 |
|
... | ... |
@@ -550,6 +550,16 @@ validate_axis_param = function(axis_param, which) { |
550 | 550 |
for(nm in names(axis_param)) { |
551 | 551 |
dft[[nm]] = axis_param[[nm]] |
552 | 552 |
} |
553 |
+ if(which == "row") { |
|
554 |
+ if(dft$side %in% c("left", "right")) { |
|
555 |
+ stop_wrap("axis side can only be set to 'top' or 'bottom' for row annotations.") |
|
556 |
+ } |
|
557 |
+ } |
|
558 |
+ if(which == "column") { |
|
559 |
+ if(dft$side %in% c("top", "bottom")) { |
|
560 |
+ stop_wrap("axis side can only be set to 'left' or 'right' for row annotations.") |
|
561 |
+ } |
|
562 |
+ } |
|
553 | 563 |
return(dft) |
554 | 564 |
} |
555 | 565 |
|
... | ... |
@@ -569,7 +579,6 @@ construct_axis_grob = function(axis_param, which, data_scale) { |
569 | 579 |
axis_param$labels = axis_param$at |
570 | 580 |
} |
571 | 581 |
axis_grob = do.call(annotation_axis_grob, axis_param) |
572 |
- |
|
573 | 582 |
return(axis_grob) |
574 | 583 |
} |
575 | 584 |
|
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
|
2 | 2 |
# == title |
3 |
-# Draw the Heatmap Body |
|
3 |
+# Draw Heatmap Body |
|
4 | 4 |
# |
5 | 5 |
# == param |
6 | 6 |
# -object A `Heatmap-class` object. |
... | ... |
@@ -321,7 +321,7 @@ setMethod(f = "draw_dimnames", |
321 | 321 |
# -object A `Heatmap-class` object. |
322 | 322 |
# -which Is title put on the row or on the column of the heatmap? |
323 | 323 |
# -k Slice index. |
324 |
-# -... Pass to `grid::viewport` which includes the complete heatmap title |
|
324 |
+# -... Pass to `grid::viewport` which includes the complete heatmap title. |
|
325 | 325 |
# |
326 | 326 |
# == details |
327 | 327 |
# A viewport is created which contains heatmap title. |
... | ... |
@@ -6,11 +6,11 @@ |
6 | 6 |
# -object A `Heatmap-class` object. |
7 | 7 |
# |
8 | 8 |
# == detail |
9 |
-# The layout of the single heatmap will be established by setting the size of each heatmap components. |
|
9 |
+# The layout of the single heatmap will be established by setting the size of each heatmap component. |
|
10 | 10 |
# Also how to make graphics for heatmap components will be recorded by saving as functions. |
11 | 11 |
# |
12 | 12 |
# Whether to apply row clustering or column clustering affects the layout, so clustering should be applied |
13 |
-# first before making the layout. |
|
13 |
+# first by `prepare,Heatmap-method` before making the layout. |
|
14 | 14 |
# |
15 | 15 |
# This function is only for internal use. |
16 | 16 |
# |
... | ... |
@@ -476,7 +476,7 @@ setMethod(f = "show", |
476 | 476 |
# -direction Whether the heatmap is added horizontal or vertically? |
477 | 477 |
# |
478 | 478 |
# == details |
479 |
-# There is a shortcut function ``+.AdditiveUnit``. |
|
479 |
+# Normally we directly use ``+`` for horizontal concatenation and `\%v\%` for vertical concatenation. |
|
480 | 480 |
# |
481 | 481 |
# == value |
482 | 482 |
# A `HeatmapList-class` object. |
... | ... |
@@ -108,12 +108,14 @@ HeatmapAnnotation = function(..., |
108 | 108 |
) { |
109 | 109 |
|
110 | 110 |
dev.null() |
111 |
- on.exit(dev.off2()) |
|
112 | 111 |
|
113 | 112 |
.ENV$current_annotation_which = NULL |
114 | 113 |
which = match.arg(which)[1] |
115 | 114 |
.ENV$current_annotation_which = which |
116 |
- on.exit(.ENV$current_annotation_which <- NULL) |
|
115 |
+ on.exit({ |
|
116 |
+ .ENV$current_annotation_which <- NULL |
|
117 |
+ dev.off2() |
|
118 |
+ }) |
|
117 | 119 |
|
118 | 120 |
fun_args = names(as.list(environment())) |
119 | 121 |
|
... | ... |
@@ -409,10 +411,10 @@ HeatmapAnnotation = function(..., |
409 | 411 |
|
410 | 412 |
## adjust height/width if `width`/`annotation_width` is set |
411 | 413 |
if(which == "column") { |
412 |
- .Object = resize(.Object, height = height, annotation_height = annotation_height, |
|
414 |
+ .Object = re_size(.Object, height = height, annotation_height = annotation_height, |
|
413 | 415 |
anno_simple_size = anno_simple_size, simple_anno_size_adjust = simple_anno_size_adjust) |
414 | 416 |
} else { |
415 |
- .Object = resize(.Object, width = width, annotation_width = annotation_width, |
|
417 |
+ .Object = re_size(.Object, width = width, annotation_width = annotation_width, |
|
416 | 418 |
anno_simple_size = anno_simple_size, simple_anno_size_adjust = simple_anno_size_adjust) |
417 | 419 |
} |
418 | 420 |
|
... | ... |
@@ -744,7 +746,7 @@ nobs.HeatmapAnnotation = function(object, ...) { |
744 | 746 |
# -direction Whether it is a horizontal add or a vertical add? |
745 | 747 |
# |
746 | 748 |
# == details |
747 |
-# There is a helper function ``+.AdditiveUnit`` for horizontal add or `\%v\%` for vertical add. |
|
749 |
+# Normally we directly use ``+`` for horizontal concatenation and `\%v\%` for vertical concatenation. |
|
748 | 750 |
# |
749 | 751 |
# == value |
750 | 752 |
# A `HeatmapList-class` object. |
... | ... |
@@ -984,7 +986,7 @@ length.HeatmapAnnotation = function(x) { |
984 | 986 |
# and ``anno_simple_size`` is disabled. |
985 | 987 |
# 6. If ``simple_anno_size_adjust`` is ``FALSE``, the size of the simple annotations will not change. |
986 | 988 |
# |
987 |
-setMethod(f = "resize", |
|
989 |
+setMethod(f = "re_size", |
|
988 | 990 |
signature = "HeatmapAnnotation", |
989 | 991 |
definition = function(object, |
990 | 992 |
annotation_height = NULL, |
... | ... |
@@ -518,8 +518,8 @@ setMethod(f = "draw", |
518 | 518 |
upViewport() |
519 | 519 |
upViewport() |
520 | 520 |
|
521 |
- object@ht_list_param$width = ht_list_width |
|
522 |
- object@ht_list_param$height = ht_list_height |
|
521 |
+ object@ht_list_param$width = w |
|
522 |
+ object@ht_list_param$height = h |
|
523 | 523 |
|
524 | 524 |
for(i in seq_along(object@ht_list)) { |
525 | 525 |
if(inherits(object@ht_list[[i]], "Heatmap")) { |
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
|
2 | 2 |
# == title |
3 |
-# Adjust heatmap list |
|
3 |
+# Adjust Heatmap List |
|
4 | 4 |
# |
5 | 5 |
# == param |
6 | 6 |
# -object A `HeatmapList-class` object |
... | ... |
@@ -38,12 +38,12 @@ setMethod(f = "adjust_heatmap_list", |
38 | 38 |
for(i in ht_index) { |
39 | 39 |
if(has_component(object@ht_list[[i]], "column_anno_top")) { |
40 | 40 |
if(verbose) qqcat("adjust height of top annotation of heamtap @{object@ht_list[[i]]@name}\n") |
41 |
- object@ht_list[[i]]@top_annotation = resize(object@ht_list[[i]]@top_annotation, height = max_top_anno_height) |
|
41 |
+ object@ht_list[[i]]@top_annotation = re_size(object@ht_list[[i]]@top_annotation, height = max_top_anno_height) |
|
42 | 42 |
object@ht_list[[i]] = set_component_height(object@ht_list[[i]], "column_anno_top", object@ht_list[[i]]@top_annotation@height + ht_opt$COLUMN_ANNO_PADDING) |
43 | 43 |
} |
44 | 44 |
if(has_component(object@ht_list[[i]], "column_anno_bottom")) { |
45 | 45 |
if(verbose) qqcat("adjust height of bottom annotation of heamtap @{object@ht_list[[i]]@name}\n") |
46 |
- object@ht_list[[i]]@bottom_annotation = resize(object@ht_list[[i]]@bottom_annotation, height = max_bottom_anno_height) |
|
46 |
+ object@ht_list[[i]]@bottom_annotation = re_size(object@ht_list[[i]]@bottom_annotation, height = max_bottom_anno_height) |
|
47 | 47 |
object@ht_list[[i]] = set_component_height(object@ht_list[[i]], "column_anno_bottom", object@ht_list[[i]]@bottom_annotation@height + ht_opt$COLUMN_ANNO_PADDING) |
48 | 48 |
} |
49 | 49 |
} |
... | ... |
@@ -240,12 +240,12 @@ setMethod(f = "adjust_heatmap_list", |
240 | 240 |
for(i in ht_index) { |
241 | 241 |
if(has_component(object@ht_list[[i]], "row_anno_left")) { |
242 | 242 |
if(verbose) qqcat("adjust width of left annotation of heamtap @{object@ht_list[[i]]@name}\n") |
243 |
- object@ht_list[[i]]@left_annotation = resize(object@ht_list[[i]]@left_annotation, width = max_left_anno_width) |
|
243 |
+ object@ht_list[[i]]@left_annotation = re_size(object@ht_list[[i]]@left_annotation, width = max_left_anno_width) |
|
244 | 244 |
object@ht_list[[i]] = set_component_width(object@ht_list[[i]], "row_anno_left", object@ht_list[[i]]@left_annotation@width + ht_opt$ROW_ANNO_PADDING) |
245 | 245 |
} |
246 | 246 |
if(has_component(object@ht_list[[i]], "row_anno_right")) { |
247 | 247 |
if(verbose) qqcat("adjust width of right annotation of heamtap @{object@ht_list[[i]]@name}\n") |
248 |
- object@ht_list[[i]]@right_annotation = resize(object@ht_list[[i]]@right_annotation, width = max_right_anno_width) |
|
248 |
+ object@ht_list[[i]]@right_annotation = re_size(object@ht_list[[i]]@right_annotation, width = max_right_anno_width) |
|
249 | 249 |
object@ht_list[[i]] = set_component_width(object@ht_list[[i]], "row_anno_right", object@ht_list[[i]]@right_annotation@width + ht_opt$ROW_ANNO_PADDING) |
250 | 250 |
} |
251 | 251 |
} |
... | ... |
@@ -537,16 +537,6 @@ setMethod(f = "draw_heatmap_list", |
537 | 537 |
} else if(inherits(ht, "HeatmapAnnotation")) { |
538 | 538 |
# calcualte the position of the heatmap body |
539 | 539 |
pushViewport(viewport(y = max_bottom_component_height, height = unit(1, "npc") - max_top_component_height - max_bottom_component_height, just = c("bottom"))) |
540 |
- # if(length(ht) == 1 & n_slice > 1) { |
|
541 |
- # if(inherits(ht@anno_list[[1]], "AnnotationFunction")) { |
|
542 |
- # if(identical(ht@anno_list[[1]]@fun@fun_name, "anno_mark")) { |
|
543 |
- # # adjust pos_map var |
|
544 |
- # fun = ht@anno_list[[1]]@fun |
|
545 |
- # draw(fun, index = ht_main@row_order) |
|
546 |
- # next |
|
547 |
- # } |
|
548 |
- # } |
|
549 |
- # } |
|
550 | 540 |
for(j in seq_len(n_slice)) { |
551 | 541 |
draw(ht, index = ht_main@row_order_list[[j]], y = slice_y[j], height = slice_height[j], just = slice_just[2], k = j, n = n_slice) |
552 | 542 |
} |
... | ... |
@@ -1,13 +1,19 @@ |
1 | 1 |
|
2 | 2 |
# == title |
3 |
-# Draw legends for all heatmaps |
|
3 |
+# Draw legends for All Heatmaps |
|
4 | 4 |
# |
5 | 5 |
# == param |
6 |
-# -object a `HeatmapList-class` object |
|
7 |
-# -legend_list a list of self-defined legend, should be wrapped into `grid::grob` objects. |
|
8 |
-# -... graphic parameters passed to `color_mapping_legend,ColorMapping-method`. |
|
6 |
+# -object A `HeatmapList-class` object. |
|
7 |
+# -legend_list A list of self-defined legends, should be wrapped into `grid::grob` objects. It is |
|
8 |
+# normally constructed by `Legend`. |
|
9 |
+# -... Other arguments. |
|
9 | 10 |
# |
10 | 11 |
# == details |
12 |
+# Actually we call the "heatmap legends" as the main legends. |
|
13 |
+# For horizontal heatmap list, the legends are those from heamtap/row annotation/left/right annotation. |
|
14 |
+# For vertical heatmap list, the legends are those from heamtap/column annotation/top/bottom annotation. |
|
15 |
+# if ``merge_legends`` is true in `draw,HeatmapList-method`, then it contains all legends shown on the plot. |
|
16 |
+# |
|
11 | 17 |
# A viewport is created which contains heatmap legends. |
12 | 18 |
# |
13 | 19 |
# This function is only for internal use. |
... | ... |
@@ -128,14 +134,19 @@ setMethod(f = "draw_heatmap_legend", |
128 | 134 |
}) |
129 | 135 |
|
130 | 136 |
# == title |
131 |
-# Draw legends for all column annotations |
|
137 |
+# Draw legends for All Annotations |
|
132 | 138 |
# |
133 | 139 |
# == param |
134 |
-# -object a `HeatmapList-class` object |
|
135 |
-# -legend_list a list of self-defined legend, should be wrapped into `grid::grob` objects. |
|
136 |
-# -... graphic parameters passed to `color_mapping_legend,ColorMapping-method`. |
|
140 |
+# -object A `HeatmapList-class` object. |
|
141 |
+# -legend_list A list of self-defined legends, should be wrapped into `grid::grob` objects. |
|
142 |
+# It is normally constructed by `Legend`. |
|
143 |
+# -... Other arguments. |
|
137 | 144 |
# |
138 | 145 |
# == details |
146 |
+# We call the "annotation legends" as the secondary legends. |
|
147 |
+# For horizontal heamtap list, the legends are those from all top/bottom annotations, and for vertical heatmap list, |
|
148 |
+# the legends are those from all left/right annotations. |
|
149 |
+# |
|
139 | 150 |
# A viewport is created which contains annotation legends. |
140 | 151 |
# |
141 | 152 |
# This function is only for internal use. |
... | ... |
@@ -212,14 +223,17 @@ setMethod(f = "draw_annotation_legend", |
212 | 223 |
}) |
213 | 224 |
|
214 | 225 |
# == title |
215 |
-# Size of the heatmap legend viewport |
|
226 |
+# Size of the Heatmap Legends |
|
216 | 227 |
# |
217 | 228 |
# == param |
218 |
-# -object a `HeatmapList-class` object |
|
219 |
-# -legend_list a list of self-defined legend, should be wrapped into `grid::grob` objects. |
|
220 |
-# -... graphic parameters passed to `color_mapping_legend,ColorMapping-method`. |
|
229 |
+# -object A `HeatmapList-class` object. |
|
230 |
+# -legend_list A list of self-defined legend, should be wrapped into `grid::grob` objects. |
|
231 |
+# It is normally constructed by `Legend`. |
|
232 |
+# -... Other arguments. |
|
221 | 233 |
# |
222 | 234 |
# == detail |
235 |
+# Internally, all heatmap legends are packed by `packLegend` as a single `grid::grob` object. |
|
236 |
+# |
|
223 | 237 |
# This function is only for internal use. |
224 | 238 |
# |
225 | 239 |
# == value |
... | ... |
@@ -301,16 +315,16 @@ setMethod(f = "heatmap_legend_size", |
301 | 315 |
}) |
302 | 316 |
|
303 | 317 |
# == title |
304 |
-# Size of the annotation legend viewport |
|
318 |
+# Size of the Annotation Legends |
|
305 | 319 |
# |
306 | 320 |
# == param |
307 | 321 |
# -object a `HeatmapList-class` object. |
308 |
-# -legend_list a list of self-defined legend, should be wrapped into `grid::grob` objects. |
|
309 |
-# -... graphic parameters passed to `color_mapping_legend,ColorMapping-method`. |
|
322 |
+# -legend_list A list of self-defined legend, should be wrapped into `grid::grob` objects. |
|
323 |
+# It is normally constructed by `Legend`. |
|
324 |
+# -... Other arguments. |
|
310 | 325 |
# |
311 | 326 |
# == detail |
312 |
-# Legends for all heatmaps or legends for all annotations will be put in one viewport. This function |
|
313 |
-# calculates the size of such viewport. Note graphic parameters for legends will affect the size. |
|
327 |
+# Internally, all annotation legends are packed by `packLegend` as a single `grid::grob` object. |
|
314 | 328 |
# |
315 | 329 |
# This function is only for internal use. |
316 | 330 |
# |
... | ... |
@@ -1,17 +1,105 @@ |
1 | 1 |
# == title |
2 |
-# Grob for annotation axis |
|
2 |
+# Grob for Annotation Axis |
|
3 | 3 |
# |
4 | 4 |
# == param |
5 |
-# -at Break values. |
|
5 |
+# -at Break values. If it is not specified, it is inferred from data scale in current viewport. |
|
6 | 6 |
# -labels Corresponding labels. |
7 | 7 |
# -labels_rot Rotations of labels. |
8 | 8 |
# -gp Graphic parameters. |
9 |
-# -side side of the axis to the annotation viewport. |
|
9 |
+# -side side of the axis of the annotation viewport. |
|
10 | 10 |
# -facing Facing of the axis. |
11 | 11 |
# |
12 | 12 |
# == value |
13 | 13 |
# A `grid::grob` object. |
14 | 14 |
# |
15 |
+# == examples |
|
16 |
+# gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, |
|
17 |
+# side = "left", facing = "outside") |
|
18 |
+# grid.newpage() |
|
19 |
+# pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
20 |
+# grid.draw(gb) |
|
21 |
+# grid.rect(x = unit(0, "npc"), width = grobWidth(gb), just = "right") |
|
22 |
+# popViewport() |
|
23 |
+# |
|
24 |
+# gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, |
|
25 |
+# side = "left", facing = "inside") |
|
26 |
+# grid.newpage() |
|
27 |
+# pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
28 |
+# grid.draw(gb) |
|
29 |
+# grid.rect(x = unit(0, "npc"), width = grobWidth(gb), just = "left") |
|
30 |
+# popViewport() |
|
31 |
+# |
|
32 |
+# gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, |
|
33 |
+# side = "right", facing = "outside") |
|
34 |
+# grid.newpage() |
|
35 |
+# pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
36 |
+# grid.draw(gb) |
|
37 |
+# grid.rect(x = unit(1, "npc"), width = grobWidth(gb), just = "left") |
|
38 |
+# popViewport() |
|
39 |
+# |
|
40 |
+# gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, |
|
41 |
+# side = "right", facing = "inside") |
|
42 |
+# grid.newpage() |
|
43 |
+# pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
44 |
+# grid.draw(gb) |
|
45 |
+# grid.rect(x = unit(1, "npc"), width = grobWidth(gb), just = "right") |
|
46 |
+# popViewport() |
|
47 |
+# |
|
48 |
+# gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, |
|
49 |
+# side = "top", facing = "outside") |
|
50 |
+# grid.newpage() |
|
51 |
+# pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
52 |
+# grid.draw(gb) |
|
53 |
+# grid.rect(y = unit(1, "npc"), height = grobHeight(gb), just = "bottom") |
|
54 |
+# popViewport() |
|
55 |
+# |
|
56 |
+# gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 90, |
|
57 |
+# side = "top", facing = "outside") |
|
58 |
+# grid.newpage() |
|
59 |
+# pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
60 |
+# grid.draw(gb) |
|
61 |
+# grid.rect(y = unit(1, "npc"), height = grobHeight(gb), just = "bottom") |
|
62 |
+# popViewport() |
|
63 |
+# |
|
64 |
+# gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 45, |
|
65 |
+# side = "top", facing = "outside") |
|
66 |
+# grid.newpage() |
|
67 |
+# pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
68 |
+# grid.draw(gb) |
|
69 |
+# grid.rect(y = unit(1, "npc"), height = grobHeight(gb), just = "bottom") |
|
70 |
+# popViewport() |
|
71 |
+# |
|
72 |
+# gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, |
|
73 |
+# side = "top", facing = "inside") |
|
74 |
+# grid.newpage() |
|
75 |
+# pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
76 |
+# grid.draw(gb) |
|
77 |
+# grid.rect(y = unit(1, "npc"), height = grobHeight(gb), just = "top") |
|
78 |
+# popViewport() |
|
79 |
+# |
|
80 |
+# gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, |
|
81 |
+# side = "bottom", facing = "outside") |
|
82 |
+# grid.newpage() |
|
83 |
+# pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
84 |
+# grid.draw(gb) |
|
85 |
+# grid.rect(y = unit(0, "npc"), height = grobHeight(gb), just = "top") |
|
86 |
+# popViewport() |
|
87 |
+# |
|
88 |
+# gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, |
|
89 |
+# side = "bottom", facing = "inside") |
|
90 |
+# grid.newpage() |
|
91 |
+# pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
92 |
+# grid.draw(gb) |
|
93 |
+# grid.rect(y = unit(0, "npc"), height = grobHeight(gb), just = "bottom") |
|
94 |
+# popViewport() |
|
95 |
+# |
|
96 |
+# grid.newpage() |
|
97 |
+# pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
98 |
+# gb = annotation_axis_grob(labels_rot = 0, side = "left", facing = "outside") |
|
99 |
+# grid.draw(gb) |
|
100 |
+# grid.rect(x = unit(0, "npc"), width = grobWidth(gb), just = "right") |
|
101 |
+# popViewport() |
|
102 |
+# |
|
15 | 103 |
annotation_axis_grob = function(at = NULL, labels = at, labels_rot = 0, gp = gpar(), |
16 | 104 |
side = "left", facing = "outside") { |
17 | 105 |
|
... | ... |
@@ -136,20 +224,26 @@ annotation_axis_grob = function(at = NULL, labels = at, labels_rot = 0, gp = gpa |
136 | 224 |
|
137 | 225 |
|
138 | 226 |
# == title |
139 |
-# Grob width for annotation_axis |
|
227 |
+# Width for annotation_axis Grob |
|
140 | 228 |
# |
141 | 229 |
# == param |
142 |
-# -x legend body |
|
230 |
+# -x The ``annotation_axis`` grob returned by `annotation_axis_grob`. |
|
231 |
+# |
|
232 |
+# == details |
|
233 |
+# The physical width of the grob can be get by ``convertWidth(grobWidth(axis_grob), "mm")``. |
|
143 | 234 |
# |
144 | 235 |
widthDetails.annotation_axis = function(x) { |
145 | 236 |
attr(x, "width") |
146 | 237 |
} |
147 | 238 |
|
148 | 239 |
# == title |
149 |
-# Grob width for annotation_axis |
|
240 |
+# Height for annotation_axis Grob |
|
150 | 241 |
# |
151 | 242 |
# == param |
152 |
-# -x legend body |
|
243 |
+# -x The ``annotation_axis`` grob returned by `annotation_axis_grob`. |
|
244 |
+# |
|
245 |
+# == details |
|
246 |
+# The physical height of the grob can be get by ``convertWidth(grobHeight(axis_grob), "mm")``. |
|
153 | 247 |
# |
154 | 248 |
heightDetails.annotation_axis = function(x) { |
155 | 249 |
attr(x, "height") |
... | ... |
@@ -23,7 +23,7 @@ |
23 | 23 |
# -column_names_gp Pass to `Heatmap`. |
24 | 24 |
# -column_names_rot Pass to `Heatmap`. |
25 | 25 |
# -cluster_columns Whether cluster columns (here clustered by density values)? Normally we don't cluster columns. |
26 |
-# - clustering_distance_columns |
|
26 |
+# -clustering_distance_columns |
|
27 | 27 |
# -clustering_method_columns |
28 | 28 |
# -... pass to `Heatmap`. |
29 | 29 |
# |
... | ... |
@@ -1,15 +1,14 @@ |
1 | 1 |
|
2 | 2 |
|
3 | 3 |
# == title |
4 |
-# Global Options |
|
4 |
+# Global Options for Heatmaps |
|
5 | 5 |
# |
6 | 6 |
# == param |
7 |
-# -... options, see 'details' section |
|
8 |
-# -RESET reset all the option values |
|
9 |
-# -READ.ONLY ``TRUE`` means only to return read-only values, ``FALSE`` means only to return non-read-only |
|
10 |
-# values, ``NULL`` means to return both. |
|
11 |
-# -LOCAL switch local mode |
|
12 |
-# -ADD add new options |
|
7 |
+# -... Options, see 'Details' section. |
|
8 |
+# -RESET Reset all the option values. |
|
9 |
+# -READ.ONLY Please ignore this argument. |
|
10 |
+# -LOCAL Please ignore this argument. |
|
11 |
+# -ADD Please ignore this argument. |
|
13 | 12 |
# |
14 | 13 |
# == details |
15 | 14 |
# You can set some parameters for all heatmaps/annotations simultaneously by this global function. |
... | ... |
@@ -24,27 +23,27 @@ |
24 | 23 |
# -heatmap_column_title_gp set ``column_title_gp`` in all `Heatmap`. |
25 | 24 |
# -heatmap_border set ``border`` in all `Heatmap`. |
26 | 25 |
# |
27 |
-# Following parameters to control the legends: |
|
26 |
+# Following parameters control the legends: |
|
28 | 27 |
# |
29 |
-# -legend_title_gp set |
|
30 |
-# -legend_title_position |
|
31 |
-# -legend_labels_gp |
|
32 |
-# -legend_grid_width |
|
33 |
-# -legend_grid_height |
|
34 |
-# -legend_border |
|
28 |
+# -legend_title_gp set ``title_gp`` in all heatmap legends and annotation legends. |
|
29 |
+# -legend_title_position set ``title_position`` in all heatmap legends and annotation legends. |
|
30 |
+# -legend_labels_gp set ``labels_gp`` in all heatmap legends and annotation legends. |
|
31 |
+# -legend_grid_width set ``grid_width`` in all heatmap legends and annotation legends. |
|
32 |
+# -legend_grid_height set ``grid_height`` in all heatmap legends and annotation legends. |
|
33 |
+# -legend_border set ``border`` in all heatmap legends and annotation legends. |
|
35 | 34 |
# |
36 |
-# Following parameters to control annotations: |
|
35 |
+# Following parameters control heatmap annotations: |
|
37 | 36 |
# |
38 |
-# -annotation_border border of all annotations |
|
37 |
+# -annotation_border ``border`` in all `HeatmapAnnotation`. |
|
39 | 38 |
# -anno_simple_size size for the simple annotation. |
40 | 39 |
# |
41 |
-# Following parameters to control the space between heatmap components: |
|
40 |
+# Following parameters control the space between heatmap components: |
|
42 | 41 |
# |
43 |
-# -DENDROGRAM_PADDING space bewteen dendrograms and heatmap body |
|
44 |
-# -DIMNAME_PADDING space between row/column names and heatmap body |
|
45 |
-# -TITLE_PADDING space between row/column titles and heatmap body |
|
46 |
-# -COLUMN_ANNO_PADDING space between column annotations and heatmap body |
|
47 |
-# -ROW_ANNO_PADDING space between row annotations and heatmap body |
|
42 |
+# -DENDROGRAM_PADDING space bewteen dendrograms and heatmap body. |
|
43 |
+# -DIMNAME_PADDING space between row/column names and heatmap body. |
|
44 |
+# -TITLE_PADDING space between row/column titles and heatmap body. |
|
45 |
+# -COLUMN_ANNO_PADDING space between column annotations and heatmap body. |
|
46 |
+# -ROW_ANNO_PADDING space between row annotations and heatmap body. |
|
48 | 47 |
# |
49 | 48 |
# Other parameters: |
50 | 49 |
# |
... | ... |
@@ -66,8 +65,7 @@ |
66 | 65 |
# Zuguang Gu <z.gu@dkfz.de> |
67 | 66 |
# |
68 | 67 |
# == example |
69 |
-# # no example for this function |
|
70 |
-# NULL |
|
68 |
+# ht_opt |
|
71 | 69 |
# |
72 | 70 |
ht_opt = function(..., RESET = FALSE, READ.ONLY = NULL, LOCAL = FALSE, ADD = FALSE) {} |
73 | 71 |
ht_opt = setGlobalOptions( |
... | ... |
@@ -154,15 +152,15 @@ ht_opt = setGlobalOptions( |
154 | 152 |
|
155 | 153 |
|
156 | 154 |
# == title |
157 |
-# Global graphic options for heatmaps |
|
155 |
+# Global Options for Heatmaps |
|
158 | 156 |
# |
159 | 157 |
# == param |
160 |
-# -... options, see 'details' section |
|
161 |
-# -RESET reset all the option values |
|
158 |
+# -... Options. |
|
159 |
+# -RESET Reset all the option values. |
|
162 | 160 |
# -READ.ONLY ``TRUE`` means only to return read-only values, ``FALSE`` means only to return non-read-only |
163 | 161 |
# values, ``NULL`` means to return both. |
164 |
-# -LOCAL switch local mode |
|
165 |
-# -ADD add new options |
|
162 |
+# -LOCAL Wwitch to local mode. |
|
163 |
+# -ADD Add new options. |
|
166 | 164 |
# |
167 | 165 |
# == details |
168 | 166 |
# This function is deprecated. Please use `ht_opt` instead. However, changes by this function |
... | ... |
@@ -16,7 +16,7 @@ subset_dendrogram = function(x, ind) { |
16 | 16 |
# Adjust the Positions of nodes/leaves in the Dendrogram |
17 | 17 |
# |
18 | 18 |
# == param |
19 |
-# -dend A `dendrogram` object |
|
19 |
+# -dend A `dendrogram` object. |
|
20 | 20 |
# -leaf_pos A vector of positions of leaves. The value can also be a `grid::unit` object. |
21 | 21 |
# |
22 | 22 |
# == detail |
... | ... |
@@ -188,18 +188,19 @@ construct_dend_segments = function(dend, gp) { |
188 | 188 |
# == param |
189 | 189 |
# -dend A `dendrogram` object. |
190 | 190 |
# -facing Facing of the dendrogram. |
191 |
-# -order If it is set to ``reverse``, the first element is put on the right if the dendrogram |
|
191 |
+# -order If it is set to ``reverse``, the first leaf is put on the right if the dendrogram |
|
192 | 192 |
# is horizontal and it is put on the top if the dendrogram is vertical. |
193 | 193 |
# -gp Graphic parameters for the dendrogram segments. If any of ``col``, ``lwd`` or ``lty`` is set |
194 | 194 |
# in the ``edgePar`` attribute of a node, the corresponding value defined in ``gp`` will be |
195 |
-# overwritten for this node, so ``gp`` is like a global graphic parameters for dendrogram segments. |
|
195 |
+# overwritten for this node, so ``gp`` is like global graphic parameters for dendrogram segments. |
|
196 | 196 |
# |
197 | 197 |
# == details |
198 | 198 |
# If ``dend`` has not been processed by `adjust_dend_by_x`, internally `adjust_dend_by_x` is called |
199 |
-# to add ``x`` attributes of each node/leaf. |
|
199 |
+# to add ``x`` attributes to each node/leaf. |
|
200 | 200 |
# |
201 | 201 |
# == value |
202 |
-# A `grob` object which is generally contructed by `grid::segmentsGrob`. |
|
202 |
+# A `grob` object which is contructed by `grid::segmentsGrob`. |
|
203 |
+# |
|
203 | 204 |
dendrogramGrob = function(dend, facing = c("bottom", "top", "left", "right"), |
204 | 205 |
order = c("normal", "reverse"), gp = gpar()) { |
205 | 206 |
|
... | ... |
@@ -481,10 +482,10 @@ dend_branches_heights = function(d, v = NULL) { |
481 | 482 |
|
482 | 483 |
|
483 | 484 |
# == title |
484 |
-# Height of dendrograms |
|
485 |
+# Height of the Dendrograms |
|
485 | 486 |
# |
486 | 487 |
# == param |
487 |
-# -x a `dendrogram` object and a list of `dendrogram` objects. |
|
488 |
+# -x a `dendrogram` object or a list of `dendrogram` objects. |
|
488 | 489 |
# |
489 | 490 |
dend_heights = function(x) { |
490 | 491 |
if(is.null(x)) return(0) |
... | ... |
@@ -506,7 +507,7 @@ dend_heights = function(x) { |
506 | 507 |
# ``dend`` will be processed by `adjust_dend_by_x` if it is processed yet. |
507 | 508 |
# |
508 | 509 |
# == value |
509 |
-# A list of leave positions and dendrogram height. |
|
510 |
+# A list of leave positions (``x``) and dendrogram height (``y``). |
|
510 | 511 |
# |
511 | 512 |
# == example |
512 | 513 |
# m = matrix(rnorm(100), 10) |
... | ... |
@@ -556,7 +557,7 @@ dend_xy = function(dend) { |
556 | 557 |
# compare to between-group dendrogram. |
557 | 558 |
# |
558 | 559 |
# == value |
559 |
-# A `dendrogram` object. The order of columns can be retrieved by `order.dendrogram`. |
|
560 |
+# A `dendrogram` object. The order of columns can be retrieved by `stat::order.dendrogram`. |
|
560 | 561 |
# |
561 | 562 |
# == example |
562 | 563 |
# m = matrix(rnorm(120), nc = 12) |
... | ... |
@@ -594,5 +595,4 @@ cluster_within_group = function(mat, factor) { |
594 | 595 |
dend = merge_dendrogram(parent, dend_list) |
595 | 596 |
order.dendrogram(dend) = unlist(order_list) |
596 | 597 |
return(dend) |
597 |
- |
|
598 | 598 |
} |
... | ... |
@@ -14,6 +14,7 @@ |
14 | 14 |
# -col a vector of color for which names correspond to alteration types. |
15 | 15 |
# -top_annotation Annotation put on top of the oncoPrint. By default it is barplot which shows the number of genes having the alteration in each sample. |
16 | 16 |
# -right_annotation Annotation put on the right of hte oncoPrint. By default it is barplto which shows the number of samples having the alteration in each gene. |
17 |
+# -bottom_annotation |
|
17 | 18 |
# -show_pct whether show percent values on the left of the oncoprint |
18 | 19 |
# -pct_gp graphic paramters for percent row annotation |
19 | 20 |
# -pct_digits digits for percent values |
... | ... |
@@ -6,10 +6,10 @@ |
6 | 6 |
# multiple heatmaps as well as flexible annotation graphics. |
7 | 7 |
# |
8 | 8 |
# The package is implemented in an object-oriented way. |
9 |
-# Components of heatmap lists are abstracted into several classes. |
|
9 |
+# The heatmap lists are abstracted into several classes. |
|
10 | 10 |
# |
11 |
-# - `Heatmap-class`: a single heatmap containing heatmap body, row/column names, titles, dendrograms and column annotations. |
|
12 |
-# - `HeatmapList-class`: a list of heatmaps and row/column annotations. |
|
11 |
+# - `Heatmap-class`: a single heatmap containing heatmap body, row/column names, titles, dendrograms and annotations. |
|
12 |
+# - `HeatmapList-class`: a list of heatmaps and annotations. |
|
13 | 13 |
# - `HeatmapAnnotation-class`: a list of row/column annotations. |
14 | 14 |
# |
15 | 15 |
# There are also several internal classes: |
... | ... |
@@ -18,7 +18,10 @@ |
18 | 18 |
# - `ColorMapping-class`: mapping from values to colors. |
19 | 19 |
# - `AnnotationFunction-class`: construct an annotation function which allows subsetting. |
20 | 20 |
# |
21 |
-# For plotting one single heatmap, please go to the documentation page of `Heatmap`. |
|
22 |
-# For plotting multiple heatmaps, please go to `HeatmapList-class`, ``+.AdditiveUnit`` and ``\%v\%.AdditiveUnit``. |
|
21 |
+# Following two high-level functions take use of functionality of complex heatmaps: |
|
23 | 22 |
# |
24 |
-# You can refer to the ComplexHeatmap Complete Reference for all the information of this package (). |
|
23 |
+# - `oncoPrint`: oncoPrint plot which visualize genomic alterations in a set of genes. |
|
24 |
+# - `densityHeatmap`: use heatmaps to visualize density distributions. |
|
25 |
+# |
|
26 |
+# The complete reference of ComplexHeatmap package is available at http://jokergoo.github.io/ComplexHeatmap-reference/book. |
|
27 |
+# |
|
25 | 28 |
\ No newline at end of file |
... | ... |
@@ -95,7 +95,7 @@ default_col = function(x, main_matrix = FALSE) { |
95 | 95 |
# Calculate Pairwise Distance from a Matrix |
96 | 96 |
# |
97 | 97 |
# == param |
98 |
-# -mat A matrix. The distance is calculated by rows. |
|
98 |
+# -x A matrix or a list. If it is a matrix, the distance is calculated by rows. |
|
99 | 99 |
# -pairwise_fun A function which calculates distance between two vectors. |
100 | 100 |
# -... Pass to `stats::as.dist`. |
101 | 101 |
# |
... | ... |
@@ -109,27 +109,49 @@ default_col = function(x, main_matrix = FALSE) { |
109 | 109 |
# == author |
110 | 110 |
# Zuguang Gu <z.gu@dkfz.de> |
111 | 111 |
# |
112 |
-dist2 = function(mat, pairwise_fun = function(x, y) sqrt(sum((x - y)^2)), ...) { |
|
112 |
+# == example |
|
113 |
+# lt = lapply(1:10, function(i) { |
|
114 |
+# sample(letters, sample(6:10, 1)) |
|
115 |
+# }) |
|
116 |
+# dist2(lt, function(x, y) { |
|
117 |
+# length(intersect(x, y))/length(union(x, y)) |
|
118 |
+# }) |
|
119 |
+dist2 = function(x, pairwise_fun = function(x, y) sqrt(sum((x - y)^2)), ...) { |
|
113 | 120 |
|
114 |
- if(!is.matrix(mat)) { |
|
115 |
- stop("`mat` should be a matrix.") |
|
116 |
- } |
|
121 |
+ if(is.matrix(x)) { |
|
122 |
+ if(nrow(x) < 2) { |
|
123 |
+ stop_wrap("`x` should have at least two rows.") |
|
124 |
+ } |
|
117 | 125 |
|
118 |
- if(nrow(mat) < 2) { |
|
119 |
- stop("`mat` should have at least two rows.") |
|
120 |
- } |
|
126 |
+ nr = nrow(x) |
|
127 |
+ mat2 = matrix(NA, nrow = nr, ncol = nr) |
|
128 |
+ rownames(mat2) = colnames(mat2) = rownames(x) |
|
121 | 129 |
|
122 |
- nr = nrow(mat) |
|
123 |
- mat2 = matrix(NA, nrow = nr, ncol = nr) |
|
124 |
- rownames(mat2) = colnames(mat2) = rownames(mat) |
|
130 |
+ for(i in 2:nr) { |
|
131 |
+ for(j in 1:(nr-1)) { |
|
132 |
+ mat2[i, j] = pairwise_fun(x[i, ], x[j, ]) |
|
133 |
+ } |
|
134 |
+ } |
|
125 | 135 |
|
126 |
- for(i in 2:nr) { |
|
127 |
- for(j in 1:(nr-1)) { |
|
128 |
- mat2[i, j] = pairwise_fun(mat[i, ], mat[j, ]) |
|
136 |
+ as.dist(mat2, ...) |
|
137 |
+ } else if(is.list(x)) { |
|
138 |
+ if(length(x) < 2) { |
|
139 |
+ stop_wrap("`x` should have at least length of 2.") |
|
129 | 140 |
} |
130 |
- } |
|
131 | 141 |
|
132 |
- as.dist(mat2, ...) |
|
142 |
+ nr = length(x) |
|
143 |
+ mat2 = matrix(NA, nrow = nr, ncol = nr) |
|
144 |
+ rownames(mat2) = colnames(mat2) = names(x) |
|
145 |
+ |
|
146 |
+ for(i in 2:nr) { |
|
147 |
+ for(j in 1:(nr-1)) { |
|
148 |
+ mat2[i, j] = pairwise_fun(x[[i]], x[[j]]) |
|
149 |
+ } |
|
150 |
+ } |
|
151 |
+ as.dist(mat2, ...) |
|
152 |
+ } else { |
|
153 |
+ stop_wrap("`x` can be a matrix or a list.") |
|
154 |
+ } |
|
133 | 155 |
} |
134 | 156 |
|
135 | 157 |
|
... | ... |
@@ -197,7 +219,7 @@ check_gp = function(gp) { |
197 | 219 |
|
198 | 220 |
|
199 | 221 |
# == title |
200 |
-# Subset a gpar object |
|
222 |
+# Subset a gpar Object |
|
201 | 223 |
# |
202 | 224 |
# == param |
203 | 225 |
# -gp A `gpar` object. |
... | ... |
@@ -306,7 +328,7 @@ list_components = function() { |
306 | 328 |
# -gp Graphic parameters for text. |
307 | 329 |
# |
308 | 330 |
# == details |
309 |
-# Simply calculate maximum width of a list of `grid::textGrob` objects. |
|
331 |
+# It simply calculates maximum width of a list of `grid::textGrob` objects. |
|
310 | 332 |
# |
311 | 333 |
# Note it ignores the text rotation. |
312 | 334 |
# |
... | ... |
@@ -342,7 +364,7 @@ max_text_width = function(text, gp = gpar()) { |
342 | 364 |
# -gp Graphic parameters for text. |
343 | 365 |
# |
344 | 366 |
# == details |
345 |
-# Simply calculate maximum height of a list of `grid::textGrob` objects. |
|
367 |
+# It simply calculates maximum height of a list of `grid::textGrob` objects. |
|
346 | 368 |
# |
347 | 369 |
# Note it ignores the text rotation. |
348 | 370 |
# |
... | ... |
@@ -520,31 +542,65 @@ recycle_param = function(x, all_names, default) { |
520 | 542 |
} |
521 | 543 |
|
522 | 544 |
# == title |
523 |
-# Convert XY in a parent viewport |
|
545 |
+# Convert XY in a Parent Viewport |
|
524 | 546 |
# |
525 | 547 |
# == param |
526 |
-# -u A list of two units which is x and y |
|
527 |
-# -vp_name the name of the parent viewport |
|
548 |
+# -u A list of two units which correspond to x and y. |
|
549 |
+# -vp_name The name of the parent viewport. |
|
528 | 550 |
# |
551 |
+# == details |
|
552 |
+# It converts a coordinate measured in current viewport to the coordinate in a parent viewport. |
|
553 |
+# |
|
554 |
+# In the conversion, all units are recalculated as absolute units, so if you change the size |
|
555 |
+# of the interactive graphic window, you need to rerun the function. |
|
556 |
+# |
|
557 |
+# == value |
|
558 |
+# A list of two units. |
|
559 |
+# |
|
529 | 560 |
# == example |
530 | 561 |
# grid.newpage() |
531 | 562 |
# pushViewport(viewport(x = 0.5, y = 0.5, width = 0.5, height = 0.5, just = c("left", "bottom"))) |
563 |
+# grid.rect() |
|
564 |
+# grid.points(x = unit(2, "cm"), y = unit(2, "cm"), pch = 1) |
|
532 | 565 |
# u = list(x = unit(2, "cm"), y = unit(2, "cm")) |
533 |
-# convertXY_in_vp(u) |
|
534 |
-convertXY_in_vp = function(u, vp_name = "ROOT") { |
|
566 |
+# u2 = getXY_in_parent_vp(u) |
|
567 |
+# popViewport() |
|
568 |
+# grid.rect(gp = gpar(col = "red")) |
|
569 |
+# grid.points(x = u2$x, u2$y, pch = 2) |
|
570 |
+getXY_in_parent_vp = function(u, vp_name = "ROOT") { |
|
571 |
+ if(inherits(u, "unit")) { |
|
572 |
+ if(length(u) == 2) { |
|
573 |
+ u = list(x = u[1], y = u[2]) |
|
574 |
+ } else { |
|
575 |
+ stop_wrap("If `u` is a unit vector, it must have length of 2.") |
|
576 |
+ } |
|
577 |
+ } |
|
578 |
+ if(length(u) != 2) { |
|
579 |
+ stop_wrap("`u` should be a list of length of 2 (two elements: `x` and `y`).") |
|
580 |
+ } |
|
581 |
+ if(is.null(names(u))) { |
|
582 |
+ names(u) = c("x", "y") |
|
583 |
+ } |
|
584 |
+ |
|
535 | 585 |
vp = current.viewport() |
536 | 586 |
current_vp_name = vp$name |
537 | 587 |
original_vp_name = current_vp_name |
588 |
+ on.exit(seekViewport(original_vp_name)) |
|
589 |
+ |
|
590 |
+ if(current_vp_name == "ROOT") { |
|
591 |
+ return(u) |
|
592 |
+ } |
|
538 | 593 |
while(current_vp_name != vp_name) { |
539 | 594 |
|
540 | 595 |
if(current_vp_name == "ROOT") { |
541 |
- return(u) |
|
596 |
+ stop_wrap(qq("Cannot find a parent viewport with name \"@{vp_name}\".")) |
|
542 | 597 |
} |
543 | 598 |
|
544 | 599 |
u$x = convertX(u$x, "mm") |
545 | 600 |
u$y = convertX(u$y, "mm") |
546 |
- current_vp_x = convertX(vp$x - vp$width*vp$valid.just[1], "mm") |
|
547 |
- current_vp_y = convertY(vp$y - vp$height*vp$valid.just[2], "mm") |
|
601 |
+ # vp is measured in parent vp |
|
602 |
+ current_vp_x = vp$x - vp$width*vp$valid.just[1] |
|
603 |
+ current_vp_y = vp$y - vp$height*vp$valid.just[2] |
|
548 | 604 |
|
549 | 605 |
upViewport(1) |
550 | 606 |
offset_x = convertX(current_vp_x, "mm") |
... | ... |
@@ -555,18 +611,22 @@ convertXY_in_vp = function(u, vp_name = "ROOT") { |
555 | 611 |
vp = current.viewport() |
556 | 612 |
current_vp_name = vp$name |
557 | 613 |
} |
558 |
- seekViewport(original_vp_name) |
|
559 | 614 |
|
560 | 615 |
return(u) |
561 | 616 |
} |
562 | 617 |
|
563 | 618 |
# == title |
564 |
-# Get values in a matrix by pair-wise indices |
|
619 |
+# Get Values in a Matrix by Pair-wise Indices |
|
565 | 620 |
# |
566 | 621 |
# == param |
567 |
-# -m a matrix or a 3d array |
|
568 |
-# -i row indices |
|
569 |
-# -j column indicies |
|
622 |
+# -m A matrix or a 3-dimension array. |
|
623 |
+# -i Row indices or the indices in the first dimension. |
|
624 |
+# -j Column indicies or the indices in the second dimension. |
|
625 |
+# |
|
626 |
+# == value |
|
627 |
+# If ``m`` is a matrix, the value returned is a vector ``c(m[i1, j1], m[i2, j2], ...)```. |
|
628 |
+# |
|
629 |
+# If ``m`` is an array, the value returned is a matrix ``rbind(m[i1, j1, ], m[i2, j2, ], ...)```. |
|
570 | 630 |
# |
571 | 631 |
# == example |
572 | 632 |
# m = matrix(rnorm(100), 10) |
... | ... |
@@ -584,6 +644,13 @@ convertXY_in_vp = function(u, vp_name = "ROOT") { |
584 | 644 |
# identical(pindex(arr, 1:2, 2:3), |
585 | 645 |
# rbind(arr[1, 2, ], arr[2, 3, ])) |
586 | 646 |
pindex = function(m, i, j) { |
647 |
+ |
|
648 |
+ if(length(i) == 1) i = rep(i, length(j)) |
|
649 |
+ if(length(j) == 1) j = rep(j, length(i)) |
|
650 |
+ if(length(i) != length(j)) { |
|
651 |
+ stop_wrap("Length of index i and j should be the same.") |
|
652 |
+ } |
|
653 |
+ |
|
587 | 654 |
nr = nrow(m) |
588 | 655 |
nc = ncol(m) |
589 | 656 |
ind = (j-1)*nr + i |
... | ... |
@@ -614,7 +681,7 @@ unit_with_vp = function(..., vp = current.viewport()$name) { |
614 | 681 |
# == param |
615 | 682 |
# -value A vector of numeric values. |
616 | 683 |
# -pos Position of the boxplot. |
617 |
-# -outline Whether draw outlines. |
|
684 |
+# -outline Whether draw outlines? |
|
618 | 685 |
# -box_width width of the box. |
619 | 686 |
# -pch Point type. |
620 | 687 |
# -size Point size. |
... | ... |
@@ -624,6 +691,13 @@ unit_with_vp = function(..., vp = current.viewport()$name) { |
624 | 691 |
# == details |
625 | 692 |
# All the values are measured with ``native`` coordinate. |
626 | 693 |
# |
694 |
+# == example |
|
695 |
+# lt = list(rnorm(100), rnorm(100)) |
|
696 |
+# grid.newpage() |
|
697 |
+# pushViewport(viewport(xscale = c(0.5, 2.5), yscale = range(lt))) |
|
698 |
+# grid.boxplot(lt[[1]], pos = 1, gp = gpar(fill = "red")) |
|
699 |
+# grid.boxplot(lt[[2]], pos = 2, gp = gpar(fill = "green")) |
|
700 |
+# popViewport() |
|
627 | 701 |
grid.boxplot = function(value, pos, outline = TRUE, box_width = 0.6, |
628 | 702 |
pch = 1, size = unit(2, "mm"), gp = gpar(fill = "#CCCCCC"), |
629 | 703 |
direction = c("vertical", "horizontal")) { |
... | ... |
@@ -5,7 +5,7 @@ |
5 | 5 |
", pkgname, " version ", version, " |
6 | 6 |
Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/ |
7 | 7 |
Github page: https://github.com/jokergoo/ComplexHeatmap |
8 |
-Documentation: http://jokergoo.github.io/ComplexHeatmap_book |
|
8 |
+Documentation: http://jokergoo.github.io/ComplexHeatmap-reference |
|
9 | 9 |
|
10 | 10 |
If you use it in published research, please cite: |
11 | 11 |
Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional |
... | ... |
@@ -57,7 +57,8 @@ densityHeatmap(data, |
57 | 57 |
\item{column_names_max_height}{Pass to \code{\link{Heatmap}}.} |
58 | 58 |
\item{column_names_gp}{Pass to \code{\link{Heatmap}}.} |
59 | 59 |
\item{column_names_rot}{Pass to \code{\link{Heatmap}}.} |
60 |
- \item{cluster_columns}{Whether cluster columns (here clustered by density values)? Normally we don't cluster columns. - clustering_distance_columns} |
|
60 |
+ \item{cluster_columns}{Whether cluster columns (here clustered by density values)? Normally we don't cluster columns.} |
|
61 |
+ \item{clustering_distance_columns}{-clustering_distance_columns} |
|
61 | 62 |
\item{clustering_method_columns}{-clustering_method_columns} |
62 | 63 |
\item{...}{pass to \code{\link{Heatmap}}.} |
63 | 64 |
|
24 | 24 |
deleted file mode 100644 |
... | ... |
@@ -1,22 +0,0 @@ |
1 |
-\name{height} |
|
2 |
-\alias{height} |
|
3 |
-\title{ |
|
4 |
-Generic Method for height() |
|
5 |
-} |
|
6 |
-\description{ |
|
7 |
-Generic Method for height() |
|
8 |
-} |
|
9 |
-\usage{ |
|
10 |
-height(x, ...) |
|
11 |
-} |
|
12 |
-\arguments{ |
|
13 |
- |
|
14 |
- \item{x}{An object.} |
|
15 |
- \item{...}{Other arguments.} |
|
16 |
- |
|
17 |
-} |
|
18 |
-\examples{ |
|
19 |
-# There is no example |
|
20 |
-NULL |
|
21 |
- |
|
22 |
-} |
23 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,24 +0,0 @@ |
1 |
-\name{height<-} |
|
2 |
-\alias{height<-} |
|
3 |
-\alias{heightAssign} |
|
4 |
-\title{ |
|
5 |
-Generic Assignment Method for height() |
|
6 |
-} |
|
7 |
-\description{ |
|
8 |
-Generic Assignment Method for height() |
|
9 |
-} |
|
10 |
-\usage{ |
|
11 |
-height(x, ...) <- value |
|
12 |
-} |
|
13 |
-\arguments{ |
|
14 |
- |
|
15 |
- \item{x}{An object.} |
|
16 |
- \item{value}{The value} |
|
17 |
- \item{...}{Other arguments.} |
|
18 |
- |
|
19 |
-} |
|
20 |
-\examples{ |
|
21 |
-# There is no example |
|
22 |
-NULL |
|
23 |
- |
|
24 |
-} |
... | ... |
@@ -44,6 +44,7 @@ oncoPrint(mat, |
44 | 44 |
\item{col}{a vector of color for which names correspond to alteration types.} |
45 | 45 |
\item{top_annotation}{Annotation put on top of the oncoPrint. By default it is barplot which shows the number of genes having the alteration in each sample.} |
46 | 46 |
\item{right_annotation}{Annotation put on the right of hte oncoPrint. By default it is barplto which shows the number of samples having the alteration in each gene.} |
47 |
+ \item{bottom_annotation}{-bottom_annotation} |
|
47 | 48 |
\item{show_pct}{whether show percent values on the left of the oncoprint} |
48 | 49 |
\item{pct_gp}{graphic paramters for percent row annotation} |
49 | 50 |
\item{pct_digits}{digits for percent values} |
50 | 51 |
similarity index 92% |
51 | 52 |
rename from man/resize-HeatmapAnnotation-method.rd |
52 | 53 |
rename to man/re_size-HeatmapAnnotation-method.rd |
... | ... |
@@ -1,6 +1,6 @@ |
1 |
-\name{resize-HeatmapAnnotation-method} |
|
2 |
-\alias{resize,HeatmapAnnotation-method} |
|
3 |
-\alias{resize} |
|
1 |
+\name{re_size-HeatmapAnnotation-method} |
|
2 |
+\alias{re_size,HeatmapAnnotation-method} |
|
3 |
+\alias{re_size} |
|
4 | 4 |
\title{ |
5 | 5 |
Resize the Width or Height of Heatmap Annotations |
6 | 6 |
} |
... | ... |
@@ -8,7 +8,7 @@ Resize the Width or Height of Heatmap Annotations |
8 | 8 |
Resize the Width or Height of Heatmap Annotations |
9 | 9 |
} |
10 | 10 |
\usage{ |
11 |
-\S4method{resize}{HeatmapAnnotation}(object, |
|
11 |
+\S4method{re_size}{HeatmapAnnotation}(object, |
|
12 | 12 |
annotation_height = NULL, |
13 | 13 |
annotation_width = NULL, |
14 | 14 |
height = NULL, |
... | ... |
@@ -20,7 +20,7 @@ It returns the width if it is a row annotation and the height if it is a column |
20 | 20 |
} |
21 | 21 |
\examples{ |
22 | 22 |
anno = anno_points(1:10) |
23 |
-size(anno) |
|
23 |
+ComplexHeatmap:::size(anno) |
|
24 | 24 |
anno = anno_points(1:10, which = "row") |
25 |
-size(anno) |
|
25 |
+ComplexHeatmap:::size(anno) |
|
26 | 26 |
} |
27 | 27 |
deleted file mode 100644 |
... | ... |
@@ -1,22 +0,0 @@ |
1 |
-\name{size} |
|
2 |
-\alias{size} |
|
3 |
-\title{ |
|
4 |
-Generic Method for size() |
|
5 |
-} |
|
6 |
-\description{ |
|
7 |
-Generic Method for size() |
|
8 |
-} |
|
9 |
-\usage{ |
|
10 |
-size(x, ...) |
|
11 |
-} |
|
12 |
-\arguments{ |
|
13 |
- |
|
14 |
- \item{x}{An object.} |
|
15 |
- \item{...}{Other arguments.} |
|
16 |
- |
|
17 |
-} |
|
18 |
-\examples{ |
|
19 |
-# There is no example |
|
20 |
-NULL |
|
21 |
- |
|
22 |
-} |
28 | 28 |
deleted file mode 100644 |
... | ... |
@@ -1,24 +0,0 @@ |
1 |
-\name{size<-} |
|
2 |
-\alias{size<-} |
|
3 |
-\alias{sizeAssign} |
|
4 |
-\title{ |
|
5 |
-Generic Assignment Method for size() |
|
6 |
-} |
|
7 |
-\description{ |
|
8 |
-Generic Assignment Method for size() |
|
9 |
-} |
|
10 |
-\usage{ |
|
11 |
-size(x, ...) <- value |
|
12 |
-} |
|
13 |
-\arguments{ |
|
14 |
- |
|
15 |
- \item{x}{An object.} |
|
16 |
- \item{value}{The value} |
|
17 |
- \item{...}{Other arguments.} |
|
18 |
- |
|
19 |
-} |
|
20 |
-\examples{ |
|
21 |
-# There is no example |
|
22 |
-NULL |
|
23 |
- |
|
24 |
-} |
24 | 24 |
deleted file mode 100644 |
... | ... |
@@ -1,22 +0,0 @@ |
1 |
-\name{width} |
|
2 |
-\alias{width} |
|
3 |
-\title{ |
|
4 |
-Generic Method for width() |
|
5 |
-} |
|
6 |
-\description{ |
|
7 |
-Generic Method for width() |
|
8 |
-} |
|
9 |
-\usage{ |
|
10 |
-width(x, ...) |
|
11 |
-} |
|
12 |
-\arguments{ |
|
13 |
- |
|
14 |
- \item{x}{An object.} |
|
15 |
- \item{...}{Other arguments.} |
|
16 |
- |
|
17 |
-} |
|
18 |
-\examples{ |
|
19 |
-# There is no example |
|
20 |
-NULL |
|
21 |
- |
|
22 |
-} |
23 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,24 +0,0 @@ |
1 |
-\name{width<-} |
|
2 |
-\alias{width<-} |
|
3 |
-\alias{widthAssign} |
|
4 |
-\title{ |
|
5 |
-Generic Assignment Method for width() |
|
6 |
-} |
|
7 |
-\description{ |
|
8 |
-Generic Assignment Method for width() |
|
9 |
-} |
|
10 |
-\usage{ |
|
11 |
-width(x, ...) <- value |
|
12 |
-} |
|
13 |
-\arguments{ |
|
14 |
- |
|
15 |
- \item{x}{An object.} |
|
16 |
- \item{value}{The value} |
|
17 |
- \item{...}{Other arguments.} |
|
18 |
- |
|
19 |
-} |
|
20 |
-\examples{ |
|
21 |
-# There is no example |
|
22 |
-NULL |
|
23 |
- |
|
24 |
-} |
... | ... |
@@ -358,3 +358,12 @@ draw(anno, index = 1:10, k = 2, n = 2, test = "anno_block") |
358 | 358 |
anno = anno_block(gp = gpar(fill = 1:4), labels = letters[1:4], labels_gp = gpar(col = "white"), which = "row") |
359 | 359 |
draw(anno, index = 1:10, k = 2, n = 4, test = "anno_block") |
360 | 360 |
|
361 |
+ |
|
362 |
+ |
|
363 |
+ |
|
364 |
+ |
|
365 |
+ |
|
366 |
+ |
|
367 |
+ |
|
368 |
+ |
|
369 |
+ |
... | ... |
@@ -25,26 +25,26 @@ ha = HeatmapAnnotation(foo = 1:10, |
25 | 25 |
gap = unit(2, "mm")) |
26 | 26 |
draw(ha, test = "complex annotations") |
27 | 27 |
|
28 |
-ha2 = resize(ha, annotation_height = unit(1:3, "cm")) |
|
28 |
+ha2 = re_size(ha, annotation_height = unit(1:3, "cm")) |
|
29 | 29 |
draw(ha2, test = "complex annotations") |
30 |
-ha2 = resize(ha, annotation_height = 1, height = unit(6, "cm")) |
|
30 |
+ha2 = re_size(ha, annotation_height = 1, height = unit(6, "cm")) |
|
31 | 31 |
draw(ha2, test = "complex annotations") |
32 |
-ha2 = resize(ha, annotation_height = 1:3, height = unit(6, "cm")) |
|
32 |
+ha2 = re_size(ha, annotation_height = 1:3, height = unit(6, "cm")) |
|
33 | 33 |
draw(ha2, test = "complex annotations") |
34 |
-ha2 = resize(ha, annotation_height = unit(c(1, 2, 3), c("null", "null", "cm")), height = unit(6, "cm")) |
|
34 |
+ha2 = re_size(ha, annotation_height = unit(c(1, 2, 3), c("null", "null", "cm")), height = unit(6, "cm")) |
|
35 | 35 |
draw(ha2, test = "complex annotations") |
36 |
-ha2 = resize(ha, annotation_height = unit(c(2, 2, 3), c("cm", "null", "cm")), height = unit(6, "cm")) |
|
36 |
+ha2 = re_size(ha, annotation_height = unit(c(2, 2, 3), c("cm", "null", "cm")), height = unit(6, "cm")) |
|
37 | 37 |
draw(ha2, test = "complex annotations") |
38 |
-ha2 = resize(ha, annotation_height = unit(c(2, 2, 3), c("cm", "cm", "cm"))) |
|
38 |
+ha2 = re_size(ha, annotation_height = unit(c(2, 2, 3), c("cm", "cm", "cm"))) |
|
39 | 39 |
draw(ha2, test = "complex annotations") |
40 |
-ha2 = resize(ha[, 1:2], annotation_height = 1, height = unit(4, "cm")) |
|
40 |
+ha2 = re_size(ha[, 1:2], annotation_height = 1, height = unit(4, "cm")) |
|
41 | 41 |
draw(ha2, test = "complex annotations") |
42 |
-ha2 = resize(ha[, 1:2], annotation_height = c(1, 4), height = unit(4, "cm")) |
|
42 |
+ha2 = re_size(ha[, 1:2], annotation_height = c(1, 4), height = unit(4, "cm")) |
|
43 | 43 |
draw(ha2, test = "complex annotations") |
44 |
-ha2 = resize(ha[, 1:2], height = unit(6, "cm")) |
|
44 |
+ha2 = re_size(ha[, 1:2], height = unit(6, "cm")) |
|
45 | 45 |
draw(ha2, test = "complex annotations") |
46 | 46 |
|
47 |
-ha2 = resize(ha, height = unit(6, "cm")) |
|
47 |
+ha2 = re_size(ha, height = unit(6, "cm")) |
|
48 | 48 |
draw(ha2, test = "complex annotations") |
49 | 49 |
|
50 | 50 |
#### test anno_empty and self-defined anotation function |
... | ... |
@@ -1,83 +1,77 @@ |
1 | 1 |
|
2 |
-gb = annotation_axis_grob(at = 1:5, label = month.name[1:5], label_rot = 0, side = "left", facing = "outside") |
|
2 |
+gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, side = "left", facing = "outside") |
|
3 | 3 |
grid.newpage() |
4 | 4 |
pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
5 | 5 |
grid.draw(gb) |
6 | 6 |
grid.rect(x = unit(0, "npc"), width = grobWidth(gb), just = "right") |
7 | 7 |
popViewport() |
8 | 8 |
|
9 |
-gb = annotation_axis_grob(at = 1:5, label = month.name[1:5], label_rot = 0, side = "left", facing = "inside") |
|
9 |
+gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, side = "left", facing = "inside") |
|
10 | 10 |
grid.newpage() |
11 | 11 |
pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
12 | 12 |
grid.draw(gb) |
13 | 13 |
grid.rect(x = unit(0, "npc"), width = grobWidth(gb), just = "left") |
14 | 14 |
popViewport() |
15 | 15 |
|
16 |
- |
|
17 |
-gb = annotation_axis_grob(at = 1:5, label = month.name[1:5], label_rot = 0, side = "right", facing = "outside") |
|
16 |
+gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, side = "right", facing = "outside") |
|
18 | 17 |
grid.newpage() |
19 | 18 |
pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
20 | 19 |
grid.draw(gb) |
21 | 20 |
grid.rect(x = unit(1, "npc"), width = grobWidth(gb), just = "left") |
22 | 21 |
popViewport() |
23 | 22 |
|
24 |
- |
|
25 |
-gb = annotation_axis_grob(at = 1:5, label = month.name[1:5], label_rot = 0, side = "right", facing = "inside") |
|
23 |
+gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, side = "right", facing = "inside") |
|
26 | 24 |
grid.newpage() |
27 | 25 |
pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
28 | 26 |
grid.draw(gb) |
29 | 27 |
grid.rect(x = unit(1, "npc"), width = grobWidth(gb), just = "right") |
30 | 28 |
popViewport() |
31 | 29 |
|
32 |
- |
|
33 |
-gb = annotation_axis_grob(at = 1:5, label = month.name[1:5], label_rot = 0, side = "top", facing = "outside") |
|
30 |
+gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, side = "top", facing = "outside") |
|
34 | 31 |
grid.newpage() |
35 | 32 |
pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
36 | 33 |
grid.draw(gb) |
37 | 34 |
grid.rect(y = unit(1, "npc"), height = grobHeight(gb), just = "bottom") |
38 | 35 |
popViewport() |
39 | 36 |
|
40 |
-gb = annotation_axis_grob(at = 1:5, label = month.name[1:5], label_rot = 90, side = "top", facing = "outside") |
|
37 |
+gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 90, side = "top", facing = "outside") |
|
41 | 38 |
grid.newpage() |
42 | 39 |
pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
43 | 40 |
grid.draw(gb) |
44 | 41 |
grid.rect(y = unit(1, "npc"), height = grobHeight(gb), just = "bottom") |
45 | 42 |
popViewport() |
46 | 43 |
|
47 |
-gb = annotation_axis_grob(at = 1:5, label = month.name[1:5], label_rot = 45, side = "top", facing = "outside") |
|
44 |
+gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 45, side = "top", facing = "outside") |
|
48 | 45 |
grid.newpage() |
49 | 46 |
pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
50 | 47 |
grid.draw(gb) |
51 | 48 |
grid.rect(y = unit(1, "npc"), height = grobHeight(gb), just = "bottom") |
52 | 49 |
popViewport() |
53 | 50 |
|
54 |
-gb = annotation_axis_grob(at = 1:5, label = month.name[1:5], label_rot = 0, side = "top", facing = "inside") |
|
51 |
+gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, side = "top", facing = "inside") |
|
55 | 52 |
grid.newpage() |
56 | 53 |
pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
57 | 54 |
grid.draw(gb) |
58 | 55 |
grid.rect(y = unit(1, "npc"), height = grobHeight(gb), just = "top") |
59 | 56 |
popViewport() |
60 | 57 |
|
61 |
- |
|
62 |
-gb = annotation_axis_grob(at = 1:5, label = month.name[1:5], label_rot = 0, side = "bottom", facing = "outside") |
|
58 |
+gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, side = "bottom", facing = "outside") |
|
63 | 59 |
grid.newpage() |
64 | 60 |
pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
65 | 61 |
grid.draw(gb) |
66 | 62 |
grid.rect(y = unit(0, "npc"), height = grobHeight(gb), just = "top") |
67 | 63 |
popViewport() |
68 | 64 |
|
69 |
-gb = annotation_axis_grob(at = 1:5, label = month.name[1:5], label_rot = 0, side = "bottom", facing = "inside") |
|
65 |
+gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, side = "bottom", facing = "inside") |
|
70 | 66 |
grid.newpage() |
71 | 67 |
pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
72 | 68 |
grid.draw(gb) |
73 | 69 |
grid.rect(y = unit(0, "npc"), height = grobHeight(gb), just = "bottom") |
74 | 70 |
popViewport() |
75 | 71 |
|
76 |
- |
|
77 |
- |
|
78 | 72 |
grid.newpage() |
79 | 73 |
pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
80 |
-gb = annotation_axis_grob(label_rot = 0, side = "left", facing = "outside") |
|
74 |
+gb = annotation_axis_grob(labels_rot = 0, side = "left", facing = "outside") |
|
81 | 75 |
grid.draw(gb) |
82 | 76 |
grid.rect(x = unit(0, "npc"), width = grobWidth(gb), just = "right") |
83 | 77 |
popViewport() |