Browse code

add numbers to the barplot annotations

Zuguang Gu authored on 03/08/2021 12:22:45
Showing19 changed files

... ...
@@ -221,6 +221,7 @@ export("subset_matrix_by_row")
221 221
 export("subset_vector")
222 222
 export("test_alter_fun")
223 223
 export("unify_mat_list")
224
+export("upset_left_annotation")
224 225
 export("upset_right_annotation")
225 226
 export("upset_top_annotation")
226 227
 exportClasses("AdditiveUnit")
... ...
@@ -7,6 +7,7 @@ CHANGES in VERSION 2.9.3
7 7
 * legends: fixed a bug of the grid heights were not correctedly calculated.
8 8
 * discrete annotations: neighbour grids are merged into one single grid if they have the 
9 9
   same values.
10
+* `anno_barplot()`: allows to add numbers on top of bars.
10 11
 
11 12
 =========================
12 13
 
... ...
@@ -1,32 +1,32 @@
1
-setGeneric('draw_title', function(object, ...) standardGeneric('draw_title'))
2
-setGeneric('annotation_legend_size', function(object, ...) standardGeneric('annotation_legend_size'))
3
-setGeneric('attach_annotation', function(object, ...) standardGeneric('attach_annotation'))
4
-setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend'))
5
-setGeneric('draw_dend', function(object, ...) standardGeneric('draw_dend'))
1
+setGeneric('add_heatmap', function(object, ...) standardGeneric('add_heatmap'))
2
+setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames'))
3
+setGeneric('component_height', function(object, ...) standardGeneric('component_height'))
4
+setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend'))
5
+setGeneric('make_layout', function(object, ...) standardGeneric('make_layout'))
6
+setGeneric('row_order', function(object, ...) standardGeneric('row_order'))
7
+setGeneric('re_size', function(object, ...) standardGeneric('re_size'))
8
+setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list'))
6 9
 setGeneric('column_dend', function(object, ...) standardGeneric('column_dend'))
10
+setGeneric('draw_title', function(object, ...) standardGeneric('draw_title'))
11
+setGeneric('set_component_width', function(object, ...) standardGeneric('set_component_width'))
7 12
 setGeneric('map_to_colors', function(object, ...) standardGeneric('map_to_colors'))
8
-setGeneric('make_layout', function(object, ...) standardGeneric('make_layout'))
9 13
 setGeneric('row_dend', function(object, ...) standardGeneric('row_dend'))
10
-setGeneric('add_heatmap', function(object, ...) standardGeneric('add_heatmap'))
11
-setGeneric('component_height', function(object, ...) standardGeneric('component_height'))
12
-setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size'))
14
+setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster'))
15
+setGeneric('draw_heatmap_body', function(object, ...) standardGeneric('draw_heatmap_body'))
16
+setGeneric('copy_all', function(object, ...) standardGeneric('copy_all'))
17
+setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation'))
13 18
 setGeneric('draw', function(object, ...) standardGeneric('draw'))
14
-setGeneric('prepare', function(object, ...) standardGeneric('prepare'))
15
-setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster'))
16 19
 setGeneric('adjust_heatmap_list', function(object, ...) standardGeneric('adjust_heatmap_list'))
17
-setGeneric('set_component_width', function(object, ...) standardGeneric('set_component_width'))
20
+setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list'))
21
+setGeneric('draw_dend', function(object, ...) standardGeneric('draw_dend'))
22
+setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size'))
18 23
 setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend'))
19 24
 setGeneric('component_width', function(object, ...) standardGeneric('component_width'))
20
-setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height'))
21
-setGeneric('re_size', function(object, ...) standardGeneric('re_size'))
22
-setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend'))
23
-setGeneric('copy_all', function(object, ...) standardGeneric('copy_all'))
24
-setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list'))
25
-setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation'))
26
-setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster'))
25
+setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend'))
27 26
 setGeneric('column_order', function(object, ...) standardGeneric('column_order'))
28
-setGeneric('row_order', function(object, ...) standardGeneric('row_order'))
29
-setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list'))
30
-setGeneric('draw_heatmap_body', function(object, ...) standardGeneric('draw_heatmap_body'))
27
+setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height'))
28
+setGeneric('prepare', function(object, ...) standardGeneric('prepare'))
29
+setGeneric('attach_annotation', function(object, ...) standardGeneric('attach_annotation'))
30
+setGeneric('annotation_legend_size', function(object, ...) standardGeneric('annotation_legend_size'))
31
+setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster'))
31 32
 setGeneric('get_color_mapping_list', function(object, ...) standardGeneric('get_color_mapping_list'))
32
-setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames'))
... ...
@@ -1189,6 +1189,10 @@ anno_lines = function(x, which = c("column", "row"), border = TRUE, gp = gpar(),
1189 1189
 # -extend The extension to both side of ``ylim``. The value is a percent value corresponding to ``ylim[2] - ylim[1]``.
1190 1190
 # -axis Whether to add axis?
1191 1191
 # -axis_param parameters for controlling axis. See `default_axis_param` for all possible settings and default parameters.
1192
+# -add_numbers Whether to add numbers to the bars. It only works when ``x`` is a simple vector.
1193
+# -numbers_gp Graphics parameters for the numbers.
1194
+# -numbers_rot Rotation of numbers.
1195
+# -numbers_offset Offset to the default positions (1mm away the top of the bars).
1192 1196
 # -width Width of the annotation. The value should be an absolute unit. Width is not allowed to be set for column annotation.
1193 1197
 # -height Height of the annotation. The value should be an absolute unit. Height is not allowed to be set for row annotation.
1194 1198
 # -... Other arguments.
... ...
@@ -1209,7 +1213,9 @@ anno_lines = function(x, which = c("column", "row"), border = TRUE, gp = gpar(),
1209 1213
 # draw(anno, test = "proportion matrix")
1210 1214
 anno_barplot = function(x, baseline = 0, which = c("column", "row"), border = TRUE, bar_width = 0.6,
1211 1215
 	gp = gpar(fill = "#CCCCCC"), ylim = NULL, extend = 0.05, axis = TRUE, 
1212
-	axis_param = default_axis_param(which),
1216
+	axis_param = default_axis_param(which), 
1217
+	add_numbers = FALSE, numbers_gp = gpar(fontsize = 8), 
1218
+	numbers_rot = ifelse(which == "column", 45, 0), numbers_offset = unit(2, "mm"),
1213 1219
 	width = NULL, height = NULL, ...) {
1214 1220
 
1215 1221
 	other_args = list(...)
... ...
@@ -1282,6 +1288,19 @@ anno_barplot = function(x, baseline = 0, which = c("column", "row"), border = TR
1282 1288
 	}
1283 1289
 
1284 1290
 	value = x
1291
+
1292
+	if(ncol(value) == 1) {
1293
+		if(add_numbers) {
1294
+			if(which == "column") {
1295
+				extend = convertHeight(sin(numbers_rot/180*pi)*max_text_width(value, gp = numbers_gp) + numbers_offset + unit(4, "mm"), "mm", valueOnly = TRUE)/convertHeight(anno_size$height, "mm", valueOnly = TRUE)*(data_scale[2] - data_scale[1])
1296
+				data_scale[2] = data_scale[2] + extend
1297
+			} else if(which == "row") {
1298
+				extend = convertWidth(cos(numbers_rot/180*pi)*max_text_width(value, gp = numbers_gp) + numbers_offset + unit(4, "mm"), "mm", valueOnly = TRUE)/convertWidth(anno_size$width, "mm", valueOnly = TRUE)*(data_scale[2] - data_scale[1])
1299
+				data_scale[2] = data_scale[2] + extend
1300
+			}
1301
+		}
1302
+	}
1303
+
1285 1304
 	axis_param = validate_axis_param(axis_param, which)
1286 1305
 	axis_grob = if(axis) construct_axis_grob(axis_param, which, data_scale) else NULL
1287 1306
 
... ...
@@ -1299,6 +1318,13 @@ anno_barplot = function(x, baseline = 0, which = c("column", "row"), border = TR
1299 1318
 			width = value[index] - baseline
1300 1319
 			x_coor = width/2+baseline
1301 1320
 			grid.rect(x = x_coor, y = n - seq_along(index) + 1, width = abs(width), height = 1*bar_width, default.units = "native", gp = subset_gp(gp, index))
1321
+			if(add_numbers) {
1322
+				if(axis_param$direction == "normal") {
1323
+					grid.text(value[index], x = unit(baseline + width, "native") + numbers_offset, y = n - seq_along(index) + 1, default.units = "native", gp = subset_gp(numbers_gp, index), just = c("left"), rot = numbers_rot)
1324
+				} else {
1325
+					grid.text(value_origin[index], x = unit(baseline + width, "native") - numbers_offset, y = n - seq_along(index) + 1, default.units = "native", gp = subset_gp(numbers_gp, index), just = c("right"), rot = numbers_rot)
1326
+				}
1327
+			}
1302 1328
 		} else {
1303 1329
 			for(i in seq_len(ncol(value))) {
1304 1330
 				if(axis_param$direction == "normal") {
... ...
@@ -1336,6 +1362,9 @@ anno_barplot = function(x, baseline = 0, which = c("column", "row"), border = TR
1336 1362
 			height = value[index] - baseline
1337 1363
 			y_coor = height/2+baseline
1338 1364
 			grid.rect(y = y_coor, x = seq_along(index), height = abs(height), width = 1*bar_width, default.units = "native", gp = subset_gp(gp, index))
1365
+			if(add_numbers) {
1366
+				grid.text(value[index], x = seq_along(index), y = unit(baseline + height, "native") + numbers_offset, default.units = "native", gp = subset_gp(numbers_gp, index), just = c("left"), rot = numbers_rot)
1367
+			}
1339 1368
 		} else {
1340 1369
 			for(i in seq_len(ncol(value))) {
1341 1370
 				if(axis_param$direction == "normal") {
... ...
@@ -1375,7 +1404,7 @@ anno_barplot = function(x, baseline = 0, which = c("column", "row"), border = TR
1375 1404
 		height = anno_size$height,
1376 1405
 		n = n,
1377 1406
 		data_scale = data_scale,
1378
-		var_import = list(value, gp, border, bar_width, baseline, axis, axis_param, axis_grob, data_scale)
1407
+		var_import = list(value, gp, border, bar_width, baseline, axis, axis_param, axis_grob, data_scale, add_numbers, numbers_gp, numbers_offset, numbers_rot)
1379 1408
 	)
1380 1409
 
1381 1410
 	anno@subset_rule$value = subset_matrix_by_row
... ...
@@ -445,6 +445,7 @@ setMethod(f = "adjust_heatmap_list",
445 445
     padding = unit(c(0, 0, 0, 0), "mm")
446 446
     if(is.null(adjust_annotation_extension)) {
447 447
         if(direction == "horizontal") {
448
+            # right side
448 449
             if(inherits(object@ht_list[[n]], "Heatmap")) {
449 450
                 # if the last heatmap has nothing on the right while something on the right of heatmap list
450 451
                 if(!(has_component(object@ht_list[[n]], "row_anno_right") ||
... ...
@@ -459,6 +460,7 @@ setMethod(f = "adjust_heatmap_list",
459 460
                     }
460 461
                 }
461 462
             }
463
+            # left side
462 464
             if(inherits(object@ht_list[[1]], "Heatmap")) {
463 465
                 if(!(has_component(object@ht_list[[1]], "row_anno_left") ||
464 466
                      has_component(object@ht_list[[1]], "row_names_left") ||
... ...
@@ -472,6 +474,21 @@ setMethod(f = "adjust_heatmap_list",
472 474
                     }
473 475
                 }
474 476
             }
477
+            # bottom side
478
+            if(has_heatmap_list_component(object, "column_title_bottom") || 
479
+               has_heatmap_list_component(object, "heatmap_legend_bottom") || 
480
+               has_heatmap_list_component(object, "annotation_legend_bottom")) {
481
+                object@layout$row_anno_max_bottom_extended = unit(0, "mm")
482
+                adjust_annotation_extension = TRUE
483
+            }
484
+
485
+            if(has_heatmap_list_component(object, "column_title_top") || 
486
+               has_heatmap_list_component(object, "heatmap_legend_top") || 
487
+               has_heatmap_list_component(object, "annotation_legend_top")) {
488
+                object@layout$row_anno_max_top_extended = unit(0, "mm")
489
+                adjust_annotation_extension = TRUE
490
+            }
491
+
475 492
         } else {
476 493
             if(inherits(object@ht_list[[n]], "Heatmap")) {
477 494
                 # if the last heatmap has nothing on the right while something on the right of heatmap list
... ...
@@ -500,6 +517,20 @@ setMethod(f = "adjust_heatmap_list",
500 517
                     }
501 518
                 }
502 519
             }
520
+
521
+            if(has_heatmap_list_component(object, "column_title_bottom") || 
522
+               has_heatmap_list_component(object, "heatmap_legend_bottom") || 
523
+               has_heatmap_list_component(object, "annotation_legend_bottom")) {
524
+                object@layout$row_anno_max_bottom_extended = unit(0, "mm")
525
+                adjust_annotation_extension = TRUE
526
+            }
527
+
528
+            if(has_heatmap_list_component(object, "column_title_top") || 
529
+               has_heatmap_list_component(object, "heatmap_legend_top") || 
530
+               has_heatmap_list_component(object, "annotation_legend_top")) {
531
+                object@layout$row_anno_max_top_extended = unit(0, "mm")
532
+                adjust_annotation_extension = TRUE
533
+            }
503 534
         }
504 535
     }
505 536
 
... ...
@@ -345,7 +345,6 @@ setMethod(f = "make_layout",
345 345
             object@ht_list[[i_main]]@row_order = row_order
346 346
             if(verbose) qqcat("set row_order to main heatmap\n")
347 347
         }
348
-
349 348
         
350 349
         if(!is.null(height) && !is.null(heatmap_height)) {
351 350
             stop_wrap("You can only specify one of `height` and `heatmap_height` in draw().")
... ...
@@ -140,7 +140,7 @@ setMethod(f = "draw_heatmap_legend",
140 140
                 y = max(y1, y2)
141 141
                 pushViewport(viewport(name = "heatmap_legend", x = unit(0.5, "npc"), y = y, width = size[1], height = size[2], just = c("center", "top")))           
142 142
             } else {
143
-                x1 = unit(0.5, "npc") - size[1]*0.5  # top of heatmap legend
143
+                x1 = unit(0.5, "npc") - size[1]*0.5  # left of heatmap legend
144 144
                 x2 = unit(0.5, "npc") - annotation_legend_size[1]*0.5
145 145
                 x = min(x1, x2)
146 146
                 pushViewport(viewport(name = "heatmap_legend", x = x, y = unit(0.5, "npc"), width = size[1], height = size[2], just = c("left", "center")))           
... ...
@@ -1250,6 +1250,7 @@ print.comb_mat = function(x, ...) {
1250 1250
 # -set_order The order of sets.
1251 1251
 # -comb_order The order of combination sets.
1252 1252
 # -top_annotation A `HeatmapAnnotation` object on top of the combination matrix.
1253
+# -left_annotation A `HeatmapAnnotation` object on top of the combination matrix.
1253 1254
 # -right_annotation A `HeatmapAnnotation` object on the right of the combination matrix.
1254 1255
 # -row_names_side The side of row names.
1255 1256
 # -... Other arguments passed to `Heatmap`.
... ...
@@ -1350,6 +1351,7 @@ UpSet = function(m,
1350 1351
 		},
1351 1352
 	top_annotation = upset_top_annotation(m),
1352 1353
 	right_annotation = upset_right_annotation(m),
1354
+	left_annotation = NULL,
1353 1355
 	row_names_side = "left",
1354 1356
 	...) {
1355 1357
 
... ...
@@ -1364,6 +1366,15 @@ UpSet = function(m,
1364 1366
 	pt_size = pt_size
1365 1367
 	lwd = lwd
1366 1368
 
1369
+	if(!is.null(left_annotation)) {
1370
+		if(missing(right_annotation)) {
1371
+			right_annotation = NULL
1372
+		}
1373
+		if(missing(row_names_side)) {
1374
+			row_names_side = "right"
1375
+		}
1376
+	}
1377
+
1367 1378
 	if(set_on_rows) {
1368 1379
 		n_comb = ncol(m)
1369 1380
 		if(length(comb_col == 1)) comb_col = rep(comb_col, n_comb)
... ...
@@ -1409,7 +1420,7 @@ UpSet = function(m,
1409 1420
 		ht = Heatmap(m2, cluster_rows = FALSE, cluster_columns = FALSE, rect_gp = gpar(type = "none"),
1410 1421
 			layer_fun = layer_fun, show_heatmap_legend = FALSE,
1411 1422
 			top_annotation = ra,
1412
-			right_annotation = right_annotation,
1423
+			right_annotation = right_annotation, left_annotation = left_annotation,
1413 1424
 			row_names_side = row_names_side, col = c("0" = bg_pt_col, "1" = comb_col[1]),
1414 1425
 			row_order = set_order, column_order = comb_order, ...)
1415 1426
 	} else {
... ...
@@ -1451,10 +1462,21 @@ UpSet = function(m,
1451 1462
 				}
1452 1463
 			}
1453 1464
 		}
1465
+		la = left_annotation
1466
+		if(length(la) == 1) {
1467
+			ta_call = substitute(top_annotation)
1468
+			ta_call = as.list(ta_call)
1469
+			if(as.character(ta_call[[1]]) == "upset_left_annotation") {
1470
+				if(!"gp" %in% names(as.list(ta_call))) {
1471
+					la@anno_list[[1]]@fun@var_env$gp$fill = comb_col
1472
+					la@anno_list[[1]]@fun@var_env$gp$col = comb_col
1473
+				}
1474
+			}
1475
+		}
1454 1476
 		ht = Heatmap(m2, cluster_rows = FALSE, cluster_columns = FALSE, rect_gp = gpar(type = "none"),
1455 1477
 			layer_fun = layer_fun, show_heatmap_legend = FALSE,
1456 1478
 			top_annotation = top_annotation,
1457
-			right_annotation = ra, col = c("0" = bg_pt_col, "1" = comb_col[1]),
1479
+			right_annotation = ra, left_annotation = la, col = c("0" = bg_pt_col, "1" = comb_col[1]),
1458 1480
 			row_order = comb_order, column_order = set_order, ...)
1459 1481
 	}
1460 1482
 	ht@heatmap_param$type = "UpSet"
... ...
@@ -1495,6 +1517,8 @@ order.comb_mat = function(m, decreasing = TRUE, on = "comb_set") {
1495 1517
 	}
1496 1518
 }
1497 1519
 
1520
+
1521
+
1498 1522
 # == title
1499 1523
 # Default UpSet Top Annotation
1500 1524
 #
... ...
@@ -1573,7 +1597,7 @@ upset_top_annotation = function(m,
1573 1597
 # -annotation_name_offset Offset to the annotation name, a `grid::unit` object.
1574 1598
 # -annotation_name_side Side of the annotation name.
1575 1599
 # -annotation_name_rot Rotation of the annotation name, it can only take values in ``c(00, 90, 180, 270)``.
1576
-# -... Passed to `anno_barplot`.
1600
+# -... Passed to `anno_barplot`, e.g. to set ``add_numbers``.
1577 1601
 #
1578 1602
 # == details
1579 1603
 # The default right annotation is actually barplot implemented by `anno_barplot`. For
... ...
@@ -1627,6 +1651,70 @@ upset_right_annotation = function(m,
1627 1651
 	return(ha)
1628 1652
 }
1629 1653
 
1654
+# == title
1655
+# UpSet Left Annotation
1656
+#
1657
+# == param
1658
+# -m A combination matrix which is as same as the one for `UpSet`.
1659
+# -gp Graphic parameters for bars.
1660
+# -axis_param Parameters for axis.
1661
+# -width Width of the left annotation.
1662
+# -show_annotation_name Whether show annotation names?
1663
+# -annotation_name_gp Graphic parameters for anntation names.
1664
+# -annotation_name_offset Offset to the annotation name, a `grid::unit` object.
1665
+# -annotation_name_side Side of the annotation name.
1666
+# -annotation_name_rot Rotation of the annotation name, it can only take values in ``c(00, 90, 180, 270)``.
1667
+# -... Passed to `anno_barplot`, e.g. to set ``add_numbers``.
1668
+#
1669
+upset_left_annotation = function(m,
1670
+	gp = gpar(fill = "black"),  
1671
+	axis_param = list(direction = "reverse"),
1672
+	width = unit(ifelse(set_on_rows, 2, 3), "cm"),
1673
+	show_annotation_name = TRUE,
1674
+	annotation_name_gp = gpar(),
1675
+	annotation_name_offset = NULL,
1676
+	annotation_name_side = "bottom",
1677
+	annotation_name_rot = NULL,
1678
+	...) {
1679
+
1680
+	set_on_rows = attr(m, "param")$set_on_rows
1681
+
1682
+	if(!"direction" %in% names(axis_param)) {
1683
+		axis_param$direction = "reverse"
1684
+	}
1685
+
1686
+	if(set_on_rows) {
1687
+		ha = rowAnnotation("set_size" = anno_barplot(set_size(m), border = FALSE, 
1688
+					gp = gp, width = width, axis_param = axis_param, ...),
1689
+				show_annotation_name = show_annotation_name,
1690
+				annotation_name_gp = annotation_name_gp,
1691
+				annotation_name_offset = annotation_name_offset,
1692
+				annotation_name_side = annotation_name_side,
1693
+				annotation_name_rot = annotation_name_rot,
1694
+				annotation_label = "Set size")
1695
+	} else {
1696
+		ha = rowAnnotation("intersection_size" = anno_barplot(comb_size(m), 
1697
+					border = FALSE, gp = gp, width = width, axis_param = axis_param, ...),
1698
+				show_annotation_name = show_annotation_name,
1699
+				annotation_name_gp = annotation_name_gp,
1700
+				annotation_name_offset = annotation_name_offset,
1701
+				annotation_name_side = annotation_name_side,
1702
+				annotation_name_rot = annotation_name_rot,
1703
+				annotation_label = "Intersection\nsize")
1704
+	}
1705
+
1706
+	mode = attr(m, "param")$mode
1707
+	if(!set_on_rows) {
1708
+		if(mode %in% c("distinct", "intersect")) {
1709
+			# names(ha) = "intersection_size"
1710
+		} else {
1711
+			names(ha) = "union_size"
1712
+			ha@anno_list[[1]]@label = "Union size"
1713
+		}
1714
+	}
1715
+	return(ha)
1716
+}
1717
+
1630 1718
 # == title
1631 1719
 # Normalize a list of combination matrice
1632 1720
 #
... ...
@@ -19,6 +19,7 @@ UpSet(m,
19 19
     },
20 20
     top_annotation = upset_top_annotation(m),
21 21
     right_annotation = upset_right_annotation(m),
22
+    left_annotation = NULL,
22 23
     row_names_side = "left",
23 24
     ...)
24 25
 }
... ...
@@ -33,6 +34,7 @@ UpSet(m,
33 34
   \item{set_order}{The order of sets.}
34 35
   \item{comb_order}{The order of combination sets.}
35 36
   \item{top_annotation}{A \code{\link{HeatmapAnnotation}} object on top of the combination matrix.}
37
+  \item{left_annotation}{A \code{\link{HeatmapAnnotation}} object on top of the combination matrix.}
36 38
   \item{right_annotation}{A \code{\link{HeatmapAnnotation}} object on the right of the combination matrix.}
37 39
   \item{row_names_side}{The side of row names.}
38 40
   \item{...}{Other arguments passed to \code{\link{Heatmap}}.}
... ...
@@ -10,6 +10,8 @@ Barplot Annotation
10 10
 anno_barplot(x, baseline = 0, which = c("column", "row"), border = TRUE, bar_width = 0.6,
11 11
     gp = gpar(fill = "#CCCCCC"), ylim = NULL, extend = 0.05, axis = TRUE,
12 12
     axis_param = default_axis_param(which),
13
+    add_numbers = FALSE, numbers_gp = gpar(fontsize = 8),
14
+    numbers_rot = ifelse(which == "column", 45, 0), numbers_offset = unit(2, "mm"),
13 15
     width = NULL, height = NULL, ...)
14 16
 }
15 17
 \arguments{
... ...
@@ -24,6 +26,10 @@ anno_barplot(x, baseline = 0, which = c("column", "row"), border = TRUE, bar_wid
24 26
   \item{extend}{The extension to both side of \code{ylim}. The value is a percent value corresponding to \code{ylim[2] - ylim[1]}.}
25 27
   \item{axis}{Whether to add axis?}
26 28
   \item{axis_param}{parameters for controlling axis. See \code{\link{default_axis_param}} for all possible settings and default parameters.}
29
+  \item{add_numbers}{Whether to add numbers to the bars. It only works when \code{x} is a simple vector.}
30
+  \item{numbers_gp}{Graphics parameters for the numbers.}
31
+  \item{numbers_rot}{Rotation of numbers.}
32
+  \item{numbers_offset}{Offset to the default positions (1mm away the top of the bars).}
27 33
   \item{width}{Width of the annotation. The value should be an absolute unit. Width is not allowed to be set for column annotation.}
28 34
   \item{height}{Height of the annotation. The value should be an absolute unit. Height is not allowed to be set for row annotation.}
29 35
   \item{...}{Other arguments.}
... ...
@@ -10,8 +10,8 @@ Method dispatch page for \code{column_order}.
10 10
 \code{column_order} can be dispatched on following classes:
11 11
 
12 12
 \itemize{
13
-\item \code{\link{column_order,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
14 13
 \item \code{\link{column_order,Heatmap-method}}, \code{\link{Heatmap-class}} class method
14
+\item \code{\link{column_order,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
15 15
 }
16 16
 }
17 17
 \examples{
... ...
@@ -10,8 +10,8 @@ Method dispatch page for \code{component_height}.
10 10
 \code{component_height} can be dispatched on following classes:
11 11
 
12 12
 \itemize{
13
-\item \code{\link{component_height,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
14 13
 \item \code{\link{component_height,Heatmap-method}}, \code{\link{Heatmap-class}} class method
14
+\item \code{\link{component_height,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
15 15
 }
16 16
 }
17 17
 \examples{
... ...
@@ -10,8 +10,8 @@ Method dispatch page for \code{copy_all}.
10 10
 \code{copy_all} can be dispatched on following classes:
11 11
 
12 12
 \itemize{
13
-\item \code{\link{copy_all,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method
14 13
 \item \code{\link{copy_all,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method
14
+\item \code{\link{copy_all,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method
15 15
 }
16 16
 }
17 17
 \examples{
... ...
@@ -10,12 +10,12 @@ Method dispatch page for \code{draw}.
10 10
 \code{draw} can be dispatched on following classes:
11 11
 
12 12
 \itemize{
13
-\item \code{\link{draw,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
14
-\item \code{\link{draw,Legends-method}}, \code{\link{Legends-class}} class method
13
+\item \code{\link{draw,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
15 14
 \item \code{\link{draw,Heatmap-method}}, \code{\link{Heatmap-class}} class method
16
-\item \code{\link{draw,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method
15
+\item \code{\link{draw,Legends-method}}, \code{\link{Legends-class}} class method
16
+\item \code{\link{draw,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
17 17
 \item \code{\link{draw,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method
18
-\item \code{\link{draw,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
18
+\item \code{\link{draw,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method
19 19
 }
20 20
 }
21 21
 \examples{
... ...
@@ -10,8 +10,8 @@ Method dispatch page for \code{make_layout}.
10 10
 \code{make_layout} can be dispatched on following classes:
11 11
 
12 12
 \itemize{
13
-\item \code{\link{make_layout,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
14 13
 \item \code{\link{make_layout,Heatmap-method}}, \code{\link{Heatmap-class}} class method
14
+\item \code{\link{make_layout,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
15 15
 }
16 16
 }
17 17
 \examples{
... ...
@@ -10,8 +10,8 @@ Method dispatch page for \code{row_dend}.
10 10
 \code{row_dend} can be dispatched on following classes:
11 11
 
12 12
 \itemize{
13
-\item \code{\link{row_dend,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
14 13
 \item \code{\link{row_dend,Heatmap-method}}, \code{\link{Heatmap-class}} class method
14
+\item \code{\link{row_dend,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
15 15
 }
16 16
 }
17 17
 \examples{
... ...
@@ -11,10 +11,10 @@ Method dispatch page for \code{show}.
11 11
 
12 12
 \itemize{
13 13
 \item \code{\link{show,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
14
-\item \code{\link{show,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method
15
-\item \code{\link{show,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method
16
-\item \code{\link{show,Heatmap-method}}, \code{\link{Heatmap-class}} class method
17 14
 \item \code{\link{show,ColorMapping-method}}, \code{\link{ColorMapping-class}} class method
15
+\item \code{\link{show,Heatmap-method}}, \code{\link{Heatmap-class}} class method
16
+\item \code{\link{show,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method
17
+\item \code{\link{show,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method
18 18
 \item \code{\link{show,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
19 19
 }
20 20
 }
21 21
new file mode 100644
... ...
@@ -0,0 +1,38 @@
1
+\name{upset_left_annotation}
2
+\alias{upset_left_annotation}
3
+\title{
4
+UpSet Left Annotation
5
+}
6
+\description{
7
+UpSet Left Annotation
8
+}
9
+\usage{
10
+upset_left_annotation(m,
11
+    gp = gpar(fill = "black"),
12
+    axis_param = list(direction = "reverse"),
13
+    width = unit(ifelse(set_on_rows, 2, 3), "cm"),
14
+    show_annotation_name = TRUE,
15
+    annotation_name_gp = gpar(),
16
+    annotation_name_offset = NULL,
17
+    annotation_name_side = "bottom",
18
+    annotation_name_rot = NULL,
19
+    ...)
20
+}
21
+\arguments{
22
+
23
+  \item{m}{A combination matrix which is as same as the one for \code{\link{UpSet}}.}
24
+  \item{gp}{Graphic parameters for bars.}
25
+  \item{axis_param}{Parameters for axis.}
26
+  \item{width}{Width of the left annotation.}
27
+  \item{show_annotation_name}{Whether show annotation names?}
28
+  \item{annotation_name_gp}{Graphic parameters for anntation names.}
29
+  \item{annotation_name_offset}{Offset to the annotation name, a \code{\link[grid]{unit}} object.}
30
+  \item{annotation_name_side}{Side of the annotation name.}
31
+  \item{annotation_name_rot}{Rotation of the annotation name, it can only take values in \code{c(00, 90, 180, 270)}.}
32
+  \item{...}{Passed to \code{\link{anno_barplot}}, e.g. to set \code{add_numbers}.}
33
+
34
+}
35
+\examples{
36
+# There is no example
37
+NULL
38
+}
... ...
@@ -27,7 +27,7 @@ upset_right_annotation(m,
27 27
   \item{annotation_name_offset}{Offset to the annotation name, a \code{\link[grid]{unit}} object.}
28 28
   \item{annotation_name_side}{Side of the annotation name.}
29 29
   \item{annotation_name_rot}{Rotation of the annotation name, it can only take values in \code{c(00, 90, 180, 270)}.}
30
-  \item{...}{Passed to \code{\link{anno_barplot}}.}
30
+  \item{...}{Passed to \code{\link{anno_barplot}}, e.g. to set \code{add_numbers}.}
31 31
 
32 32
 }
33 33
 \details{