Browse code

legends support symbols as labels

Zuguang Gu authored on 25/09/2019 07:48:09
Showing2 changed files

... ...
@@ -7,6 +7,7 @@ CHANGES in VERSION 2.1.0
7 7
 * `densityHeatmap()`: `ylim` works as it is expected.
8 8
 * add `cluster_row_slices` and `cluster_column_slices` to `draw,HeatmapList-method()`
9 9
 * add `cluster_rows`/`cluster_columns` in `oncoPrint()`
10
+* legend labels support symbols
10 11
 
11 12
 ========================
12 13
 
... ...
@@ -373,7 +373,11 @@ discrete_legend_body = function(at, labels = at, nrow = NULL, ncol = 1, by_row =
373 373
 	# legend grid
374 374
 	gl = list()
375 375
 	for(i in 1:ncol) {
376
-		index = index_mat[, i][labels_mat[, i] != ""]
376
+		if(inherits(labels_mat[1, 1], "expression")) {
377
+			index = index_mat[, i][sapply(labels_mat[, i], function(x) x) != ""]
378
+		} else {
379
+			index = index_mat[, i][labels_mat[, i] != ""]
380
+		}
377 381
 		ni = length(index)
378 382
 		y = (0:(ni-1))*(grid_height)
379 383
 		y = legend_body_height - y