Browse code

update

Zuguang Gu authored on 02/11/2018 07:57:06
Showing7 changed files

... ...
@@ -243,7 +243,7 @@ HeatmapAnnotation = function(...,
243 243
     an = names(anno_value_list)
244 244
     show_annotation_name = recycle_param(show_annotation_name, an, TRUE)
245 245
     annotation_name_side = recycle_param(annotation_name_side, an, ifelse(which == "column", "right", "bottom"))
246
-    if(inherits(annotation_name_offset, "unit")) annotation_name_offset = unit_to_str(annotation_name_offset)
246
+    if(inherits(annotation_name_offset, "unit")) annotation_name_offset = to_unit_str(annotation_name_offset)
247 247
     annotation_name_offset = recycle_param(annotation_name_offset, an, NULL, as.list = TRUE)
248 248
     annotation_name_rot = recycle_param(annotation_name_rot, an, NULL, as.list = TRUE)
249 249
     if(missing(border)) {
... ...
@@ -156,7 +156,7 @@ densityHeatmap = function(data,
156 156
 
157 157
 	bb = grid.pretty(c(min_x, max_x))
158 158
 	ht = Heatmap(mat, col = col, name = "density", 
159
-		column_title = column_title,
159
+		column_title = title,
160 160
 		column_title_gp = title_gp,
161 161
 		cluster_rows = FALSE, 
162 162
 		cluster_columns = cluster_columns,
... ...
@@ -362,10 +362,10 @@ oncoPrint = function(mat,
362 362
 			left_annotation = left_annotation[l_non_empty_row, ]
363 363
 		}
364 364
 		if(pct_side == "left") {
365
-			left_annotation = c(left_annotation, pct_ha)
365
+			left_annotation = c(left_annotation, pct_ha, gap = unit(1, "mm"))
366 366
 		}
367 367
 		if(row_names_side == "left") {
368
-			left_annotation = c(left_annotation, rn_ha)
368
+			left_annotation = c(left_annotation, rn_ha, gap = unit(1, "mm"))
369 369
 		}
370 370
 	}
371 371
 
... ...
@@ -381,10 +381,10 @@ oncoPrint = function(mat,
381 381
 			right_annotation = right_annotation[l_non_empty_row, ]
382 382
 		}
383 383
 		if(pct_side == "right") {
384
-			if(!is.null(pct_ha)) right_annotation = c(pct_ha, right_annotation)
384
+			if(!is.null(pct_ha)) right_annotation = c(pct_ha, right_annotation, gap = unit(1, "mm"))
385 385
 		}
386 386
 		if(row_names_side == "right") {
387
-			if(!is.null(rn_ha)) right_annotation = c(rn_ha, right_annotation)
387
+			if(!is.null(rn_ha)) right_annotation = c(rn_ha, right_annotation, gap = unit(1, "mm"))
388 388
 		}
389 389
 	}
390 390
 	if(remove_empty_columns) {
... ...
@@ -163,7 +163,7 @@ get_dist = function(matrix, method) {
163 163
         } else if(nargs == 3) {
164 164
             dst = dist2(matrix, method)
165 165
         } else {
166
-            stop_wrap("Since your distance method is a funciton, it can only accept one or two arguments.")
166
+            stop_wrap("Since your distance method is a function, it can only accept one or two arguments.")
167 167
         }
168 168
     } else if(method %in% c("euclidean", "maximum", "manhattan", "canberra", "binary", "minkowski")) {
169 169
         # if(any(is.na(matrix))) {
... ...
@@ -532,7 +532,7 @@ recycle_param = function(x, all_names, default, as.list = FALSE) {
532 532
         }
533 533
     } else if(length(x) == n) {
534 534
         if(as.list) {
535
-            x = lapply(1:n, x[i])
535
+            x = lapply(1:n, function(i) x[i])
536 536
         }
537 537
         return(x)
538 538
     } else {
... ...
@@ -543,7 +543,7 @@ recycle_param = function(x, all_names, default, as.list = FALSE) {
543 543
         if(is.null(nm)) {
544 544
             if(length(x) == 1) {
545 545
                 if(as.list) {
546
-                    x = lapply(1:n , function(x) x)
546
+                    x = rep(list(x), n)
547 547
                 } else {
548 548
                     x = rep(x, n)
549 549
                 }
... ...
@@ -551,7 +551,7 @@ recycle_param = function(x, all_names, default, as.list = FALSE) {
551 551
                 if(length(x) > n) {
552 552
                     x = x[1:n]
553 553
                     if(as.list) {
554
-                        x = lapply(1:n, x[i])
554
+                        x = lapply(1:n, function(i) x[i])
555 555
                     }
556 556
                 } else {
557 557
                     if(as.list) {
... ...
@@ -18,9 +18,9 @@ HeatmapAnnotation(...,
18 18
     
19 19
     show_annotation_name = TRUE,
20 20
     annotation_name_gp = gpar(),
21
-    annotation_name_offset = unit(1, "mm"),
21
+    annotation_name_offset = NULL,
22 22
     annotation_name_side = ifelse(which == "column", "right", "bottom"),
23
-    annotation_name_rot = ifelse(which == "column", 0, 90),
23
+    annotation_name_rot = NULL,
24 24
     
25 25
     annotation_height = NULL,
26 26
     annotation_width = NULL,
... ...
@@ -16,9 +16,9 @@ SingleAnnotation(name, value, col, fun,
16 16
     legend_param = list(),
17 17
     show_name = TRUE,
18 18
     name_gp = gpar(fontsize = 12),
19
-    name_offset = unit(1, "mm"),
19
+    name_offset = NULL,
20 20
     name_side = ifelse(which == "column", "right", "bottom"),
21
-    name_rot = ifelse(which == "column", 0, 90),
21
+    name_rot = NULL,
22 22
     anno_simple_size = ht_opt$anno_simple_size,
23 23
     width = NULL, height = NULL)
24 24
 }
... ...
@@ -32,8 +32,22 @@ For retrieving orders and dendrograms from a list of heatmaps. See https://joker
32 32
 
33 33
 ### How should I control the height or width of the heatmap annotations?
34 34
 
35
+For complex annotations generated by `anno_*()` functions, width or height should be set inside 
36
+the `anno_*()` function, such as `anno_points(..., height = ...)`. The size of simple annotations
37
+is controlled by `anno_simple_size`. The `width`/`height` and `annotation_width`/`annotation_height`
38
+are used to adjust the size for multiple annotations which are put in one `HeatmapAnnotation` object.
39
+See https://jokergoo.github.io/ComplexHeatmap-reference/book/heatmap-annotations.html#multiple-annotations
40
+
35 41
 ### How should I control the axes of the annotations?
36 42
 
43
+In the annotation functions `anno_*()`, the argument `axis_param` can be used to set the axes. The value
44
+should be a list and the default settings for axis can be get by:
45
+
46
+```{r, eval = FALSE}
47
+default_axis_param("column")
48
+default_axis_param("row")
49
+```
50
+
37 51
 ### How to control the style of legends?
38 52
 
39 53
 The style of legends can be controlled by `heatmap_legend_param` in `Heatmap()`, or