... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
Package: ComplexHeatmap |
2 | 2 |
Type: Package |
3 |
-Title: Making Complex Heatmaps |
|
3 |
+Title: Make Complex Heatmaps |
|
4 | 4 |
Version: 1.99.0 |
5 | 5 |
Date: 2018-6-9 |
6 | 6 |
Author: Zuguang Gu |
... | ... |
@@ -15,7 +15,7 @@ VignetteBuilder: knitr |
15 | 15 |
Description: Complex heatmaps are efficient to visualize associations |
16 | 16 |
between different sources of data sets and reveal potential structures. |
17 | 17 |
Here the ComplexHeatmap package provides a highly flexible way to arrange |
18 |
- multiple heatmaps and supports self-defined annotation graphics. |
|
18 |
+ multiple heatmaps and supports various annotation graphics. |
|
19 | 19 |
biocViews: Software, Visualization, Sequencing |
20 | 20 |
URL: https://github.com/jokergoo/ComplexHeatmap |
21 | 21 |
License: MIT + file LICENSE |
... | ... |
@@ -6,6 +6,8 @@ S3method("[", "Heatmap") |
6 | 6 |
export("[.Heatmap") |
7 | 7 |
S3method("[", "HeatmapAnnotation") |
8 | 8 |
export("[.HeatmapAnnotation") |
9 |
+S3method("[", "HeatmapList") |
|
10 |
+export("[.HeatmapList") |
|
9 | 11 |
S3method("[", "SingleAnnotation") |
10 | 12 |
export("[.SingleAnnotation") |
11 | 13 |
S3method("c", "HeatmapAnnotation") |
... | ... |
@@ -38,10 +40,14 @@ S3method("heightDetails", "packed_legends") |
38 | 40 |
export("heightDetails.packed_legends") |
39 | 41 |
S3method("length", "HeatmapAnnotation") |
40 | 42 |
export("length.HeatmapAnnotation") |
43 |
+S3method("length", "HeatmapList") |
|
44 |
+export("length.HeatmapList") |
|
41 | 45 |
S3method("merge", "dendrogram") |
42 | 46 |
export("merge.dendrogram") |
43 | 47 |
S3method("names", "HeatmapAnnotation") |
44 | 48 |
export("names.HeatmapAnnotation") |
49 |
+S3method("names", "HeatmapList") |
|
50 |
+export("names.HeatmapList") |
|
45 | 51 |
S3method("names<-", "HeatmapAnnotation") |
46 | 52 |
export("names<-.HeatmapAnnotation") |
47 | 53 |
S3method("ncol", "Heatmap") |
... | ... |
@@ -115,7 +121,9 @@ export("anno_mark") |
115 | 121 |
export("anno_oncoprint_barplot") |
116 | 122 |
export("anno_points") |
117 | 123 |
export("anno_simple") |
124 |
+export("anno_summary") |
|
118 | 125 |
export("anno_text") |
126 |
+export("annotation_axis_grob") |
|
119 | 127 |
export("cluster_within_group") |
120 | 128 |
export("columnAnnotation") |
121 | 129 |
export("convertXY_in_vp") |
... | ... |
@@ -136,12 +144,14 @@ export("dend_xy") |
136 | 144 |
export("dendrogramGrob") |
137 | 145 |
export("densityHeatmap") |
138 | 146 |
export("dist2") |
147 |
+export("grid.boxplot") |
|
139 | 148 |
export("grid.dendrogram") |
140 | 149 |
export("height") |
141 | 150 |
export("height<-") |
142 | 151 |
export("ht_global_opt") |
143 | 152 |
export("ht_opt") |
144 | 153 |
export("is_abs_unit") |
154 |
+export("list_component") |
|
145 | 155 |
export("max_text_height") |
146 | 156 |
export("max_text_width") |
147 | 157 |
export("oncoPrint") |
... | ... |
@@ -1,31 +1,31 @@ |
1 |
+setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list')) |
|
2 |
+setGeneric('adjust_heatmap_list', function(object, ...) standardGeneric('adjust_heatmap_list')) |
|
3 |
+setGeneric('component_width', function(object, ...) standardGeneric('component_width')) |
|
4 |
+setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend')) |
|
1 | 5 |
setGeneric('map_to_colors', function(object, ...) standardGeneric('map_to_colors')) |
2 |
-setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height')) |
|
3 |
-setGeneric('draw_heatmap_body', function(object, ...) standardGeneric('draw_heatmap_body')) |
|
4 |
-setGeneric('component_height', function(object, ...) standardGeneric('component_height')) |
|
6 |
+setGeneric('draw', function(object, ...) standardGeneric('draw')) |
|
7 |
+setGeneric('column_dend', function(object, ...) standardGeneric('column_dend')) |
|
8 |
+setGeneric('draw_dend', function(object, ...) standardGeneric('draw_dend')) |
|
5 | 9 |
setGeneric('make_layout', function(object, ...) standardGeneric('make_layout')) |
6 |
-setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size')) |
|
7 |
-setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list')) |
|
8 |
-setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend')) |
|
9 | 10 |
setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster')) |
10 |
-setGeneric('column_dend', function(object, ...) standardGeneric('column_dend')) |
|
11 |
-setGeneric('resize', function(object, ...) standardGeneric('resize')) |
|
12 |
-setGeneric('row_order', function(object, ...) standardGeneric('row_order')) |
|
13 | 11 |
setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list')) |
14 |
-setGeneric('row_dend', function(object, ...) standardGeneric('row_dend')) |
|
15 |
-setGeneric('add_heatmap', function(object, ...) standardGeneric('add_heatmap')) |
|
16 |
-setGeneric('set_component_width', function(object, ...) standardGeneric('set_component_width')) |
|
17 |
-setGeneric('column_order', function(object, ...) standardGeneric('column_order')) |
|
18 |
-setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend')) |
|
19 |
-setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend')) |
|
20 |
-setGeneric('annotation_legend_size', function(object, ...) standardGeneric('annotation_legend_size')) |
|
21 | 12 |
setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation')) |
13 |
+setGeneric('copy_all', function(object, ...) standardGeneric('copy_all')) |
|
14 |
+setGeneric('row_order', function(object, ...) standardGeneric('row_order')) |
|
22 | 15 |
setGeneric('prepare', function(object, ...) standardGeneric('prepare')) |
23 | 16 |
setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames')) |
24 |
-setGeneric('draw', function(object, ...) standardGeneric('draw')) |
|
17 |
+setGeneric('component_height', function(object, ...) standardGeneric('component_height')) |
|
25 | 18 |
setGeneric('draw_title', function(object, ...) standardGeneric('draw_title')) |
26 |
-setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster')) |
|
27 |
-setGeneric('component_width', function(object, ...) standardGeneric('component_width')) |
|
19 |
+setGeneric('resize', function(object, ...) standardGeneric('resize')) |
|
20 |
+setGeneric('column_order', function(object, ...) standardGeneric('column_order')) |
|
28 | 21 |
setGeneric('get_color_mapping_list', function(object, ...) standardGeneric('get_color_mapping_list')) |
29 |
-setGeneric('draw_dend', function(object, ...) standardGeneric('draw_dend')) |
|
30 |
-setGeneric('adjust_heatmap_list', function(object, ...) standardGeneric('adjust_heatmap_list')) |
|
31 |
-setGeneric('copy_all', function(object, ...) standardGeneric('copy_all')) |
|
22 |
+setGeneric('row_dend', function(object, ...) standardGeneric('row_dend')) |
|
23 |
+setGeneric('annotation_legend_size', function(object, ...) standardGeneric('annotation_legend_size')) |
|
24 |
+setGeneric('add_heatmap', function(object, ...) standardGeneric('add_heatmap')) |
|
25 |
+setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend')) |
|
26 |
+setGeneric('draw_heatmap_body', function(object, ...) standardGeneric('draw_heatmap_body')) |
|
27 |
+setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height')) |
|
28 |
+setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend')) |
|
29 |
+setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size')) |
|
30 |
+setGeneric('set_component_width', function(object, ...) standardGeneric('set_component_width')) |
|
31 |
+setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster')) |
... | ... |
@@ -1,79 +1,79 @@ |
1 | 1 |
|
2 | 2 |
# == title |
3 |
-# Generic method for width |
|
3 |
+# Generic Method for width() |
|
4 | 4 |
# |
5 | 5 |
# == param |
6 |
-# -x x |
|
7 |
-# -... other arguments |
|
6 |
+# -x An object. |
|
7 |
+# -... Other arguments. |
|
8 | 8 |
# |
9 | 9 |
width = function (x, ...) { |
10 | 10 |
UseMethod("width", x) |
11 | 11 |
} |
12 | 12 |
|
13 | 13 |
# == title |
14 |
-# Generic method for height |
|
14 |
+# Generic Method for height() |
|
15 | 15 |
# |
16 | 16 |
# == param |
17 |
-# -x x |
|
18 |
-# -... other arguments |
|
17 |
+# -x An object. |
|
18 |
+# -... Other arguments. |
|
19 | 19 |
# |
20 | 20 |
height = function (x, ...) { |
21 | 21 |
UseMethod("height", x) |
22 | 22 |
} |
23 | 23 |
|
24 | 24 |
# == title |
25 |
-# Generic method for size |
|
25 |
+# Generic Method for size() |
|
26 | 26 |
# |
27 | 27 |
# == param |
28 |
-# -x x |
|
29 |
-# -... other arguments |
|
28 |
+# -x An object. |
|
29 |
+# -... Other arguments. |
|
30 | 30 |
# |
31 | 31 |
size = function (x, ...) { |
32 | 32 |
UseMethod("size", x) |
33 | 33 |
} |
34 | 34 |
|
35 | 35 |
# == title |
36 |
-# Generic assignment method for width |
|
36 |
+# Generic Assignment Method for width() |
|
37 | 37 |
# |
38 | 38 |
# == param |
39 |
-# -x x |
|
40 |
-# -value value |
|
41 |
-# -... other arguments |
|
39 |
+# -x An object. |
|
40 |
+# -value The value |
|
41 |
+# -... Other arguments. |
|
42 | 42 |
# |
43 | 43 |
"width<-" = function (x, ..., value) { |
44 | 44 |
UseMethod("width<-", x) |
45 | 45 |
} |
46 | 46 |
|
47 | 47 |
# == title |
48 |
-# Generic assignment method for height |
|
48 |
+# Generic Assignment Method for height() |
|
49 | 49 |
# |
50 | 50 |
# == param |
51 |
-# -x x |
|
52 |
-# -value value |
|
53 |
-# -... other arguments |
|
51 |
+# -x An object. |
|
52 |
+# -value The value |
|
53 |
+# -... Other arguments. |
|
54 | 54 |
# |
55 | 55 |
"height<-" = function (x, ..., value) { |
56 | 56 |
UseMethod("height<-", x) |
57 | 57 |
} |
58 | 58 |
|
59 | 59 |
# == title |
60 |
-# Generic assignment method for size |
|
60 |
+# Generic Assignment Method for size() |
|
61 | 61 |
# |
62 | 62 |
# == param |
63 |
-# -x x |
|
64 |
-# -value value |
|
65 |
-# -... other arguments |
|
63 |
+# -x An object. |
|
64 |
+# -value The value |
|
65 |
+# -... Other arguments. |
|
66 | 66 |
# |
67 | 67 |
"size<-" = function (x, ..., value) { |
68 | 68 |
UseMethod("size<-", x) |
69 | 69 |
} |
70 | 70 |
|
71 | 71 |
# == title |
72 |
-# Width of the AnnotationFunction x |
|
72 |
+# Width of the AnnotationFunction Object |
|
73 | 73 |
# |
74 | 74 |
# == param |
75 |
-# -x The `AnnotationFunction-class` x. |
|
76 |
-# -... other arguments |
|
75 |
+# -x A `AnnotationFunction-class` object. |
|
76 |
+# -... Other arguments |
|
77 | 77 |
# |
78 | 78 |
# == example |
79 | 79 |
# anno = anno_points(1:10) |
... | ... |
@@ -85,12 +85,12 @@ width.AnnotationFunction = function(x, ...) { |
85 | 85 |
} |
86 | 86 |
|
87 | 87 |
# == title |
88 |
-# Assign the Width to the AnnotationFunction x |
|
88 |
+# Assign the Width to the AnnotationFunction Object |
|
89 | 89 |
# |
90 | 90 |
# == param |
91 |
-# -x The `AnnotationFunction-class` x. |
|
92 |
-# -value A `grid::unit` x. |
|
93 |
-# -... other arguments |
|
91 |
+# -x The `AnnotationFunction-class` object. |
|
92 |
+# -... Other arguments. |
|
93 |
+# -value A `grid::unit` object. |
|
94 | 94 |
# |
95 | 95 |
"width<-.AnnotationFunction" = function(x, ..., value) { |
96 | 96 |
x@width = value |
... | ... |
@@ -98,11 +98,11 @@ width.AnnotationFunction = function(x, ...) { |
98 | 98 |
} |
99 | 99 |
|
100 | 100 |
# == title |
101 |
-# Height of the AnnotationFunction x |
|
101 |
+# Height of the AnnotationFunction Object |
|
102 | 102 |
# |
103 | 103 |
# == param |
104 |
-# -x The `AnnotationFunction-class` x. |
|
105 |
-# -... other arguments |
|
104 |
+# -x The `AnnotationFunction-class` object. |
|
105 |
+# -... Other arguments |
|
106 | 106 |
# |
107 | 107 |
# == example |
108 | 108 |
# anno = anno_points(1:10) |
... | ... |
@@ -114,12 +114,12 @@ height.AnnotationFunction = function(x, ...) { |
114 | 114 |
} |
115 | 115 |
|
116 | 116 |
# == title |
117 |
-# Assign the Height to the AnnotationFunction x |
|
117 |
+# Assign the Height to the AnnotationFunction Object |
|
118 | 118 |
# |
119 | 119 |
# == param |
120 |
-# -x The `AnnotationFunction-class` x. |
|
121 |
-# -value A `grid::unit` x. |
|
122 |
-# -... other arguments |
|
120 |
+# -x The `AnnotationFunction-class` object. |
|
121 |
+# -value A `grid::unit` object. |
|
122 |
+# -... Other arguments. |
|
123 | 123 |
# |
124 | 124 |
"height<-.AnnotationFunction" = function(x, ..., value) { |
125 | 125 |
x@height = value |
... | ... |
@@ -127,11 +127,11 @@ height.AnnotationFunction = function(x, ...) { |
127 | 127 |
} |
128 | 128 |
|
129 | 129 |
# == title |
130 |
-# Size of the AnnotationFunction x |
|
130 |
+# Size of the AnnotationFunction Object |
|
131 | 131 |
# |
132 | 132 |
# == param |
133 |
-# -x The `AnnotationFunction-class` x. |
|
134 |
-# -... other arguments |
|
133 |
+# -x The `AnnotationFunction-class` object. |
|
134 |
+# -... Other arguments. |
|
135 | 135 |
# |
136 | 136 |
# == detail |
137 | 137 |
# It returns the width if it is a row annotation and the height if it is a column annotation. |
... | ... |
@@ -150,15 +150,15 @@ size.AnnotationFunction = function(x, ...) { |
150 | 150 |
} |
151 | 151 |
|
152 | 152 |
# == title |
153 |
-# Assign the Size to the AnnotationFunction x |
|
153 |
+# Assign the Size to the AnnotationFunction Object |
|
154 | 154 |
# |
155 | 155 |
# == param |
156 |
-# -x The `AnnotationFunction-class` x. |
|
157 |
-# -value A `grid::unit` x. |
|
158 |
-# -... other arguments |
|
156 |
+# -x The `AnnotationFunction-class` object. |
|
157 |
+# -value A `grid::unit` object. |
|
158 |
+# -... Other arguments. |
|
159 | 159 |
# |
160 | 160 |
# == detail |
161 |
-# It assigns the width if it is a row annotation and the height if it is a column annotation. |
|
161 |
+# It assigns to the width if it is a row annotation and the height if it is a column annotation. |
|
162 | 162 |
# |
163 | 163 |
# == example |
164 | 164 |
# anno = anno_points(1:10) |
... | ... |
@@ -176,23 +176,23 @@ size.AnnotationFunction = function(x, ...) { |
176 | 176 |
|
177 | 177 |
|
178 | 178 |
# == title |
179 |
-# Width of the SingleAnnotation x |
|
179 |
+# Width of the SingleAnnotation Object |
|
180 | 180 |
# |
181 | 181 |
# == param |
182 |
-# -x The `SingleAnnotation-class` x. |
|
183 |
-# -... other arguments |
|
182 |
+# -x The `SingleAnnotation-class` object. |
|
183 |
+# -... Other arguments. |
|
184 | 184 |
# |
185 | 185 |
width.SingleAnnotation = function(x, ...) { |
186 | 186 |
x@width |
187 | 187 |
} |
188 | 188 |
|
189 | 189 |
# == title |
190 |
-# Assign the Width to the SingleAnnotation x |
|
190 |
+# Assign the Width to the SingleAnnotation Object |
|
191 | 191 |
# |
192 | 192 |
# == param |
193 |
-# -x The `SingleAnnotation-class` x. |
|
194 |
-# -value A `grid::unit` x. |
|
195 |
-# -... other arguments |
|
193 |
+# -x The `SingleAnnotation-class` object. |
|
194 |
+# -value A `grid::unit` object. |
|
195 |
+# -... Other arguments. |
|
196 | 196 |
# |
197 | 197 |
"width<-.SingleAnnotation" = function(x, ..., value) { |
198 | 198 |
x@width = value |
... | ... |
@@ -203,23 +203,23 @@ width.SingleAnnotation = function(x, ...) { |
203 | 203 |
} |
204 | 204 |
|
205 | 205 |
# == title |
206 |
-# Height of the SingleAnnotation x |
|
206 |
+# Height of the SingleAnnotation object |
|
207 | 207 |
# |
208 | 208 |
# == param |
209 |
-# -x The `SingleAnnotation-class` x. |
|
210 |
-# -... other arguments |
|
209 |
+# -x The `SingleAnnotation-class` object. |
|
210 |
+# -... Other arguments. |
|
211 | 211 |
# |
212 | 212 |
height.SingleAnnotation = function(x, ...) { |
213 | 213 |
x@height |
214 | 214 |
} |
215 | 215 |
|
216 | 216 |
# == title |
217 |
-# Assign the Height to the SingleAnnotation x |
|
217 |
+# Assign the Height to the SingleAnnotation Object |
|
218 | 218 |
# |
219 | 219 |
# == param |
220 |
-# -x The `SingleAnnotation-class` x. |
|
221 |
-# -value A `grid::unit` x. |
|
222 |
-# -... other arguments |
|
220 |
+# -x The `SingleAnnotation-class` object. |
|
221 |
+# -value A `grid::unit` object. |
|
222 |
+# -... Other arguments. |
|
223 | 223 |
# |
224 | 224 |
"height<-.SingleAnnotation" = function(x, ..., value) { |
225 | 225 |
x@height = value |
... | ... |
@@ -230,11 +230,11 @@ height.SingleAnnotation = function(x, ...) { |
230 | 230 |
} |
231 | 231 |
|
232 | 232 |
# == title |
233 |
-# Size of the SingleAnnotation x |
|
233 |
+# Size of the SingleAnnotation Object |
|
234 | 234 |
# |
235 | 235 |
# == param |
236 |
-# -x The `SingleAnnotation-class` x. |
|
237 |
-# -... other arguments |
|
236 |
+# -x The `SingleAnnotation-class` object. |
|
237 |
+# -... Other arguments. |
|
238 | 238 |
# |
239 | 239 |
# == detail |
240 | 240 |
# It returns the width if it is a row annotation and the height if it is a column annotation. |
... | ... |
@@ -248,15 +248,15 @@ size.SingleAnnotation = function(x, ...) { |
248 | 248 |
} |
249 | 249 |
|
250 | 250 |
# == title |
251 |
-# Assign the Size of the SingleAnnotation x |
|
251 |
+# Assign the Size to the SingleAnnotation Object |
|
252 | 252 |
# |
253 | 253 |
# == param |
254 |
-# -x The `SingleAnnotation-class` x. |
|
255 |
-# -value A `grid::unit` x. |
|
256 |
-# -... other arguments |
|
254 |
+# -x The `SingleAnnotation-class` object. |
|
255 |
+# -value A `grid::unit` object. |
|
256 |
+# -... Other arguments. |
|
257 | 257 |
# |
258 | 258 |
# == detail |
259 |
-# It assigns the width if it is a row annotation and the height if it is a column annotation. |
|
259 |
+# It assigns to the width if it is a row annotation and the height if it is a column annotation. |
|
260 | 260 |
# |
261 | 261 |
"size<-.SingleAnnotation" = function(x, ..., value) { |
262 | 262 |
if(x@which == "row") { |
... | ... |
@@ -270,23 +270,23 @@ size.SingleAnnotation = function(x, ...) { |
270 | 270 |
|
271 | 271 |
|
272 | 272 |
# == title |
273 |
-# Width of the HeatmapAnnotation x |
|
273 |
+# Width of the HeatmapAnnotation Object |
|
274 | 274 |
# |
275 | 275 |
# == param |
276 |
-# -x The `HeatmapAnnotation-class` x. |
|
277 |
-# -... other arguments |
|
276 |
+# -x The `HeatmapAnnotation-class` object. |
|
277 |
+# -... Other arguments. |
|
278 | 278 |
# |
279 | 279 |
width.HeatmapAnnotation = function(x, ...) { |
280 | 280 |
x@width |
281 | 281 |
} |
282 | 282 |
|
283 | 283 |
# == title |
284 |
-# Assign the Width to the HeatmapAnnotation x |
|
284 |
+# Assign the Width to the HeatmapAnnotation Object |
|
285 | 285 |
# |
286 | 286 |
# == param |
287 |
-# -x The `HeatmapAnnotation-class` x. |
|
288 |
-# -value A `grid::unit` x. |
|
289 |
-# -... other arguments |
|
287 |
+# -x The `HeatmapAnnotation-class` object. |
|
288 |
+# -value A `grid::unit` object. |
|
289 |
+# -... Other arguments. |
|
290 | 290 |
# |
291 | 291 |
"width<-.HeatmapAnnotation" = function(x, ..., value) { |
292 | 292 |
|
... | ... |
@@ -303,23 +303,23 @@ width.HeatmapAnnotation = function(x, ...) { |
303 | 303 |
|
304 | 304 |
|
305 | 305 |
# == title |
306 |
-# Height of the HeatmapAnnotation x |
|
306 |
+# Height of the HeatmapAnnotation Object |
|
307 | 307 |
# |
308 | 308 |
# == param |
309 |
-# -x The `HeatmapAnnotation-class` x. |
|
310 |
-# -... other arguments |
|
309 |
+# -x The `HeatmapAnnotation-class` object. |
|
310 |
+# -... Other arguments. |
|
311 | 311 |
# |
312 | 312 |
height.HeatmapAnnotation = function(x, ...) { |
313 | 313 |
x@height |
314 | 314 |
} |
315 | 315 |
|
316 | 316 |
# == title |
317 |
-# Assign the Height to the HeatmapAnnotation x |
|
317 |
+# Assign the Height to the HeatmapAnnotation Object |
|
318 | 318 |
# |
319 | 319 |
# == param |
320 |
-# -x The `HeatmapAnnotation-class` x. |
|
321 |
-# -value A `grid::unit` x. |
|
322 |
-# -... other arguments |
|
320 |
+# -x The `HeatmapAnnotation-class` object. |
|
321 |
+# -value A `grid::unit` object. |
|
322 |
+# -... Other arguments. |
|
323 | 323 |
# |
324 | 324 |
"height<-.HeatmapAnnotation" = function(x, ..., value) { |
325 | 325 |
|
... | ... |
@@ -335,11 +335,11 @@ height.HeatmapAnnotation = function(x, ...) { |
335 | 335 |
} |
336 | 336 |
|
337 | 337 |
# == title |
338 |
-# Size of the HeatmapAnnotation x |
|
338 |
+# Size of the HeatmapAnnotation Object |
|
339 | 339 |
# |
340 | 340 |
# == param |
341 |
-# -x The `HeatmapAnnotation-class` x. |
|
342 |
-# -... other arguments |
|
341 |
+# -x The `HeatmapAnnotation-class` object. |
|
342 |
+# -... Other arguments. |
|
343 | 343 |
# |
344 | 344 |
# == detail |
345 | 345 |
# It returns the width if it is a row annotation and the height if it is a column annotation. |
... | ... |
@@ -353,12 +353,12 @@ size.HeatmapAnnotation = function(x, ...) { |
353 | 353 |
} |
354 | 354 |
|
355 | 355 |
# == title |
356 |
-# Assign the Size to the HeatmapAnnotation x |
|
356 |
+# Assign the Size to the HeatmapAnnotation Object |
|
357 | 357 |
# |
358 | 358 |
# == param |
359 |
-# -x The `HeatmapAnnotation-class` x. |
|
360 |
-# -value A `grid::unit` x. |
|
361 |
-# -... other arguments |
|
359 |
+# -x The `HeatmapAnnotation-class` object. |
|
360 |
+# -value A `grid::unit` object. |
|
361 |
+# -... Other arguments. |
|
362 | 362 |
# |
363 | 363 |
# == detail |
364 | 364 |
# It assigns the width if it is a row annotation and the height if it is a column annotation. |
... | ... |
@@ -377,11 +377,11 @@ size.HeatmapAnnotation = function(x, ...) { |
377 | 377 |
# Width of the Legends |
378 | 378 |
# |
379 | 379 |
# == param |
380 |
-# -x The `grid::grob` x returned by `Legend` or `packLegend`. |
|
381 |
-# -... other arguments |
|
380 |
+# -x The `grid::grob` object returned by `Legend` or `packLegend`. |
|
381 |
+# -... Other arguments. |
|
382 | 382 |
# |
383 | 383 |
# == value |
384 |
-# The returned unit x is in ``mm``. |
|
384 |
+# The returned unit x is always in ``mm``. |
|
385 | 385 |
# |
386 | 386 |
width.Legends = function(x, ...) { |
387 | 387 |
s = attr(x@grob, "width") |
... | ... |
@@ -393,11 +393,11 @@ width.Legends = function(x, ...) { |
393 | 393 |
# Height of the Legends |
394 | 394 |
# |
395 | 395 |
# == param |
396 |
-# -x The `grid::grob` x returned by `Legend` or `packLegend`. |
|
397 |
-# -... other arguments |
|
396 |
+# -x The `grid::grob` object returned by `Legend` or `packLegend`. |
|
397 |
+# -... Other arguments. |
|
398 | 398 |
# |
399 | 399 |
# == value |
400 |
-# The returned unit x is in ``mm``. |
|
400 |
+# The returned unit x is always in ``mm``. |
|
401 | 401 |
# |
402 | 402 |
height.Legends = function(x, ...) { |
403 | 403 |
s = attr(x@grob, "height") |
... | ... |
@@ -1,10 +1,11 @@ |
1 | 1 |
|
2 | 2 |
# == title |
3 |
-# An internal class |
|
3 |
+# Class for Concatenating Heatmaps and Annotations |
|
4 | 4 |
# |
5 |
-# == detail |
|
6 |
-# This class is a super class for `Heatmap-class`, `HeatmapList-class` and `HeatmapAnnotation-class` classes. |
|
7 |
-# It is only designed for ``+`` generic method so that above three classes can be appended to each other. |
|
5 |
+# == detail |
|
6 |
+# This class is a super class for `Heatmap-class`, `HeatmapList-class` and |
|
7 |
+# `HeatmapAnnotation-class` classes. It is only designed for ``+`` generic |
|
8 |
+# method so that above three classes can be appended to each other. |
|
8 | 9 |
# |
9 | 10 |
AdditiveUnit = setClass("AdditiveUnit") |
10 | 11 |
|
... | ... |
@@ -12,7 +13,7 @@ AdditiveUnit = setClass("AdditiveUnit") |
12 | 13 |
# Constructor Method for AdditiveUnit Class |
13 | 14 |
# |
14 | 15 |
# == param |
15 |
-# -... black hole arguments. |
|
16 |
+# -... Black hole arguments. |
|
16 | 17 |
# |
17 | 18 |
# == details |
18 | 19 |
# This method is not used in the package. |
... | ... |
@@ -36,10 +37,16 @@ AdditiveUnit = function(...) { |
36 | 37 |
# -y A `Heatmap-class` object, a `HeatmapAnnotation-class` object or a `HeatmapList-class` object. |
37 | 38 |
# |
38 | 39 |
# == detail |
39 |
-# It is only a helper function. It actually calls `add_heatmap,Heatmap-method`, `add_heatmap,HeatmapList-method` |
|
40 |
-# or `add_heatmap,HeatmapAnnotation-method` depending on the class of the input objects. |
|
40 |
+# It is only a helper function. It actually calls |
|
41 |
+# `add_heatmap,Heatmap-method`, `add_heatmap,HeatmapList-method` or |
|
42 |
+# `add_heatmap,HeatmapAnnotation-method` depending on the class of the input |
|
43 |
+# objects. |
|
44 |
+# |
|
45 |
+# The `HeatmapAnnotation-class` object to be added should only be row |
|
46 |
+# annotations. Column annotations should be added to the heatmap list by |
|
47 |
+# `\%v\%`. |
|
41 | 48 |
# |
42 |
-# The `HeatmapAnnotation-class` object to be added should only be row annotations. |
|
49 |
+# ``x`` and ``y`` can also be ``NULL``. |
|
43 | 50 |
# |
44 | 51 |
# == value |
45 | 52 |
# A `HeatmapList-class` object. |
... | ... |
@@ -83,16 +90,21 @@ AdditiveUnit = function(...) { |
83 | 90 |
# -y A `Heatmap-class` object, a `HeatmapAnnotation-class` object or a `HeatmapList-class` object. |
84 | 91 |
# |
85 | 92 |
# == detail |
86 |
-# It is only a helper function. It actually calls `add_heatmap,Heatmap-method`, `add_heatmap,HeatmapList-method` |
|
87 |
-# or `add_heatmap,HeatmapAnnotation-method` depending on the class of the input objects. |
|
93 |
+# It is only a helper function. It actually calls |
|
94 |
+# `add_heatmap,Heatmap-method`, `add_heatmap,HeatmapList-method` or |
|
95 |
+# `add_heatmap,HeatmapAnnotation-method` depending on the class of the input |
|
96 |
+# objects. |
|
97 |
+# |
|
98 |
+# The `HeatmapAnnotation-class` object to be added should only be column |
|
99 |
+# annotations. |
|
88 | 100 |
# |
89 |
-# The `HeatmapAnnotation-class` object to be added should only be column annotations. |
|
101 |
+# ``x`` and ``y`` can also be ``NULL``. |
|
90 | 102 |
# |
91 | 103 |
# == value |
92 | 104 |
# A `HeatmapList-class` object. |
93 | 105 |
# |
94 | 106 |
# == seealso |
95 |
-# `+.AdditiveUnit` operator is used for vertical heatmap list. |
|
107 |
+# `+.AdditiveUnit` operator is used for horizontal heatmap list. |
|
96 | 108 |
# |
97 | 109 |
# == author |
98 | 110 |
# Zuguang Gu <z.gu@dkfz.de> |
... | ... |
@@ -3,12 +3,14 @@ |
3 | 3 |
# The AnnotationFunction class |
4 | 4 |
# |
5 | 5 |
# == details |
6 |
-# The heatmap annotation is basically graphics aligned to the columns or heatmap if it is column annotation |
|
7 |
-# or heatmap rows if it is row annotation, while the type of the graphics can be arbitory, e.g. |
|
8 |
-# it can be heatmap-like or points. Here the AnnotationFunction class is designed for creating |
|
9 |
-# complex and flexible annotation graphics. As the main part, it uses a use-defined function |
|
10 |
-# to define the graphics. It also keeps information of the size of the plotting regions of the annotation. |
|
11 |
-# And most importantly, it allows subsetting of the annotation to draw a subset of the graphics, which |
|
6 |
+# The heatmap annotation is basically graphics aligned to the heatmap columns |
|
7 |
+# if it is column annotation or heatmap rows if it is row annotation, while |
|
8 |
+# there is no restrictions for the graphic types, e.g. it can be heatmap-like |
|
9 |
+# annotation or points. Here the AnnotationFunction class is designed for |
|
10 |
+# creating complex and flexible annotation graphics. As the main part of the class, it uses |
|
11 |
+# a user-defined function to define the graphics. It also keeps information of |
|
12 |
+# the size of the plotting regions of the annotation. And most importantly, it |
|
13 |
+# allows subsetting of the annotation to draw a subset of the graphics, which |
|
12 | 14 |
# is the base for the splitting of the annotations. |
13 | 15 |
# |
14 | 16 |
# See `AnnotationFunction` constructor for details. |
... | ... |
@@ -81,7 +83,7 @@ anno_width_and_height = function(which, width = NULL, height = NULL, |
81 | 83 |
# Constructor of AnnotationFunction Class |
82 | 84 |
# |
83 | 85 |
# == param |
84 |
-# -fun A function which defines how to draw this annotation. See **Details** section. |
|
86 |
+# -fun A function which defines how to draw the annotation. See **Details** section. |
|
85 | 87 |
# -fun_name The name of the function. It is only used for printing the object. |
86 | 88 |
# -which Whether it is drawn as a column annotation or a row annotation? |
87 | 89 |
# -var_import The names of the variables or the variable themselves that the annotation function depends on. See **Details** section. |
... | ... |
@@ -92,36 +94,54 @@ anno_width_and_height = function(which, width = NULL, height = NULL, |
92 | 94 |
# -subset_rule The rule of subsetting variables in ``var_import``. It should be set when users want the final object to |
93 | 95 |
# be subsetable. See **Details** section. |
94 | 96 |
# -subsetable Whether the object is subsetable? |
97 |
+# -show_name It is used to turn off the drawing of annotation names in `HeatmapAnnotation`. Annotations always have names |
|
98 |
+# associated and normally they will be drawn beside the annotation graphics to tell what the annotation is about. |
|
99 |
+# e.g. the annotation names put beside the points annotation graphics. However, for some of the annotations, the names |
|
100 |
+# are not necessarily to be drawn, such as text annotations drawn by `anno_text` or an empty annotation drawn by `anno_empty()`. |
|
101 |
+# In this case, when `show_names` is set to `FALSE`, there will be no annotation names drawn for the annotation. |
|
95 | 102 |
# -width The width of the plotting region (the viewport) that the annotation is drawn. If it is a row annotation, |
96 |
-# the width must be an absolute unit. |
|
103 |
+# the width must be an absolute unit. Since the ``AnnotationFunction`` object is always contained by the `SingleAnnotation-class`object, |
|
104 |
+# you can only set the width of row annotations or height of column annotations, while e.g. the height of the row annotation is always ``unit(1, "npc")`` |
|
105 |
+# which means it always fully filled in the parent ``SingleAnnotation`` and only in `SingleAnnotation` or even `HeatmapAnnotation` |
|
106 |
+# can adjust the height of the row annotations. |
|
97 | 107 |
# -height The height of the plotting region (the viewport) that the annotation is drawn. If it is a column annotation, |
98 | 108 |
# the width must be an absolute unit. |
99 | 109 |
# |
100 | 110 |
# == details |
101 |
-# A normal R function defines how to draw the annotation graphics. As expected, the main part of the AnnotationFunction |
|
102 |
-# class is this function. The function defines how to draw at specific positions which correspond to rows or columns |
|
103 |
-# in the heatmap. The function should have three arguments: ``index``, ``k`` and ``n`` (the names of the arguments can |
|
104 |
-# be arbitory) where ``k`` and ``n`` are optional. ``index`` corresponds to the indices of rows or columns of the heatmap. |
|
105 |
-# The value of ``index`` is not necessarily to be the whole row indices or column indices. It can also be a subset of |
|
106 |
-# the indices if the annotation is split into slices according to the split of the heatmap. The value in ``index`` is |
|
107 |
-# always sorted according to the reordering of heatmap rows or columns (e.g. by clustering). So, ``index`` actually contains |
|
108 |
-# a list of row or column indices for the current slice after row or column reordering. This type of design makes sure |
|
109 |
-# the annotation graphics are drawn at the correct positions and can be correctly corresponded to the heatmap rows or columns. |
|
111 |
+# We use a normal R function defines how to draw the annotation graphics. As |
|
112 |
+# expected, the main part of the AnnotationFunction class is this function. |
|
113 |
+# The function defines how to draw at specific positions which correspond to |
|
114 |
+# rows or columns in the heatmap. The function should have three arguments: |
|
115 |
+# ``index``, ``k`` and ``n`` (the names of the arguments can be arbitory) |
|
116 |
+# where ``k`` and ``n`` are optional. ``index`` corresponds to the indices of |
|
117 |
+# rows or columns of the heatmap. The value of ``index`` is not necessarily to |
|
118 |
+# be the whole row indices or column indices of the heatmap. It can be a |
|
119 |
+# subset of the indices if the annotation is split into slices according to |
|
120 |
+# the split of the heatmap. ``index`` is always reordered according to the |
|
121 |
+# reordering of heatmap rows or columns (e.g. by clustering). So, ``index`` |
|
122 |
+# actually contains a list of row or column indices for the current slice |
|
123 |
+# after row or column reordering. |
|
110 | 124 |
# |
111 |
-# As mentioned, annotation can be split into slices. ``k`` corresponds to the current slice and ``n`` corresponds to |
|
112 |
-# the total number of slices. The information of ``k`` and ``n`` sometimes can be useful, for example, we want to add axis |
|
113 |
-# in the annotation, and if it is a column annotation and axis is drawn on the very right of the annotation area, the axis |
|
114 |
-# is only drawn when ``k == n``. |
|
125 |
+# As mentioned, annotation can be split into slices. ``k`` corresponds to the |
|
126 |
+# current slice and ``n`` corresponds to the total number of slices. As you can image, |
|
127 |
+# when ``n > 1``, the annotation function will be executed for all ``k``s. The |
|
128 |
+# information of ``k`` and ``n`` sometimes can be useful, for example, we want |
|
129 |
+# to add axis ot the right side of a column annotation, if this column annotation |
|
130 |
+# is split into several slices, the axis is only drawn when``k == n``. |
|
115 | 131 |
# |
116 |
-# Since the function only allows ``index``, ``k`` and ``n``, the function sometimes uses several external variables which can |
|
117 |
-# not be defined inside the function, e.g. the data points for the annotation. These variables should be imported |
|
118 |
-# into the AnnotationFunction class so that the function can correctly find these variables. |
|
132 |
+# Since the function only allows ``index``, ``k`` and ``n``, the function |
|
133 |
+# sometimes uses several external variables which can not be defined inside |
|
134 |
+# the function, e.g. the data points for the annotation. These variables |
|
135 |
+# should be imported into the AnnotationFunction class so that the function |
|
136 |
+# can correctly find these variables (by ``var_import`` argument). |
|
119 | 137 |
# |
120 |
-# One important feature for AnnotationFunction class is it can be subsetable. To allow subsetting of the object, |
|
121 |
-# users need to define the rule for the imported variables if there is any. The rules are simple function which |
|
122 |
-# accpets the variable and indices, and returns the subset of the variable. The subset rule functions implemented |
|
123 |
-# in this package are `subset_gp`, `subset_matrix_by_row` and `subset_vector`. These three functions are enough for |
|
124 |
-# most of the cases. |
|
138 |
+# One important feature for AnnotationFunction class is it can be subsetable. |
|
139 |
+# To allow subsetting of the object, users need to define the rules for the |
|
140 |
+# imported variables. The rules are simple function which |
|
141 |
+# accpets the variable and indices, and returns the subset of the variable. |
|
142 |
+# The subset rule functions implemented in this package are `subset_gp`, |
|
143 |
+# `subset_matrix_by_row` and `subset_vector`. These three functions are enough |
|
144 |
+# for most of the cases. |
|
125 | 145 |
# |
126 | 146 |
# In following, we defined three AnnotationFunction objects: |
127 | 147 |
# |
... | ... |
@@ -155,7 +175,7 @@ anno_width_and_height = function(which, width = NULL, height = NULL, |
155 | 175 |
# subsetable = TRUE |
156 | 176 |
# ) |
157 | 177 |
# |
158 |
-# 3. The most compact way to only specify the function to the constructor. |
|
178 |
+# 3. Only specify the function to the constructor. ``anno3`` is not subsettable. |
|
159 | 179 |
# |
160 | 180 |
# anno3 = AnnotationFunction( |
161 | 181 |
# fun = function(index) { |
... | ... |
@@ -167,15 +187,20 @@ anno_width_and_height = function(which, width = NULL, height = NULL, |
167 | 187 |
# } |
168 | 188 |
# ) |
169 | 189 |
# |
170 |
-# Finally, you need to push a viewport for graphics and finally pop the viewport. |
|
190 |
+# As you can see from the examples, you need to push a viewport for graphics and finally pop the viewport. |
|
171 | 191 |
# |
172 |
-# In the package, quite a lot annotation function are constructed by `AnnotationFunction` constructor: |
|
192 |
+# In the package, we have implemted quite a lot annotation function by `AnnotationFunction` constructor: |
|
173 | 193 |
# `anno_empty`, `anno_image`, `anno_points`, `anno_lines`, `anno_barplot`, `anno_boxplot`, `anno_histogram`, |
174 |
-# `anno_density`, `anno_joyplot`, `anno_horizon`, `anno_text` and `anno_mark`. Thess built-in annotation functions |
|
175 |
-# are all subsettable. |
|
194 |
+# `anno_density`, `anno_joyplot`, `anno_horizon`, `anno_text` and `anno_mark`. These built-in annotation functions |
|
195 |
+# support as both row annotations and column annotations and they are are all subsettable. |
|
196 |
+# |
|
197 |
+# == seealso |
|
198 |
+# The build-in annotation functions are already enough for most of the analysis, nevertheless, if users |
|
199 |
+# want to know more about how to construct the AnnotationFunction class manually, they can refer to |
|
200 |
+# ComplexHeatmap Complete Reference (). |
|
176 | 201 |
AnnotationFunction = function(fun, fun_name = "", which = c("column", "row"), |
177 | 202 |
var_import = list(), n = NA, data_scale = c(0, 1), subset_rule = list(), |
178 |
- subsetable = FALSE, show_name = TRUE, width = NULL, height = NULL) { |
|
203 |
+ subsetable = length(subset_rule) > 0, show_name = TRUE, width = NULL, height = NULL) { |
|
179 | 204 |
|
180 | 205 |
which = match.arg(which)[1] |
181 | 206 |
|
... | ... |
@@ -263,7 +288,7 @@ AnnotationFunction = function(fun, fun_name = "", which = c("column", "row"), |
263 | 288 |
# -i A vector of indices. |
264 | 289 |
# |
265 | 290 |
# == details |
266 |
-# One good thing for designing the `AnnotationFunction-class` object is it can be subsetted, |
|
291 |
+# One good thing for designing the `AnnotationFunction-class` is it can be subsetted, |
|
267 | 292 |
# and this is the base for the splitting of the annotations. |
268 | 293 |
# |
269 | 294 |
# == example |
... | ... |
@@ -368,17 +393,20 @@ setMethod(f = "draw", |
368 | 393 |
}) |
369 | 394 |
|
370 | 395 |
# == title |
371 |
-# Copy the AnnotationFunction object |
|
396 |
+# Copy the AnnotationFunction Object |
|
372 | 397 |
# |
373 | 398 |
# == param |
374 | 399 |
# -object The `AnnotationFunction-class` object. |
375 | 400 |
# |
376 |
-# == detail |
|
377 |
-# In `AnnotationFunction-class`, there is an environment which stores some external variables |
|
378 |
-# for the annotation function. This `copy_all,AnnotationFunction-method` hard copy all the variables |
|
379 |
-# in that environment to a new environment. |
|
401 |
+# == detail |
|
402 |
+# In `AnnotationFunction-class`, there is an environment which |
|
403 |
+# stores some external variables for the annotation function (specified by the |
|
404 |
+# ``var_import`` argument by constructing the `AnnotationFunction-class` |
|
405 |
+# object. This `copy_all,AnnotationFunction-method` hard copies all the |
|
406 |
+# variables into a new isolated environment. |
|
380 | 407 |
# |
381 | 408 |
# The environment is at ``object@var_env``. |
409 |
+# |
|
382 | 410 |
setMethod(f = "copy_all", |
383 | 411 |
signature = "AnnotationFunction", |
384 | 412 |
definition = function(object) { |
... | ... |
@@ -392,7 +420,7 @@ setMethod(f = "copy_all", |
392 | 420 |
}) |
393 | 421 |
|
394 | 422 |
# == title |
395 |
-# Print the AnnotationFunction object |
|
423 |
+# Print the AnnotationFunction Object |
|
396 | 424 |
# |
397 | 425 |
# == param |
398 | 426 |
# -object The `AnnotationFunction-class` object. |
... | ... |
@@ -434,10 +462,10 @@ setMethod(f = "show", |
434 | 462 |
# |
435 | 463 |
# == param |
436 | 464 |
# -object The `AnnotationFunction-class` object. |
437 |
-# -... other arguments |
|
465 |
+# -... Other arguments. |
|
438 | 466 |
# |
439 |
-# == details |
|
440 |
-# It returns the ``n`` slot in the object. If there does not exist, it returns ``NA``. |
|
467 |
+# == details It returns the ``n`` slot in the object. If it does not exist, it |
|
468 |
+# returns ``NA``. |
|
441 | 469 |
# |
442 | 470 |
# == example |
443 | 471 |
# anno = anno_points(1:10) |
... | ... |
@@ -4,9 +4,9 @@ |
4 | 4 |
# |
5 | 5 |
# == param |
6 | 6 |
# -which Whether it is a column annotation or a row annotation? |
7 |
-# -border Wether draw borders of the annotation region? |
|
8 |
-# -width Width of the annotation. |
|
9 |
-# -height Height of the annotation. |
|
7 |
+# -border Whether draw borders of the annotation region? |
|
8 |
+# -width Width of the annotation. The value should be an absolute unit. Width is not allowed to be set for column annotation. |
|
9 |
+# -height Height of the annotation. The value should be an absolute unit. Height is not allowed to be set for row annotation. |
|
10 | 10 |
# |
11 | 11 |
# == details |
12 | 12 |
# It creates an empty annotation and holds space, later users can add graphics |
... | ... |
@@ -91,7 +91,7 @@ subset_vector = function(x, i) x[i] |
91 | 91 |
# |
92 | 92 |
# == param |
93 | 93 |
# -x The value vector. The value can be a vector or a matrix. The length of the vector |
94 |
-# or the number of rows of the matrix is taken as the number of the observations of the annotation. |
|
94 |
+# or the nrow of the matrix is taken as the number of the observations of the annotation. |
|
95 | 95 |
# The value can be numeric or character and NA value is allowed. |
96 | 96 |
# -col Color that maps to ``x``. If ``x`` is numeric and needs a continuous mapping, ``col`` |
97 | 97 |
# should be a color mapping function which accepts a vector of values and returns a |
... | ... |
@@ -110,14 +110,14 @@ subset_vector = function(x, i) x[i] |
110 | 110 |
# the value of ``pt_size`` can be a vector, while if ``x`` is a matrix, ``pt_size`` can |
111 | 111 |
# only be a single value. |
112 | 112 |
# -pt_gp Graphic parameters for points/symbols. The length setting is same as ``pt_size``. |
113 |
-# -width Width of the annotation. |
|
114 |
-# -height Height of the annotation. |
|
113 |
+# -width Width of the annotation. The value should be an absolute unit. Width is not allowed to be set for column annotation. |
|
114 |
+# -height Height of the annotation. The value should be an absolute unit. Height is not allowed to be set for row annotation. |
|
115 | 115 |
# |
116 | 116 |
# == details |
117 | 117 |
# The "simple annotation" is the most widely used annotation type which is heatmap-like, where |
118 | 118 |
# the grid colors correspond to the values. `anno_simple` also supports to add points/symbols |
119 |
-# on top of the grids where the it can be normal point (when pch is set as numbers) or letters (when |
|
120 |
-# pch is set as single letters). |
|
119 |
+# on top of the grids where the it can be normal point (when ``pch`` is set as numbers) or letters (when |
|
120 |
+# ``pch`` is set as single letters). |
|
121 | 121 |
# |
122 | 122 |
# == value |
123 | 123 |
# An annotation function which can be used in `HeatmapAnnotation`. |
... | ... |
@@ -303,8 +303,8 @@ anno_simple = function(x, col, na_col = "grey", |
303 | 303 |
# -gp Graphic parameters for annotation grids. If the image has transparent background, the ``fill`` parameter |
304 | 304 |
# can be used to control the background color in the annotation grids. |
305 | 305 |
# -space The space around the image to the annotation grid borders. The value should be a `grid::unit` object. |
306 |
-# -width Width of the annotation. |
|
307 |
-# -height Height of the annotation. |
|
306 |
+# -width Width of the annotation. The value should be an absolute unit. Width is not allowed to be set for column annotation. |
|
307 |
+# -height Height of the annotation. The value should be an absolute unit. Height is not allowed to be set for row annotation. |
|
308 | 308 |
# |
309 | 309 |
# == details |
310 | 310 |
# This function supports image formats in ``png``, ``svg``, ``pdf``, ``eps``, ``jpeg/jpg``, ``tiff``. |
... | ... |
@@ -578,8 +578,8 @@ construct_axis_grob = function(axis_param, which, data_scale) { |
578 | 578 |
# -extend The extension to both side of ``ylim``. The value is a percent value corresponding to ``ylim[2] - ylim[1]``. |
579 | 579 |
# -axis Whether to add axis? |
580 | 580 |
# -axis_param parameters for controlling axis. See `default_axis_param` for all possible settings and default parameters. |
581 |
-# -width Width of the annotation. |
|
582 |
-# -height Height of the annotation. |
|
581 |
+# -width Width of the annotation. The value should be an absolute unit. Width is not allowed to be set for column annotation. |
|
582 |
+# -height Height of the annotation. The value should be an absolute unit. Height is not allowed to be set for row annotation. |
|
583 | 583 |
# |
584 | 584 |
# == value |
585 | 585 |
# An annotation function which can be used in `HeatmapAnnotation`. |
... | ... |
@@ -745,6 +745,7 @@ update_anno_extend = function(anno, axis_grob, axis_param) { |
745 | 745 |
# -border Wether draw borders of the annotation region? |
746 | 746 |
# -gp Graphic parameters for lines. The length of each graphic parameter can be 1, or number of columns of ``x`` is ``x`` is a matrix. |
747 | 747 |
# -add_points Whether to add points on the lines? |
748 |
+# -smooth If it is ``TRUE``, smoothing by `stats::loess` is performed. If it is ``TRUE``, ``add_points`` is set to ``TRUE`` by default. |
|
748 | 749 |
# -pch Point type. The length setting is the same as ``gp``. |
749 | 750 |
# -size Point size, the value should be a `grid::unit` object. The length setting is the same as ``gp``. |
750 | 751 |
# -pt_gp Graphic parameters for points. The length setting is the same as ``gp``. |
... | ... |
@@ -752,8 +753,8 @@ update_anno_extend = function(anno, axis_grob, axis_param) { |
752 | 753 |
# -extend The extension to both side of ``ylim``. The value is a percent value corresponding to ``ylim[2] - ylim[1]``. |
753 | 754 |
# -axis Whether to add axis? |
754 | 755 |
# -axis_param parameters for controlling axis. See `default_axis_param` for all possible settings and default parameters. |
755 |
-# -width Width of the annotation. |
|
756 |
-# -height Height of the annotation. |
|
756 |
+# -width Width of the annotation. The value should be an absolute unit. Width is not allowed to be set for column annotation. |
|
757 |
+# -height Height of the annotation. The value should be an absolute unit. Height is not allowed to be set for row annotation. |
|
757 | 758 |
# |
758 | 759 |
# == value |
759 | 760 |
# An annotation function which can be used in `HeatmapAnnotation`. |
... | ... |
@@ -767,7 +768,7 @@ update_anno_extend = function(anno, axis_grob, axis_param) { |
767 | 768 |
# add_points = TRUE, pt_gp = gpar(col = 5:6), pch = c(1, 16)) |
768 | 769 |
# draw(anno, test = "matrix") |
769 | 770 |
anno_lines = function(x, which = c("column", "row"), border = TRUE, gp = gpar(), |
770 |
- add_points = FALSE, smooth = FALSE, pch = 16, size = unit(2, "mm"), pt_gp = gpar(), ylim = NULL, |
|
771 |
+ add_points = smooth, smooth = FALSE, pch = 16, size = unit(2, "mm"), pt_gp = gpar(), ylim = NULL, |
|
771 | 772 |
extend = 0.05, axis = TRUE, axis_param = default_axis_param(which), |
772 | 773 |
width = NULL, height = NULL) { |
773 | 774 |
|
... | ... |
@@ -969,8 +970,8 @@ anno_lines = function(x, which = c("column", "row"), border = TRUE, gp = gpar(), |
969 | 970 |
# -extend The extension to both side of ``ylim``. The value is a percent value corresponding to ``ylim[2] - ylim[1]``. |
970 | 971 |
# -axis Whether to add axis? |
971 | 972 |
# -axis_param parameters for controlling axis. See `default_axis_param` for all possible settings and default parameters. |
972 |
-# -width Width of the annotation. |
|
973 |
-# -height Height of the annotation. |
|
973 |
+# -width Width of the annotation. The value should be an absolute unit. Width is not allowed to be set for column annotation. |
|
974 |
+# -height Height of the annotation. The value should be an absolute unit. Height is not allowed to be set for row annotation. |
|
974 | 975 |
# |
975 | 976 |
# == value |
976 | 977 |
# An annotation function which can be used in `HeatmapAnnotation`. |
... | ... |
@@ -1139,8 +1140,8 @@ anno_barplot = function(x, baseline = 0, which = c("column", "row"), border = TR |
1139 | 1140 |
# -size Point size. |
1140 | 1141 |
# -axis Whether to add axis? |
1141 | 1142 |
# -axis_param parameters for controlling axis. See `default_axis_param` for all possible settings and default parameters. |
1142 |
-# -width Width of the annotation. |
|
1143 |
-# -height Height of the annotation. |
|
1143 |
+# -width Width of the annotation. The value should be an absolute unit. Width is not allowed to be set for column annotation. |
|
1144 |
+# -height Height of the annotation. The value should be an absolute unit. Height is not allowed to be set for row annotation. |
|
1144 | 1145 |
# |
1145 | 1146 |
# == value |
1146 | 1147 |
# An annotation function which can be used in `HeatmapAnnotation`. |
... | ... |
@@ -1331,8 +1332,8 @@ anno_boxplot = function(x, which = c("column", "row"), border = TRUE, |
1331 | 1332 |
# -gp Graphic parameters for the boxes. The length of the graphic parameters should be one or the number of observations. |
1332 | 1333 |
# -axis Whether to add axis? |
1333 | 1334 |
# -axis_param parameters for controlling axis. See `default_axis_param` for all possible settings and default parameters. |
1334 |
-# -width Width of the annotation. |
|
1335 |
-# -height Height of the annotation. |
|
1335 |
+# -width Width of the annotation. The value should be an absolute unit. Width is not allowed to be set for column annotation. |
|
1336 |
+# -height Height of the annotation. The value should be an absolute unit. Height is not allowed to be set for row annotation. |
|
1336 | 1337 |
# |
1337 | 1338 |
# == value |
1338 | 1339 |
# An annotation function which can be used in `HeatmapAnnotation`. |
... | ... |
@@ -1489,8 +1490,8 @@ anno_histogram = function(x, which = c("column", "row"), n_breaks = 11, |
1489 | 1490 |
# -gp Graphic parameters for the boxes. The length of the graphic parameters should be one or the number of observations. |
1490 | 1491 |
# -axis Whether to add axis? |
1491 | 1492 |
# -axis_param parameters for controlling axis. See `default_axis_param` for all possible settings and default parameters. |
1492 |
-# -width Width of the annotation. |
|
1493 |
-# -height Height of the annotation. |
|
1493 |
+# -width Width of the annotation. The value should be an absolute unit. Width is not allowed to be set for column annotation. |
|
1494 |
+# -height Height of the annotation. The value should be an absolute unit. Height is not allowed to be set for row annotation. |
|
1494 | 1495 |
# |
1495 | 1496 |
# == value |
1496 | 1497 |
# An annotation function which can be used in `HeatmapAnnotation`. |
... | ... |
@@ -1744,8 +1745,8 @@ anno_density = function(x, which = c("column", "row"), |
1744 | 1745 |
# of ``location`` should be a `grid::unit` object, normally in ``npc`` unit. E.g. ``unit(0, 'npc')`` |
1745 | 1746 |
# means the most left of the annotation region and ``unit(1, 'npc')`` means the most right of |
1746 | 1747 |
# the annotation region. |
1747 |
-# -width Width of the annotation. |
|
1748 |
-# -height Height of the annotation. |
|
1748 |
+# -width Width of the annotation. The value should be an absolute unit. Width is not allowed to be set for column annotation. |
|
1749 |
+# -height Height of the annotation. The value should be an absolute unit. Height is not allowed to be set for row annotation. |
|
1749 | 1750 |
# |
1750 | 1751 |
# == value |
1751 | 1752 |
# An annotation function which can be used in `HeatmapAnnotation`. |
... | ... |
@@ -1888,8 +1889,8 @@ anno_text = function(x, which = c("column", "row"), gp = gpar(), |
1888 | 1889 |
# -transparency Transparency of the filled colors. Value should be between 0 and 1. |
1889 | 1890 |
# -axis Whether to add axis? |
1890 | 1891 |
# -axis_param parameters for controlling axis. See `default_axis_param` for all possible settings and default parameters. |
1891 |
-# -width Width of the annotation. |
|
1892 |
-# -height Height of the annotation. |
|
1892 |
+# -width Width of the annotation. The value should be an absolute unit. Width is not allowed to be set for column annotation. |
|
1893 |
+# -height Height of the annotation. The value should be an absolute unit. Height is not allowed to be set for row annotation. |
|
1893 | 1894 |
# |
1894 | 1895 |
# == value |
1895 | 1896 |
# An annotation function which can be used in `HeatmapAnnotation`. |
... | ... |
@@ -2075,8 +2076,8 @@ anno_joyplot = function(x, which = c("column", "row"), gp = gpar(fill = "#000000 |
2075 | 2076 |
# -gap Gap size of neighbouring horizon chart. |
2076 | 2077 |
# -axis Whether to add axis? |
2077 | 2078 |
# -axis_param parameters for controlling axis. See `default_axis_param` for all possible settings and default parameters. |
2078 |
-# -width Width of the annotation. |
|
2079 |
-# -height Height of the annotation. |
|
2079 |
+# -width Width of the annotation. The value should be an absolute unit. Width is not allowed to be set for column annotation. |
|
2080 |
+# -height Height of the annotation. The value should be an absolute unit. Height is not allowed to be set for row annotation. |
|
2080 | 2081 |
# |
2081 | 2082 |
# == detail |
2082 | 2083 |
# Horizon chart as row annotation is only supported. |
... | ... |
@@ -2653,13 +2654,49 @@ row_anno_link = function(...) { |
2653 | 2654 |
anno_link(..., which = "row") |
2654 | 2655 |
} |
2655 | 2656 |
|
2656 |
-# only allow for one-column/one-row heamtap |
|
2657 |
-# discrete: barplot; continuous: boxplot (maybe also barplot, e.g. pct overlap) |
|
2657 |
+# == title |
|
2658 |
+# Summary Annotation |
|
2659 |
+# |
|
2660 |
+# == param |
|
2661 |
+# -which Whether it is a column annotation or a row annotation? |
|
2662 |
+# -border Wether draw borders of the annotation region? |
|
2663 |
+# -bar_width Relative width of the bars. The value should be smaller than one. |
|
2664 |
+# -axis Whether to add axis? |
|
2665 |
+# -axis_param parameters for controlling axis. See `default_axis_param` for all possible settings and default parameters. |
|
2666 |
+# -ylim Data ranges. ``ylim`` for barplot is enforced to be ``c(0, 1)``. |
|
2667 |
+# -extend The extension to both side of ``ylim``. The value is a percent value corresponding to ``ylim[2] - ylim[1]``. This argument is only for boxplot. |
|
2668 |
+# -outline Whether draw outline of boxplots? |
|
2669 |
+# -box_width Relative width of boxes. The value should be smaller than one. |
|
2670 |
+# -pch Point style. |
|
2671 |
+# -size Point size. |
|
2672 |
+# -gp Graphic parameters. |
|
2673 |
+# -width Width of the annotation. The value should be an absolute unit. Width is not allowed to be set for column annotation. |
|
2674 |
+# -height Height of the annotation. The value should be an absolute unit. Height is not allowed to be set for row annotation. |
|
2675 |
+# |
|
2676 |
+# == detail |
|
2677 |
+# ``anno_summary`` is a special annotation function that it only works for one-column or one-row heatmap. |
|
2678 |
+# It shows the summary of the values in the heatmap. If the values in the heatmap is discrete, |
|
2679 |
+# the proportion of each level (the sum is normalized to 1) is visualized as stacked barplot. If the heatmap |
|
2680 |
+# is split into multiple slices, multiple bars are put in the annotation. If the value is continuous, boxplot is used. |
|
2681 |
+# |
|
2682 |
+# In the barplot, the color schema is used as the same as the heatmap, while for the boxplot, the color needs |
|
2683 |
+# to be controlled by ``gp``. |
|
2684 |
+# |
|
2685 |
+# == example |
|
2686 |
+# ha = HeatmapAnnotation(summary = anno_summary(height = unit(4, "cm"))) |
|
2687 |
+# v = sample(letters[1:2], 50, replace = TRUE) |
|
2688 |
+# split = sample(letters[1:2], 50, replace = TRUE) |
|
2689 |
+# Heatmap(v, top_annotation = ha, width = unit(1, "cm"), split = split) |
|
2690 |
+# |
|
2691 |
+# ha = HeatmapAnnotation(summary = anno_summary(gp = gpar(fill = 2:3), height = unit(4, "cm"))) |
|
2692 |
+# v = rnorm(50) |
|
2693 |
+# Heatmap(v, top_annotation = ha, width = unit(1, "cm"), split = split) |
|
2694 |
+# |
|
2658 | 2695 |
anno_summary = function(which = c("column", "row"), border = TRUE, bar_width = 0.8, |
2659 | 2696 |
axis = TRUE, axis_param = default_axis_param(which), |
2660 | 2697 |
ylim = NULL, extend = 0.05, outline = TRUE, box_width = 0.6, |
2661 | 2698 |
pch = 1, size = unit(2, "mm"), gp = gpar(), |
2662 |
- width = NULL, height = NULL, ...) { |
|
2699 |
+ width = NULL, height = NULL) { |
|
2663 | 2700 |
|
2664 | 2701 |
if(is.null(.ENV$current_annotation_which)) { |
2665 | 2702 |
which = match.arg(which)[1] |
... | ... |
@@ -4,7 +4,7 @@ |
4 | 4 |
# |
5 | 5 |
|
6 | 6 |
# == title |
7 |
-# Class for Mapping Values to Colors |
|
7 |
+# Class for Color Mapping |
|
8 | 8 |
# |
9 | 9 |
# == details |
10 | 10 |
# The `ColorMapping-class` handles color mapping for discrete values and continuous values. |
... | ... |
@@ -127,7 +127,7 @@ ColorMapping = function(name, colors = NULL, levels = NULL, |
127 | 127 |
} |
128 | 128 |
|
129 | 129 |
# == title |
130 |
-# Print ColorMapping Object |
|
130 |
+# Print the ColorMapping Object |
|
131 | 131 |
# |
132 | 132 |
# == param |
133 | 133 |
# -object A `ColorMapping-class` object. |
... | ... |
@@ -10,42 +10,6 @@ |
10 | 10 |
# Class for a single heatmap |
11 | 11 |
# |
12 | 12 |
# == details |
13 |
-# The components for a single heamtap are placed into a 9 x 7 layout: |
|
14 |
-# |
|
15 |
-# +------+ (1) |
|
16 |
-# +------+ (2) |
|
17 |
-# +------+ (3) |
|
18 |
-# +------+ (4) |
|
19 |
-# +-+-+-+------+-+-+-+ |
|
20 |
-# |1|2|3| 4(5) |5|6|7| |
|
21 |
-# +-+-+-+------+-+-+-+ |
|
22 |
-# +------+ (6) |
|
23 |
-# +------+ (7) |
|
24 |
-# +------+ (8) |
|
25 |
-# +------+ (9) |
|
26 |
-# |
|
27 |
-# From top to bottom in column 4, the regions are: |
|
28 |
-# |
|
29 |
-# - title which is put on the top of the heatmap, graphics are drawn by `draw_title,Heatmap-method`. |
|
30 |
-# - column cluster on the top, graphics are drawn by `draw_dend,Heatmap-method`. |
|
31 |
-# - column annotation on the top, graphics are drawn by `draw_annotation,Heatmap-method`. |
|
32 |
-# - column names on the top, graphics are drawn by `draw_dimnames,Heatmap-method`. |
|
33 |
-# - heatmap body, graphics are drawn by `draw_heatmap_body,Heatmap-method`. |
|
34 |
-# - column names on the bottom, graphics are drawn by `draw_dimnames,Heatmap-method`. |
|
35 |
-# - column annotation on the bottom, graphics are drawn by `draw_annotation,Heatmap-method`. |
|
36 |
-# - column cluster on the bottom, graphics are drawn by `draw_dend,Heatmap-method`. |
|
37 |
-# - title on the bottom, graphics are drawn by `draw_title,Heatmap-method`. |
|
38 |
-# |
|
39 |
-# From left to right in row 5, the regions are: |
|
40 |
-# |
|
41 |
-# - title which is put in the left of the heatmap, graphics are drawn by `draw_title,Heatmap-method`. |
|
42 |
-# - row cluster on the left, graphics are drawn by `draw_dend,Heatmap-method`. |
|
43 |
-# - row names on the left, graphics are drawn by `draw_dimnames,Heatmap-method`. |
|
44 |
-# - heatmap body |
|
45 |
-# - row names on the right, graphics are drawn by `draw_dimnames,Heatmap-method`. |
|
46 |
-# - row cluster on the right, graphics are drawn by `draw_dend,Heatmap-method`. |
|
47 |
-# - title on the right, graphics are drawn by `draw_title,Heatmap-method`. |
|
48 |
-# |
|
49 | 13 |
# The `Heatmap-class` is not responsible for heatmap legend and annotation legends. The `draw,Heatmap-method` method |
50 | 14 |
# will construct a `HeatmapList-class` object which only contains one single heatmap |
51 | 15 |
# and call `draw,HeatmapList-method` to make a complete heatmap. |
... | ... |
@@ -125,12 +89,12 @@ Heatmap = setClass("Heatmap", |
125 | 89 |
# -rect_gp graphic parameters for drawing rectangles (for heatmap body). |
126 | 90 |
# -color_space the color space in which colors are interpolated. Only used if ``matrix`` is numeric and |
127 | 91 |
# ``col`` is a vector of colors. Pass to `circlize::colorRamp2`. |
128 |
-# -border border |
|
92 |
+# -border whether draw border or the color of border. |
|
129 | 93 |
# -cell_fun self-defined function to add graphics on each cell. Seven parameters will be passed into |
130 | 94 |
# this function: ``i``, ``j``, ``x``, ``y``, ``width``, ``height``, ``fill`` which are row index, |
131 | 95 |
# column index in ``matrix``, coordinate of the middle points in the heatmap body viewport, |
132 | 96 |
# the width and height of the cell and the filled color. ``x``, ``y``, ``width`` and ``height`` are all `grid::unit` objects. |
133 |
-# -layer_fun layer fun |
|
97 |
+# -layer_fun similar as ``cell_fun``, but is vectorized. |
|
134 | 98 |
# -row_title title on row. |
135 | 99 |
# -row_title_side will the title be put on the left or right of the heatmap? |
136 | 100 |
# -row_title_gp graphic parameters for drawing text. |
... | ... |
@@ -199,10 +163,10 @@ Heatmap = setClass("Heatmap", |
199 | 163 |
# to top to bottom in the heatmap |
200 | 164 |
# -row_gap row gap |
201 | 165 |
# -column_gap column gap |
202 |
-# -width width |
|
203 |
-# -height height |
|
204 |
-# -heatmap_body_width width |
|
205 |
-# -heatmap_body_height height |
|
166 |
+# -width width of the heatmap body |
|
167 |
+# -height height of the heatmap body |
|
168 |
+# -heatmap_width width of the whole heatmap (including heatmap components) |
|
169 |
+# -heatmap_height height of the whole heatmap (including heatmap components) |
|
206 | 170 |
# -show_heatmap_legend whether show heatmap legend? |
207 | 171 |
# -heatmap_legend_param a list contains parameters for the heatmap legend. See `color_mapping_legend,ColorMapping-method` for all available parameters. |
208 | 172 |
# -use_raster whether render the heatmap body as a raster image. It helps to reduce file size when the matrix is huge. Note if ``cell_fun`` |
... | ... |
@@ -213,14 +177,13 @@ Heatmap = setClass("Heatmap", |
213 | 177 |
# -post_fun a function which will be executed after the plot is drawn. |
214 | 178 |
# |
215 | 179 |
# == details |
216 |
-# The initialization function only applies parameter checking and fill values to each slot with proper ones. |
|
217 |
-# Then it will be ready for clustering and layout. |
|
180 |
+# The initialization function only applies parameter checking and fill values to the slots with proper values. |
|
218 | 181 |
# |
219 | 182 |
# Following methods can be applied on the `Heatmap-class` object: |
220 | 183 |
# |
221 | 184 |
# - `show,Heatmap-method`: draw a single heatmap with default parameters |
222 | 185 |
# - `draw,Heatmap-method`: draw a single heatmap. |
223 |
-# - `add_heatmap,Heatmap-method` append heatmaps and row annotations to a list of heatmaps. |
|
186 |
+# - ``+`` or `\%v\%` append heatmaps and row annotations to a list of heatmaps. |
|
224 | 187 |
# |
225 | 188 |
# The constructor function pretends to be a high-level graphic function because the ``show`` method |
226 | 189 |
# of the `Heatmap-class` object actually plots the graphics. |
... | ... |
@@ -851,7 +814,8 @@ setMethod(f = "make_row_cluster", |
851 | 814 |
# -object A `Heatmap-class` object. |
852 | 815 |
# |
853 | 816 |
# == details |
854 |
-# The function will fill or adjust ``column_dend_list``, ``column_order_list``, ``column_title`` and ``matrix_param`` slots. |
|
817 |
+# The function will fill or adjust ``column_dend_list``, |
|
818 |
+# ``column_order_list``, ``column_title`` and ``matrix_param`` slots. |
|
855 | 819 |
# |
856 | 820 |
# If ``order`` is defined, no clustering will be applied. |
857 | 821 |
# |
... | ... |
@@ -1343,7 +1307,7 @@ make_cluster = function(object, which = c("row", "column")) { |
1343 | 1307 |
# The function creates a `HeatmapList-class` object which only contains a single heatmap |
1344 | 1308 |
# and call `draw,HeatmapList-method` to make the final heatmap. |
1345 | 1309 |
# |
1346 |
-# There are some arguments which control the global setting of the heatmap such as legends. |
|
1310 |
+# There are some arguments which control the some settings of the heatmap such as legends. |
|
1347 | 1311 |
# Please go to `draw,HeatmapList-method` for these arguments. |
1348 | 1312 |
# |
1349 | 1313 |
# == value |
... | ... |
@@ -1414,7 +1378,7 @@ setMethod(f = "draw", |
1414 | 1378 |
# == detail |
1415 | 1379 |
# The preparation of the heatmap includes following steps: |
1416 | 1380 |
# |
1417 |
-# - making clustering on rows if it is specified (by calling `make_row_cluster,Heatmap-method`) |
|
1381 |
+# - making clustering on rows (by calling `make_row_cluster,Heatmap-method`) |
|
1418 | 1382 |
# - making clustering on columns (by calling `make_column_cluster,Heatmap-method`) |
1419 | 1383 |
# - making the layout of the heatmap (by calling `make_layout,Heatmap-method`) |
1420 | 1384 |
# |
... | ... |
@@ -1,12 +1,12 @@ |
1 | 1 |
|
2 | 2 |
# == title |
3 |
-# Draw the heatmap body |
|
3 |
+# Draw the Heatmap Body |
|
4 | 4 |
# |
5 | 5 |
# == param |
6 | 6 |
# -object A `Heatmap-class` object. |
7 | 7 |
# -kr Row slice index. |
8 | 8 |
# -kc Column slice index. |
9 |
-# -... Pass to `grid::viewport` which includes the subset of heatmap body. |
|
9 |
+# -... Pass to `grid::viewport` which includes the slice of heatmap body. |
|
10 | 10 |
# |
11 | 11 |
# == details |
12 | 12 |
# A viewport is created which contains subset rows and columns of the heatmap. |
... | ... |
@@ -7,7 +7,7 @@ |
7 | 7 |
# |
8 | 8 |
# == detail |
9 | 9 |
# The layout of the single heatmap will be established by setting the size of each heatmap components. |
10 |
-# Also functions that make graphics for heatmap components will be recorded by saving as functions. |
|
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 | 13 |
# first before making the layout. |
... | ... |
@@ -52,10 +52,6 @@ HeatmapAnnotation = setClass("HeatmapAnnotation", |
52 | 52 |
# -annotation_legend_param A list which contains parameters for annotation legends. See `color_mapping_legend,ColorMapping-method` for all possible options. |
53 | 53 |
# -show_legend Whether show annotation legend. The value can be one single value or a vector which corresponds to the simple annotations. |
54 | 54 |
# -which Are the annotations row annotations or column annotations? |
55 |
-# -annotation_height Height of each annotation if annotations are column annotations. |
|
56 |
-# -annotation_width Width of each annotation if annotations are row annotations. |
|
57 |
-# -height Height of the complete column annotations. |
|
58 |
-# -width Width of the complete heatmap annotations. |
|
59 | 55 |
# -gp Graphic parameters for simple annotations (with ``fill`` parameter ignored). |
60 | 56 |
# -border border of single annotations. |
61 | 57 |
# -gap Gap between each two annotation. It can be a single value or a vector of `grid::unit` objects. |
... | ... |
@@ -65,6 +61,12 @@ HeatmapAnnotation = setClass("HeatmapAnnotation", |
65 | 61 |
# -annotation_name_offset Offset to the annotations, `grid::unit` object. The value can be a vector. |
66 | 62 |
# -annotation_name_side Side of the annotation names. |
67 | 63 |
# -annotation_name_rot Rotation of the annotation names, can only take values in ``c(00, 90, 180, 270)``. The value can be a vector. |
64 |
+# -annotation_height Height of each annotation if annotations are column annotations. |
|
65 |
+# -annotation_width Width of each annotation if annotations are row annotations. |
|
66 |
+# -height Height of the complete column annotations. |
|
67 |
+# -width Width of the complete heatmap annotations. |
|
68 |
+# -anno_simple_size size of the simple annotation. |
|
69 |
+# -simple_anno_size_adjust whether also adjust the size of simple annotations when adjust the whole heatmap annotation. |
|
68 | 70 |
# |
69 | 71 |
# == details |
70 | 72 |
# There are three ways to specify heatmap annotations: |
... | ... |
@@ -231,16 +233,16 @@ HeatmapAnnotation = function(..., |
231 | 233 |
|
232 | 234 |
if(!missing(col)) { |
233 | 235 |
if(is.null(names(col))) { |
234 |
- stop("`col` should be a named list.") |
|
236 |
+ stop_wrap("`col` should be a named list.") |
|
235 | 237 |
} |
236 | 238 |
if(any(is.na(names(col)))) { |
237 |
- stop("`col` should be a named list.") |
|
239 |
+ stop_wrap("`col` should be a named list.") |
|
238 | 240 |
} |
239 | 241 |
if(any(sapply(col, function(x) if(is.function(x)) FALSE else is.null(names(x))))) { |
240 |
- stop("elements in `col` should be named vectors.") |
|
242 |
+ stop_wrap("elements in `col` should be named vectors.") |
|
241 | 243 |
} |
242 | 244 |
if(any(sapply(col, function(x) if(is.function(x)) FALSE else any(is.na(names(x)))))) { |
243 |
- stop("elements in `col` should be named vectors.") |
|
245 |
+ stop_wrap("elements in `col` should be named vectors.") |
|
244 | 246 |
} |
245 | 247 |
} |
246 | 248 |
|
... | ... |
@@ -260,7 +262,7 @@ HeatmapAnnotation = function(..., |
260 | 262 |
len = len[len > 0] |
261 | 263 |
if(length(len)) { |
262 | 264 |
if(length(unique(len)) > 1) { |
263 |
- stop("Length of annotations differs.") |
|
265 |
+ stop_wrap("Length of annotations differs.") |
|
264 | 266 |
} |
265 | 267 |
} |
266 | 268 |
|
... | ... |
@@ -314,7 +316,7 @@ HeatmapAnnotation = function(..., |
314 | 316 |
} |
315 | 317 |
i_simple = i_simple + 1 |
316 | 318 |
} else { |
317 |
- stop(paste0(ag, ": annotations should be vector/data frame (only `df`)/matrix/functions.")) |
|
319 |
+ stop_wrap(paste0(ag, ": annotations should be vector/data frame (only `df`)/matrix/functions.")) |
|
318 | 320 |
} |
319 | 321 |
|
320 | 322 |
} |
... | ... |
@@ -336,7 +338,7 @@ HeatmapAnnotation = function(..., |
336 | 338 |
} else if(length(gap) == n_total_anno - 1) { |
337 | 339 |
gap = unit.c(gap, unit(0, "mm")) |
338 | 340 |
} else if(length(gap) < n_total_anno - 1) { |
339 |
- stop("Length of `gap` is wrong.") |
|
341 |
+ stop_wrap("Length of `gap` is wrong.") |
|
340 | 342 |
} |
341 | 343 |
|
342 | 344 |
.Object@gap = gap |
... | ... |
@@ -3,42 +3,7 @@ |
3 | 3 |
# Class for a list of heatmaps |
4 | 4 |
# |
5 | 5 |
# == details |
6 |
-# A heatmap list is defined as a list of heatmaps and row annotations. |
|
7 |
-# |
|
8 |
-# The components for the heamtap list are placed into a 7 x 7 layout: |
|
9 |
-# |
|
10 |
-# +------+(1) |
|
11 |
-# +------+(2) |
|
12 |
-# +------+(3) |
|
13 |
-# +-+-+-+------+-+-+-+ |
|
14 |
-# |1|2|3| 4(4) |5|6|7| |
|
15 |
-# +-+-+-+------+-+-+-+ |
|
16 |
-# +------+(5) |
|
17 |
-# +------+(6) |
|
18 |
-# +------+(7) |
|
19 |
-# |
|
20 |
-# From top to bottom in column 4, the regions are: |
|
21 |
-# |
|
22 |
-# - annotation legend on the top, graphics are drawn by `draw_annotation_legend,HeatmapList-method`. |
|
23 |
-# - heatmap legend on the top, graphics are drawn by `draw_heatmap_legend,HeatmapList-method`. |
|
24 |
-# - title for the heatmap list which is put on the top, graphics are drawn by `draw_title,HeatmapList-method`. |
|
25 |
-# - the list of heatmaps and row annotations |
|
26 |
-# - title for the heatmap list which is put on the bottom, graphics are drawn by `draw_title,HeatmapList-method`. |
|
27 |
-# - heatmap legend on the bottom, graphics are drawn by `draw_heatmap_legend,HeatmapList-method`. |
|
28 |
-# - annotation legend on the bottom, graphics are drawn by `draw_annotation_legend,HeatmapList-method`. |
|
29 |
-# |
|
30 |
-# From left to right in row 4, the regions are: |
|
31 |
-# |
|
32 |
-# - annotation legend on the left, graphics are drawn by `draw_annotation_legend,HeatmapList-method`. |
|
33 |
-# - heatmap legend on the left, graphics are drawn by `draw_heatmap_legend,HeatmapList-method`. |
|
34 |
-# - title for the heatmap list which is put on the left, graphics are drawn by `draw_title,HeatmapList-method`. |
|
35 |
-# - the list of heatmaps and row annotations |
|
36 |
-# - title for the heatmap list which is put on the right, graphics are drawn by `draw_title,HeatmapList-method`. |
|
37 |
-# - heatmap legend on the right, graphics are drawn by `draw_heatmap_legend,HeatmapList-method`. |
|
38 |
-# - annotation legend on the right, graphics are drawn by `draw_annotation_legend,HeatmapList-method`. |
|
39 |
-# |
|
40 |
-# For the list of heatmaps which are placed at (5, 5) in the layout, the heatmaps and row annotations |
|
41 |
-# are placed one after the other. |
|
6 |
+# A heatmap list is defined as a list of heatmaps and annotations. |
|
42 | 7 |
# |
43 | 8 |
# == methods |
44 | 9 |
# The `HeatmapList-class` provides following methods: |
... | ... |
@@ -121,7 +86,7 @@ HeatmapList = function(...) { |
121 | 86 |
# == param |
122 | 87 |
# -object a `HeatmapList-class` object. |
123 | 88 |
# -x a `Heatmap-class` object or a `HeatmapAnnotation-class` object or a `HeatmapList-class` object. |
124 |
-# -direction direction |
|
89 |
+# -direction direction of the concatenation. |
|
125 | 90 |
# |
126 | 91 |
# == details |
127 | 92 |
# There is a shortcut function ``+.AdditiveUnit``. |
... | ... |
@@ -138,7 +103,7 @@ setMethod(f = "add_heatmap", |
138 | 103 |
|
139 | 104 |
direction = match.arg(direction)[1] |
140 | 105 |
if(object@direction != direction) { |
141 |
- stop("The heatmap list should only be all horizontal or vertical.") |
|
106 |
+ stop_wrap("The heatmap list should only be all horizontal or vertical.") |
|
142 | 107 |
} |
143 | 108 |
|
144 | 109 |
# check settings of this new heatmap |
... | ... |
@@ -149,9 +114,9 @@ setMethod(f = "add_heatmap", |
149 | 114 |
object@ht_list = c(object@ht_list, x) |
150 | 115 |
} else if(inherits(x, "HeatmapAnnotation")) { |
151 | 116 |
if(x@which == "row" && direction == "vertical") { |
152 |
- stop("Row annotations should be added to the heatmap list in horizontal direction.") |
|
117 |
+ stop_wrap("Row annotations should be added to the heatmap list in horizontal direction.") |
|
153 | 118 |
} else if(x@which == "column" && direction == "horizontal") { |
154 |
- stop("Column annotations should be added to the heatmap list in vertical direction.") |
|
119 |
+ stop_wrap("Column annotations should be added to the heatmap list in vertical direction.") |
|
155 | 120 |
} |
156 | 121 |
ht_name = x@name |
157 | 122 |
x = list(x) |
... | ... |
@@ -176,7 +141,7 @@ setMethod(f = "add_heatmap", |
176 | 141 |
if(length(unique(nr)) > 1) { |
177 | 142 |
cat("`nrow` of all heatmaps:\n") |
178 | 143 |
print(nr) |
179 |
- stop("`nrow` of all heatmaps should be the same for horizontal heatmap list.") |
|
144 |
+ stop_wrap("`nrow` of all heatmaps should be the same for horizontal heatmap list.") |
|
180 | 145 |
for(i in l) { |
181 | 146 |
cat(object@ht_list[[i]]@name, ":", nrow(object@ht_list[[i]]@matrix), "\n") |
182 | 147 |
} |
... | ... |
@@ -188,7 +153,7 @@ setMethod(f = "add_heatmap", |
188 | 153 |
if(length(unique(nc)) > 1) { |
189 | 154 |
cat("`ncol` of all heatmaps:\n") |
190 | 155 |
print(nc) |
191 |
- stop("`ncol` of all heatmaps should be the same for vertical heatmap list.") |
|
156 |
+ stop_wrap("`ncol` of all heatmaps should be the same for vertical heatmap list.") |
|
192 | 157 |
for(i in l) { |
193 | 158 |
cat(object@ht_list[[i]]@name, ":", ncol(object@ht_list[[i]]@matrix), "\n") |
194 | 159 |
} |
... | ... |
@@ -204,71 +169,72 @@ setMethod(f = "add_heatmap", |
204 | 169 |
# Draw a list of heatmaps |
205 | 170 |
# |
206 | 171 |
# == param |
207 |
-# -object a `HeatmapList-class` object |
|
208 |
-# -newpage whether create a new page for the graphics. |
|
172 |
+# -object a `HeatmapList-class` object. |
|
173 |
+# -newpage whether create a new page for the graphics. If you want to arrange multiple plots in one page, I suggest to use `grid::grabExpr`. |
|
209 | 174 |
# -row_title title on the row. |
210 | 175 |
# -row_title_side will the title be put on the left or right of the heatmap. |
211 | 176 |
# -row_title_gp graphic parameters for drawing text. |
212 | 177 |
# -column_title title on the column. |
213 | 178 |
# -column_title_side will the title be put on the top or bottom of the heatmap. |
214 | 179 |
# -column_title_gp graphic parameters for drawing text. |
215 |
-# -heatmap_legend_side = c("right", "left", "bottom", "top"), |
|
216 |
-# -heatmap_legend_offset = unit(0, "mm"), |
|
217 |
-# -merge_legends = FALSE, |
|
218 |
-# -show_heatmap_legend = TRUE, |
|
219 |
-# -heatmap_legend_list = list(), |
|
220 |
-# -annotation_legend_side = c("right", "left", "bottom", "top"), |
|
221 |
-# -annotation_legend_offset = unit(0, "mm"), |
|
222 |
-# -show_annotation_legend = TRUE, |
|
223 |
-# -annotation_legend_list = list(), |
|
224 |
-# -gap = unit(2, "mm"), |
|
225 |
-# -ht_gap = gap, |
|
226 |
-# -main_heatmap = which(sapply(object@ht_list, inherits, "Heatmap"))[1], |
|
227 |
-# -padding = NULL, |
|
228 |
-# -adjust_annotation_name adjust_annotation_name |
|
229 |
-# -row_dend_side = c("original", "left", "right"), |
|
230 |
-# -row_sub_title_side = c("original", "left", "right"), |
|
231 |
-# -column_dend_side = c("original", "top", "bottom"), |
|
232 |
-# -column_sub_title_side = c("original", "top", "bottom"), |
|
233 |
-# -row_gap = NULL, |
|
234 |
-# -cluster_rows = NULL, |
|
235 |
-# -clustering_distance_rows = NULL, |
|
236 |
-# -clustering_method_rows = NULL, |
|
237 |
-# -row_dend_width = NULL, |
|
238 |
-# -show_row_dend = NULL, |
|
239 |
-# -row_dend_reorder = NULL, |
|
240 |
-# -row_dend_gp = NULL, |
|
241 |
-# -row_order = NULL, |
|
242 |
-# -km = NULL, |
|
243 |
-# -split = NULL, |
|
244 |
-# -row_km = km, |
|
245 |
-# -row_split = split, |
|
246 |
-# -heatmap_body_height = NULL, |
|
247 |
-# -column_gap = NULL, |
|
248 |
-# -cluster_columns = NULL, |
|
249 |
-# -clustering_distance_columns = NULL, |
|
250 |
-# -clustering_method_columns = NULL, |
|
251 |
-# -column_dend_width = NULL, |
|
252 |
-# -show_column_dend = NULL, |
|
253 |
-# -column_dend_reorder = NULL, |
|
254 |
-# -column_dend_gp = NULL, |
|
255 |
-# -column_order = NULL, |
|
256 |
-# -column_km = NULL, |
|
257 |
-# -column_split = NULL, |
|
258 |
-# -heatmap_body_width = NULL, |
|
259 |
-# -heatmap_row_names_gp = NULL, |
|
260 |
-# -heatmap_column_names_gp = NULL, |
|
261 |
-# -heatmap_row_title_gp = NULL, |
|
262 |
-# -heatmap_column_title_gp = NULL, |
|
263 |
-# -legend_title_gp = NULL, |
|
264 |
-# -legend_title_position = NULL, |
|
265 |
-# -legend_labels_gp = NULL, |
|
266 |
-# -legend_grid_height = NULL, |
|
267 |
-# -legend_grid_width = NULL, |
|
268 |
-# -legend_grid_border = NULL, |
|
269 |
-# -fastcluster = NULL, |
|
270 |
-# -show_vp_border = NULL, |
|
271 |
-# -anno_simple_row_size = NULL |
|
180 |
+# -heatmap_legend_side side to put heatmap legend |
|
181 |
+# -heatmap_legend_offset currently disabled |
|
182 |
+# -merge_legends merge heatmap legends and annotation legends to put into one column. |
|
183 |
+# -show_heatmap_legend whether show all heatmap legends |
|
184 |
+# -heatmap_legend_list use-defined legends which are put after the heatmap legends |
|
185 |
+# -annotation_legend_side side of the annotation legends |
|
186 |
+# -annotation_legend_offset currently disabled |
|
187 |
+# -show_annotation_legend whether show annotation legends |
|
188 |
+# -annotation_legend_list user-defined legends which are put after the annotation legends |
|
189 |
+# -gap gap between heatmaps/annotations |
|
190 |
+# -ht_gap same as ``gap``. |
|
191 |
+# -main_heatmap index of main heatmap. The value can be a numeric index or the heatmap name |
|
192 |
+# -padding padding of the whole plot. The value is a unit vector of length 4, which corresponds to bottom, left, top and right. |
|
193 |
+# -adjust_annotation_name whether take annotation name into account when calculating positions of graphic elements. |
|
194 |
+# -row_dend_side side of the dendrogram from the main heatmap |
|
195 |
+# -row_sub_title_side side of the row title from the main heatmap |
|
196 |
+# -column_dend_side side of the dendrogram from the main heatmap |
|
197 |
+# -column_sub_title_side side of the column title from the main heatmap |
|
198 |
+# -row_gap this modifies ``row_gap`` of the main heatmap |
|
199 |
+# -cluster_rows this modifies ``cluster_rows`` of the main heatmap |
|
200 |
+# -clustering_distance_rows this modifies ``clustering_distance_rows`` of the main heatmap |
|
201 |
+# -clustering_method_rows this modifies ``clustering_method_rows`` of the main heatmap |
|
202 |
+# -row_dend_width this modifies ``row_dend_width`` of the main heatmap |
|
203 |
+# -show_row_dend this modifies ``show_row_dend`` of the main heatmap |
|
204 |
+# -row_dend_reorder this modifies ``row_dend_reorder`` of the main heatmap |
|
205 |
+# -row_dend_gp this modifies ``row_dend_gp`` of the main heatmap |
|
206 |
+# -row_order this modifies ``row_order`` of the main heatmap |
|
207 |
+# -km = this modifies ``km`` of the main heatmap |
|
208 |
+# -split this modifies ``split`` of the main heatmap |
|
209 |
+# -row_km this modifies ``row_km`` of the main heatmap |
|
210 |
+# -row_split this modifies ``row_split`` of the main heatmap |
|
211 |
+# -heatmap_body_height this modifies ``heatmap_body_height`` of the main heatmap |
|
212 |
+# -column_gap this modifies ``column_gap`` of the main heatmap |
|
213 |
+# -cluster_columns this modifies ``cluster_columns`` of the main heatmap |
|
214 |
+# -clustering_distance_columns this modifies ``clustering_distance_columns`` of the main heatmap |
|
215 |
+# -clustering_method_columns this modifies ``clustering_method_columns`` of the main heatmap |
|
216 |
+# -column_dend_width this modifies ``column_dend_width`` of the main heatmap |
|
217 |
+# -show_column_dend this modifies ``show_column_dend`` of the main heatmap |
|
218 |
+# -column_dend_reorder this modifies ``column_dend_reorder`` of the main heatmap |
|
219 |
+# -column_dend_gp this modifies ``column_dend_gp`` of the main heatmap |
|
220 |
+# -column_order this modifies ``column_order`` of the main heatmap |
|
221 |
+# -column_km this modifies ``column_km`` of the main heatmap |
|
222 |
+# -column_split this modifies ``column_split`` of the main heatmap |
|
223 |
+# -heatmap_body_width this set the value in `ht_opt` and reset back after the plot is done |
|
224 |
+# -heatmap_row_names_gp this set the value in `ht_opt` and reset back after the plot is done |
|
225 |
+# -heatmap_column_names_gp this set the value in `ht_opt` and reset back after the plot is done |
|
226 |
+# -heatmap_row_title_gp this set the value in `ht_opt` and reset back after the plot is done |
|
227 |
+# -heatmap_column_title_gp this set the value in `ht_opt` and reset back after the plot is done |
|
228 |
+# -legend_title_gp this set the value in `ht_opt` and reset back after the plot is done |
|
229 |
+# -legend_title_position this set the value in `ht_opt` and reset back after the plot is done |
|
230 |
+# -legend_labels_gp this set the value in `ht_opt` and reset back after the plot is done |
|
231 |
+# -legend_grid_height this set the value in `ht_opt` and reset back after the plot is done |
|
232 |
+# -legend_grid_width this set the value in `ht_opt` and reset back after the plot is done |
|
233 |
+# -legend_border this set the value in `ht_opt` and reset back after the plot is done |
|
234 |
+# -heatmap_border this set the value in `ht_opt` and reset back after the plot is done |
|
235 |
+# -annotation_border this set the value in `ht_opt` and reset back after the plot is done |
|
236 |
+# -fastcluster this set the value in `ht_opt` and reset back after the plot is done |
|
237 |
+# -anno_simple_size this set the value in `ht_opt` and reset back after the plot is done |
|
272 | 238 |
# |
273 | 239 |
# == detail |
274 | 240 |
# The function first calls `make_layout,HeatmapList-method` to calculate |
... | ... |
@@ -277,7 +243,7 @@ setMethod(f = "add_heatmap", |
277 | 243 |
# in the layout. |
278 | 244 |
# |
279 | 245 |
# == value |
280 |
-# This function returns a list of row dendrograms and column dendrogram. |
|
246 |
+# This function returns a `HeatmapList-class` object for which the layout has been created. |
|
281 | 247 |
# |
282 | 248 |
# == author |
283 | 249 |
# Zuguang Gu <z.gu@dkfz.de> |
... | ... |
@@ -400,7 +366,7 @@ setMethod(f = "draw", |
400 | 366 |
ob = sapply(object@ht_list, nobs) |
401 | 367 |
ob = ob[!is.na(ob)] |
402 | 368 |
if(length(ob) == 0) { |
403 |
- stop("There is no heatmap in the list and cannot infer the number of observations in the heatmap annotations, please add a zero row/column matrix by hand.") |
|
369 |
+ stop_wrap("There is no heatmap in the list and cannot infer the number of observations in the heatmap annotations, please add a zero row/column matrix by hand.") |
|
404 | 370 |
} |
405 | 371 |
if(direction == "horizontal") { |
406 | 372 |
nr = ob[1] |
... | ... |
@@ -589,62 +555,143 @@ setMethod(f = "show", |
589 | 555 |
}) |
590 | 556 |
|
591 | 557 |
|
558 |
+# == title |
|
559 |
+# Subset a HeatmapList object |
|
560 |
+# |
|
561 |
+# == param |
|
562 |
+# -x A `HeatmapList-class` object |
|
563 |
+# -i row indices |
|
564 |
+# -j column indices |
|
565 |
+# |
|
566 |
+# == details |
|
567 |
+# If the heatmap list is horizontal, ``i`` is the real row indices and ``j`` corresponds to heatmap names and single annotation names. |
|
568 |
+# |
|
592 | 569 |
"[.HeatmapList" = function(x, i, j) { |
593 | 570 |
|
571 |
+ direction = x@direction |
|
572 |
+ |
|
594 | 573 |
if(!is.null(x@layout$initialized)) { |
595 | 574 |
if(x@layout$initialized) { |
596 |
- stop("subsetting on HeatmapList can only be applied before `draw()`.") |
|
575 |
+ stop_wrap("subsetting on HeatmapList can only be applied before `draw()`.") |
|
597 | 576 |
} |
598 | 577 |
} |
599 | 578 |
|
600 | 579 |
if(length(x@ht_list) == 1) { |
601 | 580 |
if(inherits(x@ht_list[[1]], "Heatmap")) { |
602 |
- return(x@ht_list[[1]][i, j]) |
|
581 |
+ if(direction == "horizontal") { |
|
582 |
+ return(x@ht_list[[1]][i, j] + NULL) |
|
583 |
+ } else { |
|
584 |
+ return(x@ht_list[[1]][i, j] %v% NULL) |
|
585 |
+ } |
|
603 | 586 |
} |
604 | 587 |
} |
605 | 588 |
|
606 | 589 |
if(nargs() == 2) { |
607 |
- subset_heatmap_list_by_row(x, i) |
|
590 |
+ subset_heatmap_list_by_row(x, i, direction) |
|
608 | 591 |
} else { |
609 | 592 |
if(missing(i)) { |
610 |
- subset_heatmap_list_by_column(x, j) |
|
593 |
+ subset_heatmap_list_by_column(x, j, direction) |
|
611 | 594 |
} else if(missing(j)) { |
612 |
- subset_heatmap_list_by_row(x, i) |
|
595 |
+ subset_heatmap_list_by_row(x, i, direction) |
|
613 | 596 |
} else { |
614 |
- x = subset_heatmap_list_by_row(x, i) |
|
615 |
- subset_heatmap_list_by_column(x, j) |
|
597 |
+ x = subset_heatmap_list_by_row(x, i, direction) |
|
598 |
+ subset_heatmap_list_by_column(x, j, direction) |
|
616 | 599 |
} |
617 | 600 |
} |
618 | 601 |
} |
619 | 602 |
|
620 | 603 |
# there is no main heatmap yet |
621 |
-subset_heatmap_list_by_row = function(ht_list, ind) { |
|
604 |
+subset_heatmap_list_by_row = function(ht_list, ind, direction) { |
|
622 | 605 |
|
623 |
- for(i in seq_along(ht_list@ht_list)) { |
|
624 |
- ht_list@ht_list[[i]] = ht_list@ht_list[[i]][ind] |
|
606 |
+ if(direction == "horizontal") { |
|
607 |
+ for(i in seq_along(ht_list@ht_list)) { |
|
608 |
+ if(inherits(ht_list@ht_list[[i]], "Heatmap")) { |
|
609 |
+ ht_list@ht_list[[i]] = ht_list@ht_list[[i]][ind, ] |
|
610 |
+ } else { |
|
611 |
+ ht_list@ht_list[[i]] = ht_list@ht_list[[i]][ind] |
|
612 |
+ } |
|
613 |
+ } |
|
614 |
+ } else { |
|
615 |
+ if(is.numeric(ind)) { |
|
616 |
+ ht_list@ht_list = ht_list@ht_list[ind] |
|
617 |
+ } else { |
|
618 |
+ ht_list = NULL |
|
619 |
+ # also check annotation names |
|
620 |
+ for(nm in names(ht_list@ht_list)) { |
|
621 |
+ if(inherits(ht_list@ht_list[[nm]], "Heatmap")) { |
|
622 |
+ if(nm %in% ind) { |
|
623 |
+ ht_list[[nm]] = ht_list@ht_list[[nm]] |
|
624 |
+ } |
|
625 |
+ } else { |
|
626 |
+ anno_nm = names(ht_list@ht_list[[nm]]@anno_list) |
|
627 |
+ if(anno_nm %in% ind) { |
|
628 |
+ ht_list[[nm]] = ht_list@ht_list[[nm]][, intersect(ind, anno_nm)] |
|
629 |
+ } |
|
630 |
+ } |
|
631 |
+ } |
|
632 |
+ ht_list@ht_list = ht_list |
|
633 |
+ } |
|
625 | 634 |
} |
626 | 635 |
return(ht_list) |
627 | 636 |
} |
628 | 637 |
|
629 |
-subset_heatmap_list_by_column = function(ht_list, ind) { |
|
630 |
- if(is.numeric(ind)) { |
|
631 |
- ht_list@ht_list = ht_list@ht_list[ind] |
|
632 |
- } else { |
|
633 |
- ht_list = NULL |
|
634 |
- # also check annotation names |
|
635 |
- for(nm in names(ht_list@ht_list)) { |
|
636 |
- if(inherits(ht_list@ht_list[[nm]], "Heatmap")) { |
|
637 |
- if(nm %in% ind) { |
|
638 |
- ht_list[[nm]] = ht_list@ht_list[[nm]] |
|
638 |
+subset_heatmap_list_by_column = function(ht_list, ind, direction) { |
|
639 |
+ if(direction == "horizontal") { |
|
640 |
+ if(is.numeric(ind)) { |
|
641 |
+ ht_list@ht_list = ht_list@ht_list[ind] |
|
642 |
+ } else { |
|
643 |
+ ht_list = NULL |
|
644 |
+ # also check annotation names |
|
645 |
+ for(nm in names(ht_list@ht_list)) { |
|
646 |
+ if(inherits(ht_list@ht_list[[nm]], "Heatmap")) { |
|
647 |
+ if(nm %in% ind) { |
|
648 |
+ ht_list[[nm]] = ht_list@ht_list[[nm]] |
|
649 |
+ } |
|
650 |
+ } else { |
|
651 |
+ anno_nm = names(ht_list@ht_list[[nm]]@anno_list) |
|
652 |
+ if(anno_nm %in% ind) { |
|
653 |
+ ht_list[[nm]] = ht_list@ht_list[[nm]][, intersect(ind, anno_nm)] |
|
654 |
+ } |
|
639 | 655 |
} |
656 |
+ } |
|
657 |
+ ht_list@ht_list = ht_list |
|
658 |
+ } |
|
659 |
+ } else { |
|
660 |
+ for(i in seq_along(ht_list@ht_list)) { |
|
661 |
+ if(inherits(ht_list@ht_list[[i]], "Heatmap")) { |
|
662 |
+ ht_list@ht_list[[i]] = ht_list@ht_list[[i]][, ind] |
|
640 | 663 |
} else { |
641 |
- anno_nm = names(ht_list@ht_list[[nm]]@anno_list) |
|
642 |
- if(anno_nm %in% ind) { |
|
643 |
- ht_list[[nm]] = ht_list@ht_list[[nm]][, intersect(ind, anno_nm)] |
|
644 |
- } |
|
664 |
+ ht_list@ht_list[[i]] = ht_list@ht_list[[i]][ind] |
|
645 | 665 |
} |
646 | 666 |
} |
647 |
- ht_list@ht_list = ht_list |
|
648 | 667 |
} |
649 | 668 |
return(ht_list) |
650 | 669 |
} |
670 |
+ |
|
671 |
+# == title |
|
672 |
+# Names of the heatmaps/annotations |
|
673 |
+# |
|
674 |
+# == param |
|
675 |
+# -x A `HeatmapList-class` object |
|
676 |
+# |
|
677 |
+names.HeatmapList = function(x) { |
|
678 |
+ nm = NULL |
|
679 |
+ for(i in seq_along(x@ht_list)) { |
|
680 |
+ if(inherits(x@ht_list[[i]], "Heatmap")) { |
|
681 |
+ nm = c(nm, x@ht_list[[i]]@name) |
|
682 |
+ } else { |
|
683 |
+ nm = c(nm, names(x@ht_list[[i]])) |
|
684 |
+ } |
|
685 |
+ } |
|
686 |
+ return(nm) |
|
687 |
+} |
|
688 |
+ |
|
689 |
+# == title |
|
690 |
+# Length of the HeatmapList object |
|
691 |
+# |
|
692 |
+# == param |
|
693 |
+# -x A `HeatmapList-class` object |
|
694 |
+# |
|
695 |
+length.HeatmapList = function(x) { |
|
696 |
+ length(x@ht_list) |
|
697 |
+} |
... | ... |
@@ -5,6 +5,14 @@ |
5 | 5 |
# == param |
6 | 6 |
# -object A `HeatmapList-class` object |
7 | 7 |
# |
8 |
+# == details |
|
9 |
+# This function adjust heatmap components for all heatmaps to align them nicely. |
|
10 |
+# |
|
11 |
+# This function is only for internal use. |
|
12 |
+# |
|
13 |
+# == author |
|
14 |
+# Zuguang Gu <z.gu@dkfz.de> |
|
15 |
+# |
|
8 | 16 |
setMethod(f = "adjust_heatmap_list", |
9 | 17 |
signature = "HeatmapList", |
10 | 18 |
definition = function(object) { |
... | ... |
@@ -6,7 +6,7 @@ |
6 | 6 |
# -object a `HeatmapList-class` object |
7 | 7 |
# |
8 | 8 |
# == value |
9 |
-# A list contains row orders which correspond to the original matrix |
|
9 |
+# The format of the returned object depends on whether rows/columns of the heatmaps are split. |
|
10 | 10 |
# |
11 | 11 |
# == author |
12 | 12 |
# Zuguang Gu <z.gu@dkfz.de> |
... | ... |
@@ -14,10 +14,13 @@ |
14 | 14 |
# == example |
15 | 15 |
# mat = matrix(rnorm(100), 10) |
16 | 16 |
# ht_list = Heatmap(mat) + Heatmap(mat) |
17 |
+# ht_list = draw(ht_list) |
|
17 | 18 |
# row_order(ht_list) |
18 | 19 |
# ht_list = Heatmap(mat, row_km = 2) + Heatmap(mat) |
20 |
+# ht_list = draw(ht_list) |
|
19 | 21 |
# row_order(ht_list) |
20 | 22 |
# ht_list = Heatmap(mat, row_km = 2) %v% Heatmap(mat) |
23 |
+# ht_list = draw(ht_list) |
|
21 | 24 |
# row_order(ht_list) |
22 | 25 |
setMethod(f = "row_order", |
23 | 26 |
signature = "HeatmapList", |
... | ... |
@@ -56,7 +59,7 @@ setMethod(f = "row_order", |
56 | 59 |
# -object a `Heatmap-class` object |
57 | 60 |
# |
58 | 61 |
# == value |
59 |
-# A list contains row orders which correspond to the original matrix |
|
62 |
+# The format of the returned object depends on whether rows/columns of the heatmaps are split. |
|
60 | 63 |
# |
61 | 64 |
# == author |
62 | 65 |
# Zuguang Gu <z.gu@dkfz.de> |
... | ... |
@@ -64,8 +67,10 @@ setMethod(f = "row_order", |
64 | 67 |
# == example |
65 | 68 |
# mat = matrix(rnorm(100), 10) |
66 | 69 |
# ht = Heatmap(mat) |
70 |
+# ht = draw(ht) |
|
67 | 71 |
# row_order(ht) |
68 | 72 |
# ht = Heatmap(mat, row_km = 2) |
73 |
+# ht = draw(ht) |
|
69 | 74 |
# row_order(ht) |
70 | 75 |
# |
71 | 76 |
setMethod(f = "row_order", |
... | ... |
@@ -89,7 +94,7 @@ setMethod(f = "row_order", |
89 | 94 |
# -object a `HeatmapList-class` object |
90 | 95 |
# |
91 | 96 |
# == value |
92 |
-# A list contains column orders which correspond every matrix |
|
97 |
+# The format of the returned object depends on whether rows/columns of the heatmaps are split. |
|
93 | 98 |
# |
94 | 99 |
# == author |
95 | 100 |
# Zuguang Gu <z.gu@dkfz.de> |
... | ... |
@@ -97,12 +102,16 @@ setMethod(f = "row_order", |
97 | 102 |
# == example |
98 | 103 |
# mat = matrix(rnorm(100), 10) |
99 | 104 |
# ht_list = Heatmap(mat) + Heatmap(mat) |
105 |
+# ht_list = draw(ht_list) |
|
100 | 106 |
# column_order(ht_list) |
101 | 107 |
# ht_list = Heatmap(mat, column_km = 2) + Heatmap(mat, column_km = 2) |
108 |
+# ht_list = draw(ht_list) |
|
102 | 109 |
# column_order(ht_list) |
103 | 110 |
# ht_list = Heatmap(mat) %v% Heatmap(mat) |
111 |
+# ht_list = draw(ht_list) |
|
104 | 112 |
# column_order(ht_list) |
105 | 113 |
# ht_list = Heatmap(mat, column_km = 2) %v% Heatmap(mat) |
114 |
+# ht_list = draw(ht_list) |
|
106 | 115 |
# column_order(ht_list) |
107 | 116 |
setMethod(f = "column_order", |
108 | 117 |
signature = "HeatmapList", |
... | ... |
@@ -141,7 +150,7 @@ setMethod(f = "column_order", |
141 | 150 |
# -object a `Heatmap-class` object |
142 | 151 |
# |
143 | 152 |
# == value |
144 |
-# A vector containing column orders |
|
153 |
+# The format of the returned object depends on whether rows/columns of the heatmaps are split. |
|
145 | 154 |
# |
146 | 155 |
# == author |
147 | 156 |
# Zuguang Gu <z.gu@dkfz.de> |
... | ... |
@@ -149,8 +158,10 @@ setMethod(f = "column_order", |
149 | 158 |
# == example |
150 | 159 |
# mat = matrix(rnorm(100), 10) |
151 | 160 |
# ht = Heatmap(mat) |
161 |
+# ht = draw(ht) |
|
152 | 162 |
# column_order(ht) |
153 | 163 |
# ht = Heatmap(mat, column_km = 2) |
164 |
+# ht = draw(ht) |
|
154 | 165 |
# column_order(ht) |
155 | 166 |
setMethod(f = "column_order", |
156 | 167 |
signature = "Heatmap", |
... | ... |
@@ -174,7 +185,7 @@ setMethod(f = "column_order", |
174 | 185 |
# -object a `HeatmapList-class` object |
175 | 186 |
# |
176 | 187 |
# == value |
177 |
-# A list of dendrograms for which each dendrogram corresponds to a row slice |
|
188 |
+# The format of the returned object depends on whether rows/columns of the heatmaps are split. |
|
178 | 189 |
# |
179 | 190 |
# == author |
180 | 191 |
# Zuguang Gu <z.gu@dkfz.de> |
... | ... |
@@ -182,10 +193,13 @@ setMethod(f = "column_order", |
182 | 193 |
# == example |
183 | 194 |
# mat = matrix(rnorm(100), 10) |
184 | 195 |
# ht_list = Heatmap(mat) + Heatmap(mat) |
196 |
+# ht_list = draw(ht_list) |
|
185 | 197 |
# row_dend(ht_list) |
186 | 198 |
# ht_list = Heatmap(mat, row_km = 2) + Heatmap(mat) |
199 |
+# ht_list = draw(ht_list) |
|
187 | 200 |
# row_dend(ht_list) |
188 | 201 |
# ht_list = Heatmap(mat, row_km = 2) %v% Heatmap(mat) |
202 |
+# ht_list = draw(ht_list) |
|
189 | 203 |
# row_dend(ht_list) |
190 | 204 |
setMethod(f = "row_dend", |
191 | 205 |
signature = "HeatmapList", |
... | ... |
@@ -225,7 +239,7 @@ setMethod(f = "row_dend", |
225 | 239 |
# -object a `Heatmap-class` object |
226 | 240 |
# |
227 | 241 |
# == value |
228 |
-# A list of dendrograms for which each dendrogram corresponds to a row slice |
|
242 |
+# The format of the returned object depends on whether rows/columns of the heatmaps are split. |
|
229 | 243 |
# |
230 | 244 |
# == author |
231 | 245 |
# Zuguang Gu <z.gu@dkfz.de> |
... | ... |
@@ -233,8 +247,10 @@ setMethod(f = "row_dend", |
233 | 247 |
# == example |
234 | 248 |
# mat = matrix(rnorm(100), 10) |
235 | 249 |
# ht = Heatmap(mat) |
250 |
+# ht = draw(ht) |
|
236 | 251 |
# row_dend(ht) |
237 | 252 |
# ht = Heatmap(mat, row_km = 2) |
253 |
+# ht = draw(ht) |
|
238 | 254 |
# row_dend(ht) |
239 | 255 |
# |
240 | 256 |
setMethod(f = "row_dend", |
... | ... |
@@ -258,7 +274,7 @@ setMethod(f = "row_dend", |
258 | 274 |
# -object a `HeatmapList-class` object |
259 | 275 |
# |
260 | 276 |
# == value |
261 |
-# A list of dendrograms for which dendrogram corresponds to each matrix |
|
277 |
+# The format of the returned object depends on whether rows/columns of the heatmaps are split. |
|
262 | 278 |
# |
263 | 279 |
# == author |
264 | 280 |
# Zuguang Gu <z.gu@dkfz.de> |
... | ... |
@@ -266,12 +282,16 @@ setMethod(f = "row_dend", |
266 | 282 |
# == example |
267 | 283 |
# mat = matrix(rnorm(100), 10) |
268 | 284 |
# ht_list = Heatmap(mat) + Heatmap(mat) |
285 |
+# ht_list = draw(ht_list) |
|
269 | 286 |
# column_dend(ht_list) |
270 | 287 |
# ht_list = Heatmap(mat, column_km = 2) + Heatmap(mat, column_km = 2) |
288 |
+# ht_list = draw(ht_list) |
|
271 | 289 |
# column_dend(ht_list) |
272 | 290 |
# ht_list = Heatmap(mat) %v% Heatmap(mat) |
291 |
+# ht_list = draw(ht_list) |
|
273 | 292 |
# column_dend(ht_list) |
274 | 293 |
# ht_list = Heatmap(mat, column_km = 2) %v% Heatmap(mat) |
294 |
+# ht_list = draw(ht_list) |
|
275 | 295 |
# column_dend(ht_list) |
276 | 296 |
setMethod(f = "column_dend", |
277 | 297 |
signature = "HeatmapList", |
... | ... |
@@ -311,7 +331,7 @@ setMethod(f = "column_dend", |
311 | 331 |
# -object a `Heatmap-class` object |
312 | 332 |
# |
313 | 333 |
# == value |
314 |
-# A dendrogram object |
|
334 |
+# The format of the returned object depends on whether rows/columns of the heatmaps are split. |
|
315 | 335 |
# |
316 | 336 |
# == author |
317 | 337 |
# Zuguang Gu <z.gu@dkfz.de> |
... | ... |
@@ -319,8 +339,10 @@ setMethod(f = "column_dend", |
319 | 339 |
# == example |
320 | 340 |
# mat = matrix(rnorm(100), 10) |
321 | 341 |
# ht = Heatmap(mat) |
342 |
+# ht = draw(ht) |
|
322 | 343 |
# column_dend(ht) |
323 | 344 |
# ht = Heatmap(mat, column_km = 2) |
345 |
+# ht = draw(ht) |
|
324 | 346 |
# column_dend(ht) |
325 | 347 |
# |
326 | 348 |
setMethod(f = "column_dend", |
... | ... |
@@ -35,7 +35,8 @@ |
35 | 35 |
# -row_order same setting as in `Heatmap`, if it is specified, ``row_order`` in main heatmap is ignored. |
36 | 36 |
# -row_km row km |
37 | 37 |
# -row_split row split |
38 |
-# -heatmap_body_height heatmap body height |
|
38 |
+# -height height of the heatmap body |
|
39 |
+# -heatmap_height height of the complete heatmap |
|
39 | 40 |
# -column_gap column gap |
40 | 41 |
# -cluster_columns cluster columns |
41 | 42 |
# -clustering_distance_columns clustering distance columns |
... | ... |
@@ -47,12 +48,15 @@ |
47 | 48 |
# -column_order column order |
48 | 49 |
# -column_km column km |
49 | 50 |
# -column_split column split |
50 |
-# -heatmap_body_width heatmap bpdy widht |
|
51 |
+# -width width of the heatmap body |
|
52 |
+# -heatmap_width width of the complete heatmap |
|
51 | 53 |
# |
52 | 54 |
# == detail |
53 |
-# It sets the size of each component of the heatmap list and adjusts graphic parameters for each heatmap if necessary. |
|
55 |
+# It sets the size of each component of the heatmap list and adjusts graphic |
|
56 |
+# parameters for each heatmap if necessary. |
|
54 | 57 |
# |
55 |
-# The layout for the heatmap list and layout for each heatmap are calculated when drawing the heatmap list. |
|
58 |
+# The layout for the heatmap list and layout for each heatmap are calculated |
|
59 |
+# when drawing the heatmap list. |
|
56 | 60 |
# |
57 | 61 |
# This function is only for internal use. |
58 | 62 |
# |
... | ... |
@@ -188,7 +188,7 @@ SingleAnnotation = function(name, value, col, fun, |
188 | 188 |
.Object@name = name |
189 | 189 |
|
190 | 190 |
if(!name_rot %in% c(0, 90, 180, 270)) { |
191 |
- stop_wrap("@{name}: `name_rot` can only take values in c(0, 90, 180, 270)") |
|
191 |
+ stop_wrap(qq("@{name}: `name_rot` can only take values in c(0, 90, 180, 270)")) |
|
192 | 192 |
} |
193 | 193 |
|
194 | 194 |
if(verbose) qqcat("create a SingleAnnotation with name '@{name}'\n") |
... | ... |
@@ -243,7 +243,7 @@ SingleAnnotation = function(name, value, col, fun, |
243 | 243 |
if(which == "column") { |
244 | 244 |
if(verbose) qqcat("@{name}: it is a column annotation\n") |
245 | 245 |
if(!name_side %in% c("left", "right")) { |
246 |
- stop_wrap("@{name}: `name_side` should be 'left' or 'right' when it is a column annotation.") |
|
246 |
+ stop_wrap(qq("@{name}: `name_side` should be 'left' or 'right' when it is a column annotation.")) |
|
247 | 247 |
} |
248 | 248 |
if(verbose) qqcat("@{name}: adjust positions of annotation names\n") |