... | ... |
@@ -7,6 +7,7 @@ CHANGES in VERSION 1.13.1 |
7 | 7 |
* `HeatmapAnnotation()`: gaps are included in the size of the annotations |
8 | 8 |
* `anno_link()`: graphic parameters are correctly reordered |
9 | 9 |
* `densityHeatmap()`: viewport is created with `clip = TRUE` |
10 |
+* `decorate_*()`: add `envir` option to control where to look for variables inside `code` |
|
10 | 11 |
|
11 | 12 |
======================== |
12 | 13 |
|
... | ... |
@@ -5,6 +5,7 @@ |
5 | 5 |
# -heatmap name of the heatmap which is set as ``name`` option in `Heatmap` function |
6 | 6 |
# -code code that adds graphics in the selected heatmap body |
7 | 7 |
# -slice index of row slices in the heatmap if it is split by rows |
8 |
+# -envir where to look for variables inside ``code`` |
|
8 | 9 |
# |
9 | 10 |
# == details |
10 | 11 |
# There is a viewport for each row slice in each heatmap. |
... | ... |
@@ -41,7 +42,7 @@ |
41 | 42 |
# grid.circle(gp = gpar(fill = "#FF000080")) |
42 | 43 |
# }) |
43 | 44 |
# |
44 |
-decorate_heatmap_body = function(heatmap, code, slice = 1) { |
|
45 |
+decorate_heatmap_body = function(heatmap, code, slice = 1, envir = new.env(parent = parent.frame())) { |
|
45 | 46 |
|
46 | 47 |
if(is.null(slice)) { |
47 | 48 |
vp_name = paste0(heatmap, "_heatmap_body_", 1) |
... | ... |
@@ -52,8 +53,7 @@ decorate_heatmap_body = function(heatmap, code, slice = 1) { |
52 | 53 |
seekViewport(vp_name) |
53 | 54 |
} |
54 | 55 |
|
55 |
- e = new.env(parent = parent.frame()) |
|
56 |
- eval(substitute(code), envir = e) |
|
56 |
+ eval(substitute(code), envir = envir) |
|
57 | 57 |
|
58 | 58 |
seekViewport("global") |
59 | 59 |
} |
... | ... |
@@ -66,6 +66,7 @@ decorate_heatmap_body = function(heatmap, code, slice = 1) { |
66 | 66 |
# -code code that adds graphics in the selected heatmap body |
67 | 67 |
# -slice index of row slices in the heatmap |
68 | 68 |
# -which on rows or on columns? |
69 |
+# -envir where to look for variables inside ``code`` |
|
69 | 70 |
# |
70 | 71 |
# == details |
71 | 72 |
# There is a viewport for each dendrogram in the heatmap. |
... | ... |
@@ -94,7 +95,8 @@ decorate_heatmap_body = function(heatmap, code, slice = 1) { |
94 | 95 |
# grid.rect(gp = gpar(fill = "#FF000080")) |
95 | 96 |
# }, which = "row", slice = 2) |
96 | 97 |
# |
97 |
-decorate_dend = function(heatmap, code, slice = 1, which = c("column", "row")) { |
|
98 |
+decorate_dend = function(heatmap, code, slice = 1, which = c("column", "row"), |
|
99 |
+ envir = new.env(parent = parent.frame())) { |
|
98 | 100 |
|
99 | 101 |
which = match.arg(which)[1] |
100 | 102 |
if(which == "column") { |
... | ... |
@@ -122,6 +124,7 @@ decorate_dend = function(heatmap, code, slice = 1, which = c("column", "row")) { |
122 | 124 |
# |
123 | 125 |
# == param |
124 | 126 |
# -... pass to `decorate_dend` |
127 |
+# -envir where to look for variables inside ``code`` |
|
125 | 128 |
# |
126 | 129 |
# == details |
127 | 130 |
# This is a wrapper function which pre-defined ``which`` argument in `decorate_dend`. |
... | ... |
@@ -136,8 +139,8 @@ decorate_dend = function(heatmap, code, slice = 1, which = c("column", "row")) { |
136 | 139 |
# # No example for this function |
137 | 140 |
# NULL |
138 | 141 |
# |
139 |
-decorate_column_dend = function(...) { |
|
140 |
- decorate_dend(..., which = "column") |
|
142 |
+decorate_column_dend = function(..., envir = new.env(parent = parent.frame())) { |
|
143 |
+ decorate_dend(..., which = "column", envir = envir) |
|
141 | 144 |
} |
142 | 145 |
|
143 | 146 |
# == title |
... | ... |
@@ -145,6 +148,7 @@ decorate_column_dend = function(...) { |
145 | 148 |
# |
146 | 149 |
# == param |
147 | 150 |
# -... pass to `decorate_dend` |
151 |
+# -envir where to look for variables inside ``code`` |
|
148 | 152 |
# |
149 | 153 |
# == details |
150 | 154 |
# This is a helper function which pre-defined ``which`` argument in `decorate_dend`. |
... | ... |
@@ -159,8 +163,8 @@ decorate_column_dend = function(...) { |
159 | 163 |
# # No example for this function |
160 | 164 |
# NULL |
161 | 165 |
# |
162 |
-decorate_row_dend = function(...) { |
|
163 |
- decorate_dend(..., which = "row") |
|
166 |
+decorate_row_dend = function(..., envir = new.env(parent = parent.frame())) { |
|
167 |
+ decorate_dend(..., which = "row", envir = envir) |
|
164 | 168 |
} |
165 | 169 |
|
166 | 170 |
|
... | ... |
@@ -172,6 +176,7 @@ decorate_row_dend = function(...) { |
172 | 176 |
# -code code that adds graphics in the selected heatmap body |
173 | 177 |
# -slice index of row slices in the heatmap |
174 | 178 |
# -which on rows or on columns? |
179 |
+# -envir where to look for variables inside ``code`` |
|
175 | 180 |
# |
176 | 181 |
# == details |
177 | 182 |
# There is a viewport for row names and column names in the heatmap. |
... | ... |
@@ -204,7 +209,8 @@ decorate_row_dend = function(...) { |
204 | 209 |
# grid.rect(gp = gpar(fill = "#FF000080")) |
205 | 210 |
# }, which = "row", slice = 2) |
206 | 211 |
# |
207 |
-decorate_dimnames = function(heatmap, code, slice = 1, which = c("column", "row")) { |
|
212 |
+decorate_dimnames = function(heatmap, code, slice = 1, which = c("column", "row"), |
|
213 |
+ envir = new.env(parent = parent.frame())) { |
|
208 | 214 |
|
209 | 215 |
which = match.arg(which)[1] |
210 | 216 |
if(which == "column") { |
... | ... |
@@ -221,8 +227,7 @@ decorate_dimnames = function(heatmap, code, slice = 1, which = c("column", "row" |
221 | 227 |
} |
222 | 228 |
|
223 | 229 |
seekViewport(vp_name) |
224 |
- e = new.env(parent = parent.frame()) |
|
225 |
- eval(substitute(code), envir = e) |
|
230 |
+ eval(substitute(code), envir = envir) |
|
226 | 231 |
seekViewport("global") |
227 | 232 |
} |
228 | 233 |
|
... | ... |
@@ -231,6 +236,7 @@ decorate_dimnames = function(heatmap, code, slice = 1, which = c("column", "row" |
231 | 236 |
# |
232 | 237 |
# == param |
233 | 238 |
# -... pass to `decorate_dimnames` |
239 |
+# -envir where to look for variables inside ``code`` |
|
234 | 240 |
# |
235 | 241 |
# == details |
236 | 242 |
# This is a helper function which pre-defined ``which`` argument in `decorate_dimnames`. |
... | ... |
@@ -245,8 +251,8 @@ decorate_dimnames = function(heatmap, code, slice = 1, which = c("column", "row" |
245 | 251 |
# # No example for this function |
246 | 252 |
# NULL |
247 | 253 |
# |
248 |
-decorate_row_names = function(...) { |
|
249 |
- decorate_dimnames(..., which = "row") |
|
254 |
+decorate_row_names = function(..., envir = new.env(parent = parent.frame())) { |
|
255 |
+ decorate_dimnames(..., which = "row", envir = envir) |
|
250 | 256 |
} |
251 | 257 |
|
252 | 258 |
# == title |
... | ... |
@@ -254,6 +260,7 @@ decorate_row_names = function(...) { |
254 | 260 |
# |
255 | 261 |
# == param |
256 | 262 |
# -... pass to `decorate_dimnames` |
263 |
+# -envir where to look for variables inside ``code`` |
|
257 | 264 |
# |
258 | 265 |
# == details |
259 | 266 |
# This is a helper function which pre-defined ``which`` argument in `decorate_dimnames`. |
... | ... |
@@ -268,8 +275,8 @@ decorate_row_names = function(...) { |
268 | 275 |
# # No example for this function |
269 | 276 |
# NULL |
270 | 277 |
# |
271 |
-decorate_column_names = function(...) { |
|
272 |
- decorate_dimnames(..., which = "column") |
|
278 |
+decorate_column_names = function(..., envir = new.env(parent = parent.frame())) { |
|
279 |
+ decorate_dimnames(..., which = "column", envir = envir) |
|
273 | 280 |
} |
274 | 281 |
|
275 | 282 |
|
... | ... |
@@ -281,6 +288,7 @@ decorate_column_names = function(...) { |
281 | 288 |
# -code code that adds graphics in the selected heatmap body |
282 | 289 |
# -slice index of row slices in the heatmap |
283 | 290 |
# -which on rows or on columns? |
291 |
+# -envir where to look for variables inside ``code`` |
|
284 | 292 |
# |
285 | 293 |
# == details |
286 | 294 |
# There is a viewport for row titles and column title in the heatmap. |
... | ... |
@@ -301,7 +309,8 @@ decorate_column_names = function(...) { |
301 | 309 |
# grid.rect(gp = gpar(fill = "#FF000080")) |
302 | 310 |
# }, which = "row", slice = 2) |
303 | 311 |
# |
304 |
-decorate_title = function(heatmap, code, slice = 1, which = c("column", "row")) { |
|
312 |
+decorate_title = function(heatmap, code, slice = 1, which = c("column", "row"), |
|
313 |
+ envir = new.env(parent = parent.frame())) { |
|
305 | 314 |
|
306 | 315 |
which = match.arg(which)[1] |
307 | 316 |
if(which == "column") { |
... | ... |
@@ -318,8 +327,7 @@ decorate_title = function(heatmap, code, slice = 1, which = c("column", "row")) |
318 | 327 |
} |
319 | 328 |
|
320 | 329 |
seekViewport(vp_name) |
321 |
- e = new.env(parent = parent.frame()) |
|
322 |
- eval(substitute(code), envir = e) |
|
330 |
+ eval(substitute(code), envir = envir) |
|
323 | 331 |
seekViewport("global") |
324 | 332 |
} |
325 | 333 |
|
... | ... |
@@ -328,6 +336,7 @@ decorate_title = function(heatmap, code, slice = 1, which = c("column", "row")) |
328 | 336 |
# |
329 | 337 |
# == param |
330 | 338 |
# -... pass to `decorate_title` |
339 |
+# -envir where to look for variables inside ``code`` |
|
331 | 340 |
# |
332 | 341 |
# == details |
333 | 342 |
# This is a helper function which pre-defined ``which`` argument in `decorate_title`. |
... | ... |
@@ -342,8 +351,8 @@ decorate_title = function(heatmap, code, slice = 1, which = c("column", "row")) |
342 | 351 |
# # No example for this function |
343 | 352 |
# NULL |
344 | 353 |
# |
345 |
-decorate_row_title = function(...) { |
|
346 |
- decorate_title(..., which = "row") |
|
354 |
+decorate_row_title = function(..., envir = new.env(parent = parent.frame())) { |
|
355 |
+ decorate_title(..., which = "row", envir = envir) |
|
347 | 356 |
} |
348 | 357 |
|
349 | 358 |
# == title |
... | ... |
@@ -351,6 +360,7 @@ decorate_row_title = function(...) { |
351 | 360 |
# |
352 | 361 |
# == param |
353 | 362 |
# -... pass to `decorate_title` |
363 |
+# -envir where to look for variables inside ``code`` |
|
354 | 364 |
# |
355 | 365 |
# == details |
356 | 366 |
# This is a helper function which pre-defined ``which`` argument in `decorate_title`. |
... | ... |
@@ -365,8 +375,8 @@ decorate_row_title = function(...) { |
365 | 375 |
# # No example for this function |
366 | 376 |
# NULL |
367 | 377 |
# |
368 |
-decorate_column_title = function(...) { |
|
369 |
- decorate_title(..., which = "column") |
|
378 |
+decorate_column_title = function(..., envir = new.env(parent = parent.frame())) { |
|
379 |
+ decorate_title(..., which = "column", envir = envir) |
|
370 | 380 |
} |
371 | 381 |
|
372 | 382 |
# == title |
... | ... |
@@ -376,6 +386,7 @@ decorate_column_title = function(...) { |
376 | 386 |
# -annotation name of the annotation |
377 | 387 |
# -code code that adds graphics in the selected heatmap body |
378 | 388 |
# -slice index of row slices in the heatmap |
389 |
+# -envir where to look for variables inside ``code`` |
|
379 | 390 |
# |
380 | 391 |
# == details |
381 | 392 |
# There is a viewport for every column annotation and row annotation. |
... | ... |
@@ -403,7 +414,7 @@ decorate_column_title = function(...) { |
403 | 414 |
# grid.rect(gp = gpar(fill = "#FF000080")) |
404 | 415 |
# }, slice = 2) |
405 | 416 |
# |
406 |
-decorate_annotation = function(annotation, code, slice) { |
|
417 |
+decorate_annotation = function(annotation, code, slice, envir = new.env(parent = parent.frame())) { |
|
407 | 418 |
|
408 | 419 |
if(missing(slice)) { |
409 | 420 |
vp_name = paste0("annotation_", annotation) |
... | ... |
@@ -428,8 +439,7 @@ decorate_annotation = function(annotation, code, slice) { |
428 | 439 |
} |
429 | 440 |
} |
430 | 441 |
|
431 |
- e = new.env(parent = parent.frame()) |
|
432 |
- eval(substitute(code), envir = e) |
|
442 |
+ eval(substitute(code), envir = envir) |
|
433 | 443 |
seekViewport("global") |
434 | 444 |
} |
435 | 445 |
|
... | ... |
@@ -7,13 +7,14 @@ Decorate the heatmap annotation |
7 | 7 |
Decorate the heatmap annotation |
8 | 8 |
} |
9 | 9 |
\usage{ |
10 |
-decorate_annotation(annotation, code, slice) |
|
10 |
+decorate_annotation(annotation, code, slice, envir = new.env(parent = parent.frame())) |
|
11 | 11 |
} |
12 | 12 |
\arguments{ |
13 | 13 |
|
14 | 14 |
\item{annotation}{name of the annotation} |
15 | 15 |
\item{code}{code that adds graphics in the selected heatmap body} |
16 | 16 |
\item{slice}{index of row slices in the heatmap} |
17 |
+ \item{envir}{where to look for variables inside \code{code}} |
|
17 | 18 |
|
18 | 19 |
} |
19 | 20 |
\details{ |
... | ... |
@@ -7,11 +7,12 @@ Decorate heatmap dendrogram on columns |
7 | 7 |
Decorate heatmap dendrogram on columns |
8 | 8 |
} |
9 | 9 |
\usage{ |
10 |
-decorate_column_dend(...) |
|
10 |
+decorate_column_dend(..., envir = new.env(parent = parent.frame())) |
|
11 | 11 |
} |
12 | 12 |
\arguments{ |
13 | 13 |
|
14 | 14 |
\item{...}{pass to \code{\link{decorate_dend}}} |
15 |
+ \item{envir}{where to look for variables inside \code{code}} |
|
15 | 16 |
|
16 | 17 |
} |
17 | 18 |
\details{ |
... | ... |
@@ -7,11 +7,12 @@ Decorate heatmap column names |
7 | 7 |
Decorate heatmap column names |
8 | 8 |
} |
9 | 9 |
\usage{ |
10 |
-decorate_column_names(...) |
|
10 |
+decorate_column_names(..., envir = new.env(parent = parent.frame())) |
|
11 | 11 |
} |
12 | 12 |
\arguments{ |
13 | 13 |
|
14 | 14 |
\item{...}{pass to \code{\link{decorate_dimnames}}} |
15 |
+ \item{envir}{where to look for variables inside \code{code}} |
|
15 | 16 |
|
16 | 17 |
} |
17 | 18 |
\details{ |
... | ... |
@@ -7,11 +7,12 @@ Decorate heatmap column title |
7 | 7 |
Decorate heatmap column title |
8 | 8 |
} |
9 | 9 |
\usage{ |
10 |
-decorate_column_title(...) |
|
10 |
+decorate_column_title(..., envir = new.env(parent = parent.frame())) |
|
11 | 11 |
} |
12 | 12 |
\arguments{ |
13 | 13 |
|
14 | 14 |
\item{...}{pass to \code{\link{decorate_title}}} |
15 |
+ \item{envir}{where to look for variables inside \code{code}} |
|
15 | 16 |
|
16 | 17 |
} |
17 | 18 |
\details{ |
... | ... |
@@ -7,7 +7,8 @@ Decorate the heatmap dendrogram |
7 | 7 |
Decorate the heatmap dendrogram |
8 | 8 |
} |
9 | 9 |
\usage{ |
10 |
-decorate_dend(heatmap, code, slice = 1, which = c("column", "row")) |
|
10 |
+decorate_dend(heatmap, code, slice = 1, which = c("column", "row"), |
|
11 |
+ envir = new.env(parent = parent.frame())) |
|
11 | 12 |
} |
12 | 13 |
\arguments{ |
13 | 14 |
|
... | ... |
@@ -15,6 +16,7 @@ decorate_dend(heatmap, code, slice = 1, which = c("column", "row")) |
15 | 16 |
\item{code}{code that adds graphics in the selected heatmap body} |
16 | 17 |
\item{slice}{index of row slices in the heatmap} |
17 | 18 |
\item{which}{on rows or on columns?} |
19 |
+ \item{envir}{where to look for variables inside \code{code}} |
|
18 | 20 |
|
19 | 21 |
} |
20 | 22 |
\details{ |
... | ... |
@@ -7,7 +7,8 @@ Decorate the heatmap dimension names |
7 | 7 |
Decorate the heatmap dimension names |
8 | 8 |
} |
9 | 9 |
\usage{ |
10 |
-decorate_dimnames(heatmap, code, slice = 1, which = c("column", "row")) |
|
10 |
+decorate_dimnames(heatmap, code, slice = 1, which = c("column", "row"), |
|
11 |
+ envir = new.env(parent = parent.frame())) |
|
11 | 12 |
} |
12 | 13 |
\arguments{ |
13 | 14 |
|
... | ... |
@@ -15,6 +16,7 @@ decorate_dimnames(heatmap, code, slice = 1, which = c("column", "row")) |
15 | 16 |
\item{code}{code that adds graphics in the selected heatmap body} |
16 | 17 |
\item{slice}{index of row slices in the heatmap} |
17 | 18 |
\item{which}{on rows or on columns?} |
19 |
+ \item{envir}{where to look for variables inside \code{code}} |
|
18 | 20 |
|
19 | 21 |
} |
20 | 22 |
\details{ |
... | ... |
@@ -7,13 +7,14 @@ Decorate the heatmap body |
7 | 7 |
Decorate the heatmap body |
8 | 8 |
} |
9 | 9 |
\usage{ |
10 |
-decorate_heatmap_body(heatmap, code, slice = 1) |
|
10 |
+decorate_heatmap_body(heatmap, code, slice = 1, envir = new.env(parent = parent.frame())) |
|
11 | 11 |
} |
12 | 12 |
\arguments{ |
13 | 13 |
|
14 | 14 |
\item{heatmap}{name of the heatmap which is set as \code{name} option in \code{\link{Heatmap}} function} |
15 | 15 |
\item{code}{code that adds graphics in the selected heatmap body} |
16 | 16 |
\item{slice}{index of row slices in the heatmap if it is split by rows} |
17 |
+ \item{envir}{where to look for variables inside \code{code}} |
|
17 | 18 |
|
18 | 19 |
} |
19 | 20 |
\details{ |
... | ... |
@@ -7,11 +7,12 @@ Decorate heatmap dendrogram on rows |
7 | 7 |
Decorate heatmap dendrogram on rows |
8 | 8 |
} |
9 | 9 |
\usage{ |
10 |
-decorate_row_dend(...) |
|
10 |
+decorate_row_dend(..., envir = new.env(parent = parent.frame())) |
|
11 | 11 |
} |
12 | 12 |
\arguments{ |
13 | 13 |
|
14 | 14 |
\item{...}{pass to \code{\link{decorate_dend}}} |
15 |
+ \item{envir}{where to look for variables inside \code{code}} |
|
15 | 16 |
|
16 | 17 |
} |
17 | 18 |
\details{ |
... | ... |
@@ -7,11 +7,12 @@ Decorate heatmap row names |
7 | 7 |
Decorate heatmap row names |
8 | 8 |
} |
9 | 9 |
\usage{ |
10 |
-decorate_row_names(...) |
|
10 |
+decorate_row_names(..., envir = new.env(parent = parent.frame())) |
|
11 | 11 |
} |
12 | 12 |
\arguments{ |
13 | 13 |
|
14 | 14 |
\item{...}{pass to \code{\link{decorate_dimnames}}} |
15 |
+ \item{envir}{where to look for variables inside \code{code}} |
|
15 | 16 |
|
16 | 17 |
} |
17 | 18 |
\details{ |
... | ... |
@@ -7,11 +7,12 @@ Decorate heatmap row title |
7 | 7 |
Decorate heatmap row title |
8 | 8 |
} |
9 | 9 |
\usage{ |
10 |
-decorate_row_title(...) |
|
10 |
+decorate_row_title(..., envir = new.env(parent = parent.frame())) |
|
11 | 11 |
} |
12 | 12 |
\arguments{ |
13 | 13 |
|
14 | 14 |
\item{...}{pass to \code{\link{decorate_title}}} |
15 |
+ \item{envir}{where to look for variables inside \code{code}} |
|
15 | 16 |
|
16 | 17 |
} |
17 | 18 |
\details{ |
... | ... |
@@ -7,7 +7,8 @@ Decorate the heatmap title |
7 | 7 |
Decorate the heatmap title |
8 | 8 |
} |
9 | 9 |
\usage{ |
10 |
-decorate_title(heatmap, code, slice = 1, which = c("column", "row")) |
|
10 |
+decorate_title(heatmap, code, slice = 1, which = c("column", "row"), |
|
11 |
+ envir = new.env(parent = parent.frame())) |
|
11 | 12 |
} |
12 | 13 |
\arguments{ |
13 | 14 |
|
... | ... |
@@ -15,6 +16,7 @@ decorate_title(heatmap, code, slice = 1, which = c("column", "row")) |
15 | 16 |
\item{code}{code that adds graphics in the selected heatmap body} |
16 | 17 |
\item{slice}{index of row slices in the heatmap} |
17 | 18 |
\item{which}{on rows or on columns?} |
19 |
+ \item{envir}{where to look for variables inside \code{code}} |
|
18 | 20 |
|
19 | 21 |
} |
20 | 22 |
\details{ |