Zuguang Gu authored on 17/10/2017 19:44:53
Showing31 changed files

... ...
@@ -1,6 +1,9 @@
1 1
 export('+.AdditiveUnit')
2 2
 export('grid.dendrogram')
3
+<<<<<<< HEAD
3 4
 export('grid.dendrogram2')
5
+=======
6
+>>>>>>> bioc/master
4 7
 export(AdditiveUnit)
5 8
 export(ColorMapping)
6 9
 export(Heatmap)
... ...
@@ -8,7 +11,10 @@ export(HeatmapAnnotation)
8 11
 export(HeatmapList)
9 12
 export(Legend)
10 13
 export(SingleAnnotation)
14
+<<<<<<< HEAD
11 15
 export(adjust_dend_by_leaf_width)
16
+=======
17
+>>>>>>> bioc/master
12 18
 export(anno_barplot)
13 19
 export(anno_boxplot)
14 20
 export(anno_density)
... ...
@@ -99,7 +105,10 @@ exportMethods(set_component_height)
99 105
 import(grDevices)
100 106
 import(graphics)
101 107
 import(grid)
108
+<<<<<<< HEAD
102 109
 import(methods)
110
+=======
111
+>>>>>>> bioc/master
103 112
 import(stats)
104 113
 importFrom("GetoptLong", qq)
105 114
 importFrom("GetoptLong", qq.options)
... ...
@@ -111,5 +120,15 @@ importFrom("circlize", rand_color)
111 120
 importFrom("circlize", smartAlign)
112 121
 importFrom("colorspace", diverge_hcl)
113 122
 importFrom("colorspace", rainbow_hcl)
123
+<<<<<<< HEAD
124
+=======
125
+importFrom("dendextend", "labels<-")
126
+importFrom("dendextend", get_branches_heights)
127
+importFrom("dendextend", nnodes)
128
+importFrom("methods", "new", "show")
129
+importFrom("methods", setClass)
130
+importFrom("methods", setGeneric)
131
+importFrom("methods", setMethod)
132
+>>>>>>> bioc/master
114 133
 importFrom("utils", "getFromNamespace")
115 134
 
... ...
@@ -1,3 +1,4 @@
1
+<<<<<<< HEAD
1 2
 CHANGES in VERSION 1.15.1
2 3
 
3 4
 * random colors are generated by new `rand_color()` function in circlize package.
... ...
@@ -22,6 +23,12 @@ CHANGES in VERSION 1.15.1
22 23
 CHANGES in VERSION 1.13.2
23 24
 
24 25
 * add `packLegend()`
26
+=======
27
+CHANGES in VERSION 1.13.2
28
+
29
+* add `packLegend()`
30
+* Legend() supports to add txt labels on grids
31
+>>>>>>> bioc/master
25 32
 
26 33
 ========================
27 34
 
28 35
new file mode 100755
... ...
@@ -0,0 +1,3 @@
1
+[Dolphin]
2
+Timestamp=2015,6,15,11,33,52
3
+ViewMode=2
... ...
@@ -1,4 +1,5 @@
1 1
 
2
+<<<<<<< HEAD
2 3
 setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list'))
3 4
 
4 5
 setGeneric('get_color_mapping_param_list', function(object, ...) standardGeneric('get_color_mapping_param_list'))
... ...
@@ -41,10 +42,49 @@ setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_he
41 42
 
42 43
 setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend'))
43 44
 
45
+=======
46
+setGeneric('add_heatmap', function(object, ...) standardGeneric('add_heatmap'))
47
+
48
+setGeneric('map_to_colors', function(object, ...) standardGeneric('map_to_colors'))
49
+
50
+setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height'))
51
+
52
+setGeneric('draw_heatmap_body', function(object, ...) standardGeneric('draw_heatmap_body'))
53
+
54
+setGeneric('column_order', function(object, ...) standardGeneric('column_order'))
55
+
56
+setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend'))
57
+
58
+setGeneric('component_height', function(object, ...) standardGeneric('component_height'))
59
+
60
+setGeneric('make_layout', function(object, ...) standardGeneric('make_layout'))
61
+
62
+setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend'))
63
+
64
+setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size'))
65
+
66
+setGeneric('annotation_legend_size', function(object, ...) standardGeneric('annotation_legend_size'))
67
+
68
+setGeneric('prepare', function(object, ...) standardGeneric('prepare'))
69
+
70
+setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation'))
71
+
72
+setGeneric('get_color_mapping_param_list', function(object, ...) standardGeneric('get_color_mapping_param_list'))
73
+
74
+setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames'))
75
+
76
+setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend'))
77
+
78
+setGeneric('draw', function(object, ...) standardGeneric('draw'))
79
+
80
+setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster'))
81
+
82
+>>>>>>> bioc/master
44 83
 setGeneric('draw_title', function(object, ...) standardGeneric('draw_title'))
45 84
 
46 85
 setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster'))
47 86
 
87
+<<<<<<< HEAD
48 88
 setGeneric('prepare', function(object, ...) standardGeneric('prepare'))
49 89
 
50 90
 setGeneric('column_dend', function(object, ...) standardGeneric('column_dend'))
... ...
@@ -52,3 +92,18 @@ setGeneric('column_dend', function(object, ...) standardGeneric('column_dend'))
52 92
 setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster'))
53 93
 
54 94
 setGeneric('draw_dend', function(object, ...) standardGeneric('draw_dend'))
95
+=======
96
+setGeneric('component_width', function(object, ...) standardGeneric('component_width'))
97
+
98
+setGeneric('column_dend', function(object, ...) standardGeneric('column_dend'))
99
+
100
+setGeneric('get_color_mapping_list', function(object, ...) standardGeneric('get_color_mapping_list'))
101
+
102
+setGeneric('row_order', function(object, ...) standardGeneric('row_order'))
103
+
104
+setGeneric('draw_dend', function(object, ...) standardGeneric('draw_dend'))
105
+
106
+setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list'))
107
+
108
+setGeneric('row_dend', function(object, ...) standardGeneric('row_dend'))
109
+>>>>>>> bioc/master
... ...
@@ -180,7 +180,10 @@ setMethod(f = "map_to_colors",
180 180
 	x2 = vector(length = length(x))
181 181
 
182 182
 	if(object@type == "discrete") {
183
+<<<<<<< HEAD
183 184
 		x[grepl("^\\s*$", x)] = NA
185
+=======
186
+>>>>>>> bioc/master
184 187
 		lna = is.na(x)
185 188
 
186 189
 		if(is.numeric(x)) x = as.character(x)
... ...
@@ -212,10 +215,17 @@ setMethod(f = "map_to_colors",
212 215
 # -title title of the legend, by default it is the name of the legend
213 216
 # -title_gp graphical parameters for legend title
214 217
 # -title_position position of the title
218
+<<<<<<< HEAD
215 219
 # -color_bar a string of "continous" or "discrete". If the mapping is continuous, whether show the legend as discrete color bar or continuous color bar
216 220
 # -grid_height height of each legend grid.
217 221
 # -grid_width width of each legend grid.
218 222
 # -border color for legend grid borders.
223
+=======
224
+# -color_bar if the mapping is continuous, whether show the legend as discrete color bar or continuous color bar
225
+# -grid_height height of each legend grid.
226
+# -grid_width width of each legend grid.
227
+# -grid_border color for legend grid borders.
228
+>>>>>>> bioc/master
219 229
 # -at break values of the legend
220 230
 # -labels labels corresponding to break values
221 231
 # -labels_gp graphcial parameters for legend labels
... ...
@@ -245,10 +255,17 @@ setMethod(f = "color_mapping_legend",
245 255
 	title = object@name,
246 256
 	title_gp = gpar(fontsize = 10, fontface = "bold"),
247 257
 	title_position = c("topleft", "topcenter", "leftcenter", "lefttop"),
258
+<<<<<<< HEAD
248 259
 	color_bar = object@type,
249 260
 	grid_height = unit(4, "mm"),
250 261
 	grid_width = unit(4, "mm"),
251 262
 	border = NULL,
263
+=======
264
+	color_bar = c("discrete", "continuous"),
265
+	grid_height = unit(4, "mm"),
266
+	grid_width = unit(4, "mm"),
267
+	grid_border = NULL,
268
+>>>>>>> bioc/master
252 269
 	at = object@levels,
253 270
 	labels = at,
254 271
 	labels_gp = gpar(fontsize = 10),
... ...
@@ -268,10 +285,17 @@ setMethod(f = "color_mapping_legend",
268 285
 	title_gp = check_gp(title_gp)
269 286
 	labels_gp = check_gp(labels_gp)
270 287
 
288
+<<<<<<< HEAD
271 289
 	# color_bar = match.arg(color_bar)
272 290
 
273 291
 	if(object@type == "discrete" && color_bar == "continuous") {
274 292
 		stop("'color_bar' can only be set to 'discrete' only if the color mapping is discrete")
293
+=======
294
+	color_bar = match.arg(color_bar)
295
+
296
+	if(object@type == "discrete" && color_bar == "continuous") {
297
+		stop("'color_bar' can only be set to 'continuous' only if the color mapping is continuous")
298
+>>>>>>> bioc/master
275 299
 	}
276 300
 
277 301
 	# get labels
... ...
@@ -291,13 +315,21 @@ setMethod(f = "color_mapping_legend",
291 315
 			labels = rev(labels)
292 316
 		}
293 317
 		gf = Legend(at = at, labels = labels, title = title, title_gp = title_gp, grid_height = grid_height,
318
+<<<<<<< HEAD
294 319
 			grid_width = grid_width, border = border, labels_gp = labels_gp, nrow = nrow, ncol = ncol,
320
+=======
321
+			grid_width = grid_width, border = grid_border, labels_gp = labels_gp, nrow = nrow, ncol = ncol,
322
+>>>>>>> bioc/master
295 323
 			legend_gp = gpar(fill = map_to_colors(object, at)), title_position = title_position)
296 324
 
297 325
 	} else {
298 326
 
299 327
 		gf = Legend(at = at, labels = labels, col_fun = object@col_fun, title = title, title_gp = title_gp, grid_height = grid_height,
328
+<<<<<<< HEAD
300 329
 			grid_width = grid_width, border = border, labels_gp = labels_gp, direction = legend_direction,
330
+=======
331
+			grid_width = grid_width, border = grid_border, labels_gp = labels_gp, direction = legend_direction,
332
+>>>>>>> bioc/master
301 333
 			legend_width = legend_width, legend_height = legend_height, title_position = title_position)
302 334
 
303 335
 	}
... ...
@@ -191,7 +191,11 @@ Heatmap = setClass("Heatmap",
191 191
 # -bottom_annotation_height total height of the column annotations on the bottom.
192 192
 # -km do k-means clustering on rows. If the value is larger than 1, the heatmap will be split by rows according to the k-means clustering.
193 193
 #     For each row-clusters, hierarchical clustering is still applied with parameters above.
194
+<<<<<<< HEAD
194 195
 # -km_title row title for each cluster when ``km`` is set. It must a text with format of ".*\%i.*" where "\%i" is replaced by the index of the cluster.
196
+=======
197
+# -km_title row title for each cluster when ``km`` is set. It must a text with format of "*\%i*" where "\%i" is replaced by the index of the cluster.
198
+>>>>>>> bioc/master
195 199
 # -split a vector or a data frame by which the rows are split. But if ``cluster_rows`` is a clustering object, ``split`` can be a single number
196 200
 #        indicating rows are to be split according to the split on the tree.
197 201
 # -gap gap between row-slices if the heatmap is split by rows, should be `grid::unit` object. If it is a vector, the order corresponds
... ...
@@ -202,8 +206,12 @@ Heatmap = setClass("Heatmap",
202 206
 #        is appended to a list of heatmaps.
203 207
 # -show_heatmap_legend whether show heatmap legend?
204 208
 # -heatmap_legend_param a list contains parameters for the heatmap legend. See `color_mapping_legend,ColorMapping-method` for all available parameters.
209
+<<<<<<< HEAD
205 210
 # -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``
206 211
 #       is set, ``use_raster`` is enforced to be ``FALSE``.
212
+=======
213
+# -use_raster whether render the heatmap body as a raster image. It helps to reduce file size when the matrix is huge.
214
+>>>>>>> bioc/master
207 215
 # -raster_device graphic device which is used to generate the raster image
208 216
 # -raster_quality a value set to larger than 1 will improve the quality of the raster image.
209 217
 # -raster_device_param a list of further parameters for the selected graphic device
... ...
@@ -231,7 +239,11 @@ Heatmap = function(matrix, col, name,
231 239
     na_col = "grey", 
232 240
     color_space = "LAB",
233 241
     rect_gp = gpar(col = NA), 
242
+<<<<<<< HEAD
234 243
     cell_fun = NULL,
244
+=======
245
+    cell_fun = function(j, i, x, y, width, height, fill) NULL,
246
+>>>>>>> bioc/master
235 247
     row_title = character(0), 
236 248
     row_title_side = c("left", "right"), 
237 249
     row_title_gp = gpar(fontsize = 14), 
... ...
@@ -270,11 +282,19 @@ Heatmap = function(matrix, col, name,
270 282
     column_order = NULL,
271 283
     row_names_side = c("right", "left"), 
272 284
     show_row_names = TRUE, 
285
+<<<<<<< HEAD
273 286
     row_names_max_width = default_row_names_max_width(), 
274 287
     row_names_gp = gpar(fontsize = 12), 
275 288
     column_names_side = c("bottom", "top"), 
276 289
     show_column_names = TRUE, 
277 290
     column_names_max_height = default_column_names_max_height(), 
291
+=======
292
+    row_names_max_width = unit(4, "cm"), 
293
+    row_names_gp = gpar(fontsize = 12), 
294
+    column_names_side = c("bottom", "top"), 
295
+    show_column_names = TRUE, 
296
+    column_names_max_height = unit(4, "cm"), 
297
+>>>>>>> bioc/master
278 298
     column_names_gp = gpar(fontsize = 12),
279 299
     top_annotation = new("HeatmapAnnotation"),
280 300
     top_annotation_height = top_annotation@size,
... ...
@@ -287,10 +307,17 @@ Heatmap = function(matrix, col, name,
287 307
     combined_name_fun = function(x) paste(x, collapse = "/"),
288 308
     width = NULL, 
289 309
     show_heatmap_legend = TRUE,
310
+<<<<<<< HEAD
290 311
     heatmap_legend_param = list(title = name),
291 312
     use_raster = FALSE, 
292 313
     raster_device = c("png", "jpeg", "tiff", "CairoPNG", "CairoJPEG", "CairoTIFF"),
293 314
     raster_quality = 2,
315
+=======
316
+    heatmap_legend_param = list(title = name, color_bar = "discrete"),
317
+    use_raster = FALSE, 
318
+    raster_device = c("png", "jpeg", "tiff", "CairoPNG", "CairoJPEG", "CairoTIFF"),
319
+    raster_quality = 1,
320
+>>>>>>> bioc/master
294 321
     raster_device_param = list()) {
295 322
 
296 323
     # re-define some of the argument values according to global settings
... ...
@@ -501,9 +528,12 @@ Heatmap = function(matrix, col, name,
501 528
     .Object@row_names_param$side = match.arg(row_names_side)[1]
502 529
     .Object@row_names_param$show = show_row_names
503 530
     .Object@row_names_param$gp = check_gp(row_names_gp)
531
+<<<<<<< HEAD
504 532
     default_row_names_max_width = function() {
505 533
         min(unit.c(unit(6, "cm")), max_text_width(rownames(matrix), gp = .Object@row_names_param$gp))
506 534
     }
535
+=======
536
+>>>>>>> bioc/master
507 537
     .Object@row_names_param$max_width = row_names_max_width + unit(2, "mm")
508 538
 
509 539
     if(is.null(colnames(matrix))) {
... ...
@@ -512,9 +542,12 @@ Heatmap = function(matrix, col, name,
512 542
     .Object@column_names_param$side = match.arg(column_names_side)[1]
513 543
     .Object@column_names_param$show = show_column_names
514 544
     .Object@column_names_param$gp = check_gp(column_names_gp)
545
+<<<<<<< HEAD
515 546
     default_column_names_max_height = function() {
516 547
         min(unit.c(unit(6, "cm")), max_text_width(colnames(matrix), gp = .Object@column_names_param$gp))
517 548
     }
549
+=======
550
+>>>>>>> bioc/master
518 551
     .Object@column_names_param$max_height = column_names_max_height + unit(2, "mm")
519 552
 
520 553
     if(inherits(cluster_rows, "dendrogram") || inherits(cluster_rows, "hclust")) {
... ...
@@ -1296,11 +1329,14 @@ setMethod(f = "draw_heatmap_body",
1296 1329
     y = (rev(seq_len(nr)) - 0.5) / nr
1297 1330
     expand_index = expand.grid(seq_len(nr), seq_len(nc))
1298 1331
     
1332
+<<<<<<< HEAD
1299 1333
     cell_fun = object@matrix_param$cell_fun
1300 1334
     if(!is.null(cell_fun)) {
1301 1335
         use_raster = FALSE
1302 1336
     }
1303 1337
         
1338
+=======
1339
+>>>>>>> bioc/master
1304 1340
     if(use_raster) {
1305 1341
         # write the image into a temporary file and read it back
1306 1342
         device_info = switch(raster_device,
... ...
@@ -1323,6 +1359,7 @@ setMethod(f = "draw_heatmap_body",
1323 1359
         if(heatmap_width <= 0 || heatmap_height <= 0) {
1324 1360
             stop("The width or height of the raster image is zero, maybe you forget to turn off the previous graphic device or it was corrupted. Run `dev.off()` to close it.")
1325 1361
         }
1362
+<<<<<<< HEAD
1326 1363
         tmp_dir = "."
1327 1364
         # dir.create(tmp_dir, showWarnings = FALSE)
1328 1365
         temp_image = tempfile(pattern = paste0(".heatmap_body_", object@name, "_", k, "_"), tmpdir = tmp_dir, fileext = paste0(".", device_info[2]))
... ...
@@ -1378,10 +1415,43 @@ setMethod(f = "draw_heatmap_body",
1378 1415
         }
1379 1416
     }
1380 1417
 
1418
+=======
1419
+        temp_image = tempfile(pattern = paste0(".heatmap_body_", object@name, "_", k, "_"), tmpdir = ".", fileext = paste0(".", device_info[2]))
1420
+        #getFromNamespace(raster_device, ns = device_info[1])(temp_image, width = heatmap_width*raster_quality, height = heatmap_height*raster_quality)
1421
+        device_fun = getFromNamespace(raster_device, ns = device_info[1])
1422
+        do.call("device_fun", c(list(filename = temp_image, width = heatmap_width*raster_quality, height = heatmap_height*raster_quality), raster_device_param))
1423
+    }
1424
+
1425
+    if(any(names(gp) %in% c("type"))) {
1426
+        if(gp$type == "none") {
1427
+        } else {
1428
+            grid.rect(x[expand_index[[2]]], y[expand_index[[1]]], width = unit(1/nc, "npc"), height = unit(1/nr, "npc"), gp = do.call("gpar", c(list(fill = col_matrix), gp)))
1429
+        }
1430
+    } else {
1431
+        grid.rect(x[expand_index[[2]]], y[expand_index[[1]]], width = unit(1/nc, "npc"), height = unit(1/nr, "npc"), gp = do.call("gpar", c(list(fill = col_matrix), gp)))
1432
+    }
1433
+
1434
+    cell_fun = object@matrix_param$cell_fun
1435
+    for(i in row_order) {
1436
+        for(j in column_order) {
1437
+            cell_fun(j, i, unit(x[which(column_order == j)], "npc"), unit(y[which(row_order == i)], "npc"), unit(1/nc, "npc"), unit(1/nr, "npc"), col_matrix[which(row_order == i), which(column_order == j)])
1438
+        }
1439
+    }
1440
+
1441
+    if(use_raster) {
1442
+        dev.off()
1443
+        image = getFromNamespace(device_info[3], ns = device_info[2])(temp_image)
1444
+        image = as.raster(image)
1445
+        grid.raster(image, width = unit(1, "npc"), height = unit(1, "npc"))
1446
+        file.remove(temp_image)
1447
+    }
1448
+
1449
+>>>>>>> bioc/master
1381 1450
     upViewport()
1382 1451
 
1383 1452
 })
1384 1453
 
1454
+<<<<<<< HEAD
1385 1455
 is_windows = function() {
1386 1456
     tolower(.Platform$OS.type) == "windows"
1387 1457
 }
... ...
@@ -1391,6 +1461,8 @@ R_binary = function() {
1391 1461
     return(file.path(R.home("bin"), R_exe))
1392 1462
 }
1393 1463
 
1464
+=======
1465
+>>>>>>> bioc/master
1394 1466
 # == title
1395 1467
 # Draw dendrogram on row or column
1396 1468
 #
... ...
@@ -1445,7 +1517,11 @@ setMethod(f = "draw_dend",
1445 1517
 
1446 1518
     dend = as.dendrogram(hc)
1447 1519
     n = length(labels(dend))
1520
+<<<<<<< HEAD
1448 1521
     if(nobs(dend) <= 1) {
1522
+=======
1523
+    if(nnodes(dend) <= 1) {
1524
+>>>>>>> bioc/master
1449 1525
         return(invisible(NULL))
1450 1526
     }
1451 1527
 
... ...
@@ -245,6 +245,7 @@ HeatmapAnnotation = function(df, name, col, na_col = "grey",
245 245
 			} else if(is.atomic(anno_arg_list[[ag]])) {
246 246
 
247 247
 			    if(is.null(simple_length)) {
248
+<<<<<<< HEAD
248 249
 			    	if(is.matrix(anno_arg_list[[ag]])) {
249 250
 			    		simple_length = nrow(anno_arg_list[[ag]])
250 251
 			    	} else {
... ...
@@ -260,6 +261,11 @@ HeatmapAnnotation = function(df, name, col, na_col = "grey",
260 261
 			    			stop("length of simple annotations differ.")
261 262
 			    		}
262 263
 			    	}
264
+=======
265
+			    	simple_length = length(anno_arg_list[[ag]])
266
+			    } else if(length(anno_arg_list[[ag]]) != simple_length) {
267
+			    	stop("length of simple annotations differ.")
268
+>>>>>>> bioc/master
263 269
 			    }
264 270
 				if(missing(col)) {
265 271
 			        anno_list = c(anno_list, list(SingleAnnotation(name = ag, value = anno_arg_list[[ag]], na_col = na_col, which = which, 
... ...
@@ -316,6 +322,7 @@ HeatmapAnnotation = function(df, name, col, na_col = "grey",
316 322
 
317 323
 	if(length(anno_size) == 1) {
318 324
 		if(!is.unit(anno_size)) {
325
+<<<<<<< HEAD
319 326
 			anno_size = sapply(anno_list, function(x) {
320 327
 				if(is_simple_annotation(x)) {
321 328
 					return(1)
... ...
@@ -325,6 +332,9 @@ HeatmapAnnotation = function(df, name, col, na_col = "grey",
325 332
 					return(2)
326 333
 				}
327 334
 			})
335
+=======
336
+			anno_size = rep(anno_size, n_total_anno)
337
+>>>>>>> bioc/master
328 338
 		}
329 339
 	}
330 340
 
... ...
@@ -154,15 +154,22 @@ setMethod(f = "add_heatmap",
154 154
     ht_name = names(object@ht_list)
155 155
     which_duplicated = duplicated(ht_name)
156 156
     if(any(which_duplicated)) {
157
+<<<<<<< HEAD
157 158
         warning(paste0("Heatmap/row annotation names are duplicated: ", paste(ht_name[which_duplicated], collapse = ", ")))
159
+=======
160
+        warning(paste0("Heatmap/row annotaiton names are duplicated: ", paste(ht_name[which_duplicated], collapse = ", ")))
161
+>>>>>>> bioc/master
158 162
     }
159 163
 
160 164
     l = which(sapply(object@ht_list, inherits, "Heatmap"))
161 165
     nr = sapply(object@ht_list[l], function(ht) nrow(ht@matrix))
162 166
 
163 167
     if(length(unique(nr)) > 1) {
168
+<<<<<<< HEAD
164 169
         cat("`nrow` of all heatmaps:\n")
165 170
         print(nr)
171
+=======
172
+>>>>>>> bioc/master
166 173
         stop("`nrow` of all heatmaps should be the same.")
167 174
         for(i in l) {
168 175
             cat(object@ht_list[[i]]@name, ":", nrow(object@ht_list[[i]]@matrix), "\n")
... ...
@@ -185,7 +192,10 @@ setMethod(f = "add_heatmap",
185 192
 # -column_title_side will the title be put on the top or bottom of the heatmap.
186 193
 # -column_title_gp graphic parameters for drawing text.
187 194
 # -heatmap_legend_side side of the heatmap legend.
195
+<<<<<<< HEAD
188 196
 # -merge_legends whether put heatmap legends and annotation legends in a same column
197
+=======
198
+>>>>>>> bioc/master
189 199
 # -show_heatmap_legend whether show heatmap legend.
190 200
 # -heatmap_legend_list a list of self-defined legend, should be wrapped into `grid::grob` objects.
191 201
 # -annotation_legend_side side of annotation legend.
... ...
@@ -206,7 +216,10 @@ setMethod(f = "add_heatmap",
206 216
 # -row_order same setting as in `Heatmap`, if it is specified, ``row_order`` in main heatmap is ignored.
207 217
 # -km same setting as in `Heatmap`, if it is specified, ``km`` in main heatmap is ignored.
208 218
 # -split same setting as in `Heatmap`, if it is specified, ``split`` in main heatmap is ignored.
219
+<<<<<<< HEAD
209 220
 # -combined_name_fun same setting as in `Heatmap`, if it is specified, ``combined_name_fun`` in main heatmap is ignored.
221
+=======
222
+>>>>>>> bioc/master
210 223
 #
211 224
 # == detail
212 225
 # It sets the size of each component of the heatmap list and adjusts graphic parameters for each heatmap if necessary.
... ...
@@ -230,7 +243,10 @@ setMethod(f = "make_layout",
230 243
     column_title_side = c("top", "bottom"), 
231 244
     column_title_gp = gpar(fontsize = 14), 
232 245
     heatmap_legend_side = c("right", "left", "bottom", "top"), 
246
+<<<<<<< HEAD
233 247
     merge_legends = FALSE,
248
+=======
249
+>>>>>>> bioc/master
234 250
     show_heatmap_legend = TRUE, 
235 251
     heatmap_legend_list = list(),
236 252
     annotation_legend_side = c("right", "left", "bottom", "top"), 
... ...
@@ -250,8 +266,12 @@ setMethod(f = "make_layout",
250 266
     row_dend_gp = NULL,
251 267
     row_order = NULL,
252 268
     km = NULL,
269
+<<<<<<< HEAD
253 270
     split = NULL,
254 271
     combined_name_fun = NULL) {
272
+=======
273
+    split = NULL) {
274
+>>>>>>> bioc/master
255 275
 
256 276
     if(object@layout$initialized) {
257 277
         return(object)
... ...
@@ -289,8 +309,11 @@ setMethod(f = "make_layout",
289 309
     }
290 310
     object@ht_list_param$gap = gap
291 311
 
312
+<<<<<<< HEAD
292 313
     object@ht_list_param$merge_legends = merge_legends
293 314
 
315
+=======
316
+>>>>>>> bioc/master
294 317
     for(i in seq_len(n)) {
295 318
         # if the zero-column matrix is the first one
296 319
         if(inherits(object@ht_list[[i]], "Heatmap")) {
... ...
@@ -310,9 +333,12 @@ setMethod(f = "make_layout",
310 333
     if(!is.null(km)) {
311 334
         object@ht_list[[i_main]]@matrix_param$km = km
312 335
     }
336
+<<<<<<< HEAD
313 337
     if(!missing(combined_name_fun)) {
314 338
         object@ht_list[[i_main]]@matrix_param$combined_name_fun = combined_name_fun
315 339
     }
340
+=======
341
+>>>>>>> bioc/master
316 342
 
317 343
     if(!is.null(cluster_rows)) {
318 344
 
... ...
@@ -456,8 +482,12 @@ setMethod(f = "make_layout",
456 482
     }
457 483
     object@ht_list_param$gap = gap
458 484
     object@ht_list_param$main_heatmap = i_main
485
+<<<<<<< HEAD
459 486
     object@ht_list_param$merge_legends = merge_legends
460 487
 
488
+=======
489
+    
490
+>>>>>>> bioc/master
461 491
     n = length(object@ht_list)
462 492
 
463 493
     ## orders of other heatmaps should be changed
... ...
@@ -603,6 +633,7 @@ setMethod(f = "make_layout",
603 633
     for(i in seq_along(object@ht_list)) {
604 634
         ht = object@ht_list[[i]]
605 635
         if(inherits(ht, "Heatmap")) {
636
+<<<<<<< HEAD
606 637
             if(merge_legends && !is.null(ht@top_annotation)) {
607 638
                 ColorMappingList = c(ColorMappingList, get_color_mapping_list(ht@top_annotation))
608 639
             }
... ...
@@ -612,6 +643,11 @@ setMethod(f = "make_layout",
612 643
             if(merge_legends && !is.null(ht@bottom_annotation)) {
613 644
                 ColorMappingList = c(ColorMappingList, get_color_mapping_list(ht@bottom_annotation))
614 645
             }
646
+=======
647
+            if(ht@heatmap_param$show_heatmap_legend) {
648
+                ColorMappingList = c(ColorMappingList, ht@matrix_color_mapping)
649
+            }
650
+>>>>>>> bioc/master
615 651
         }
616 652
         if(inherits(ht, "HeatmapAnnotation")) {
617 653
             ColorMappingList = c(ColorMappingList, get_color_mapping_list(ht))
... ...
@@ -659,6 +695,7 @@ setMethod(f = "make_layout",
659 695
     ## annotation legend to top, bottom, left and right
660 696
     # default values
661 697
     ColorMappingList = list()
698
+<<<<<<< HEAD
662 699
     if(!merge_legends) {
663 700
         for(i in seq_along(object@ht_list)) {
664 701
             ht = object@ht_list[[i]]
... ...
@@ -673,6 +710,18 @@ setMethod(f = "make_layout",
673 710
         }
674 711
     } else {
675 712
         annotation_legend_list = list()
713
+=======
714
+    for(i in seq_along(object@ht_list)) {
715
+        ht = object@ht_list[[i]]
716
+        if(inherits(ht, "Heatmap")) {
717
+            if(!is.null(ht@top_annotation)) {
718
+                ColorMappingList = c(ColorMappingList, get_color_mapping_list(ht@top_annotation))
719
+            }
720
+            if(!is.null(ht@bottom_annotation)) {
721
+                ColorMappingList = c(ColorMappingList, get_color_mapping_list(ht@bottom_annotation))
722
+            }
723
+        }
724
+>>>>>>> bioc/master
676 725
     }
677 726
     if(length(ColorMappingList) == 0 && length(annotation_legend_list) == 0) {
678 727
         show_annotation_legend = FALSE
... ...
@@ -1195,20 +1244,27 @@ setMethod(f = "draw_heatmap_legend",
1195 1244
     ColorMappingList = list()
1196 1245
     ColorMappingParamList = list()
1197 1246
     for(i in seq_along(object@ht_list)) {
1247
+<<<<<<< HEAD
1198 1248
         ht = object@ht_list[[i]]
1199 1249
         if(inherits(object@ht_list[[i]], "Heatmap")) {
1200 1250
             if(object@ht_list_param$merge_legends && !is.null(ht@top_annotation)) {
1201 1251
                 ColorMappingList = c.list(ColorMappingList, list = get_color_mapping_list(ht@top_annotation))
1202 1252
                 ColorMappingParamList = c.list(ColorMappingParamList, list = get_color_mapping_param_list(ht@top_annotation))
1203 1253
             }
1254
+=======
1255
+        if(inherits(object@ht_list[[i]], "Heatmap")) {
1256
+>>>>>>> bioc/master
1204 1257
             if(object@ht_list[[i]]@heatmap_param$show_heatmap_legend) {
1205 1258
                 ColorMappingList = c.list(ColorMappingList, object@ht_list[[i]]@matrix_color_mapping)
1206 1259
                 ColorMappingParamList = c.list(ColorMappingParamList, object@ht_list[[i]]@matrix_color_mapping_param)
1207 1260
             }
1261
+<<<<<<< HEAD
1208 1262
             if(object@ht_list_param$merge_legends && !is.null(ht@bottom_annotation)) {
1209 1263
                 ColorMappingList = c.list(ColorMappingList, list = get_color_mapping_list(ht@bottom_annotation))
1210 1264
                 ColorMappingParamList = c.list(ColorMappingParamList, list = get_color_mapping_param_list(ht@bottom_annotation))
1211 1265
             }
1266
+=======
1267
+>>>>>>> bioc/master
1212 1268
         } else if(inherits(object@ht_list[[i]], "HeatmapAnnotation")) {
1213 1269
             ColorMappingList = c.list(ColorMappingList, list = get_color_mapping_list(object@ht_list[[i]]))
1214 1270
             ColorMappingParamList = c.list(ColorMappingParamList, list = get_color_mapping_param_list(object@ht_list[[i]]))
... ...
@@ -1329,21 +1385,28 @@ setMethod(f = "heatmap_legend_size",
1329 1385
     ColorMappingList = list()
1330 1386
     ColorMappingParamList = list()
1331 1387
     for(i in seq_along(object@ht_list)) {
1388
+<<<<<<< HEAD
1332 1389
         ht = object@ht_list[[i]]
1333 1390
         if(inherits(object@ht_list[[i]], "Heatmap")) {
1334 1391
             if(object@ht_list_param$merge_legends && !is.null(ht@top_annotation)) {
1335 1392
                 ColorMappingList = c.list(ColorMappingList, list = get_color_mapping_list(ht@top_annotation))
1336 1393
                 ColorMappingParamList = c.list(ColorMappingParamList, list = get_color_mapping_param_list(ht@top_annotation))
1337 1394
             }
1395
+=======
1396
+        if(inherits(object@ht_list[[i]], "Heatmap")) {
1397
+>>>>>>> bioc/master
1338 1398
             if(object@ht_list[[i]]@heatmap_param$show_heatmap_legend) {
1339 1399
                 ColorMappingList = c.list(ColorMappingList, object@ht_list[[i]]@matrix_color_mapping)
1340 1400
                 ColorMappingParamList = c.list(ColorMappingParamList, object@ht_list[[i]]@matrix_color_mapping_param)
1341 1401
             }
1402
+<<<<<<< HEAD
1342 1403
             if(object@ht_list_param$merge_legends && !is.null(ht@bottom_annotation)) {
1343 1404
                 ColorMappingList = c.list(ColorMappingList, list = get_color_mapping_list(ht@bottom_annotation))
1344 1405
                 ColorMappingParamList = c.list(ColorMappingParamList, list = get_color_mapping_param_list(ht@bottom_annotation))
1345 1406
             }
1346 1407
             
1408
+=======
1409
+>>>>>>> bioc/master
1347 1410
         } else if(inherits(object@ht_list[[i]], "HeatmapAnnotation")) {
1348 1411
             ColorMappingList = c.list(ColorMappingList, list = get_color_mapping_list(object@ht_list[[i]]))
1349 1412
             ColorMappingParamList = c.list(ColorMappingParamList, list = get_color_mapping_param_list(object@ht_list[[i]]))
... ...
@@ -1410,12 +1473,15 @@ draw_legend = function(ColorMappingList, ColorMappingParamList, side = c("right"
1410 1473
 
1411 1474
     side = match.arg(side)[1]
1412 1475
 
1476
+<<<<<<< HEAD
1413 1477
     # remove legends which are duplicated by testing the names
1414 1478
     legend_names = sapply(ColorMappingList, function(x) x@name)
1415 1479
     l = !duplicated(legend_names)
1416 1480
     ColorMappingList = ColorMappingList[l]
1417 1481
     ColorMappingParamList = ColorMappingParamList[l]
1418 1482
 
1483
+=======
1484
+>>>>>>> bioc/master
1419 1485
     n = length(ColorMappingList)
1420 1486
     if(n == 0 && length(legend_list) == 0) {
1421 1487
         return(unit(c(0, 0), "null"))
... ...
@@ -135,10 +135,17 @@ Legend = function(at, labels = at, nrow = NULL, ncol = 1, col_fun,
135 135
 	# for(i in seq_len(length(odevlist) - length(dev.list()))) {
136 136
 	# 	dev.off()
137 137
 	# }
138
+<<<<<<< HEAD
138 139
 	return(gf)
139 140
 }
140 141
 
141 142
 # grids are arranged by rows
143
+=======
144
+
145
+	return(gf)
146
+}
147
+
148
+>>>>>>> bioc/master
142 149
 discrete_legend_body = function(at, labels = at, nrow = NULL, ncol = 1,
143 150
 	grid_height = unit(4, "mm"), grid_width = unit(4, "mm"), gap = unit(2, "mm"),
144 151
 	labels_gp = gpar(fontsize = 10),
... ...
@@ -156,18 +163,27 @@ discrete_legend_body = function(at, labels = at, nrow = NULL, ncol = 1,
156 163
 		nrow = 1
157 164
 		ncol = 1
158 165
 	}
166
+<<<<<<< HEAD
159 167
 	ncol = ifelse(ncol > n_labels, n_labels, ncol)
160 168
 
161 169
 	labels_mat = matrix(c(labels, rep("", nrow*ncol - n_labels)), nrow = nrow, ncol = ncol, byrow = TRUE)
162 170
 	index_mat = matrix(1:(nrow*ncol), nrow = nrow, ncol = ncol, byrow = TRUE)
163 171
 
172
+=======
173
+>>>>>>> bioc/master
164 174
 
165 175
 	labels_padding_left = unit(1, "mm")
166 176
 	
167 177
 	labels_max_width = NULL
168 178
 	for(i in 1:ncol) {
179
+<<<<<<< HEAD
169 180
 		if(i == 1) {
170 181
 			labels_max_width = max(do.call("unit.c", lapply(labels_mat[, i], function(x) {
182
+=======
183
+		index = seq(nrow*(i-1)+1, min(c(nrow*i, n_labels)))
184
+		if(i == 1) {
185
+			labels_max_width = max(do.call("unit.c", lapply(labels[index], function(x) {
186
+>>>>>>> bioc/master
171 187
 					g = grobWidth(textGrob(x, gp = labels_gp))
172 188
 					if(i < ncol) {
173 189
 						g = g + gap
... ...
@@ -175,7 +191,11 @@ discrete_legend_body = function(at, labels = at, nrow = NULL, ncol = 1,
175 191
 					g
176 192
 				})))
177 193
 		} else {
194
+<<<<<<< HEAD
178 195
 			labels_max_width = unit.c(labels_max_width, max(do.call("unit.c", lapply(labels_mat[, i], function(x) {
196
+=======
197
+			labels_max_width = unit.c(labels_max_width, max(do.call("unit.c", lapply(labels[index], function(x) {
198
+>>>>>>> bioc/master
179 199
 					g = grobWidth(textGrob(x, gp = labels_gp))
180 200
 					if(i < ncol) {
181 201
 						g = g + gap
... ...
@@ -195,7 +215,11 @@ discrete_legend_body = function(at, labels = at, nrow = NULL, ncol = 1,
195 215
 
196 216
 	# legend grid
197 217
 	for(i in 1:ncol) {
218
+<<<<<<< HEAD
198 219
 		index = index_mat[, i][labels_mat[, i] != ""]
220
+=======
221
+		index = seq(nrow*(i-1)+1, min(c(nrow*i, n_labels)))
222
+>>>>>>> bioc/master
199 223
 		ni = length(index)
200 224
 		x = unit(rep(0, ni), "npc")
201 225
 		y = (0:(ni-1))*(grid_height)
... ...
@@ -221,7 +245,15 @@ discrete_legend_body = function(at, labels = at, nrow = NULL, ncol = 1,
221 245
 		if(any(c("points", "p") %in% type)) {
222 246
 			if(length(pch) == 1) pch = rep(pch, n_labels)
223 247
 			if(length(size) == 1) size = rep(size, n_labels)
248
+<<<<<<< HEAD
224 249
 			gf = placeGrob(gf, row = 1, col = 2*i-1, grob = pointsGrob(x+grid_width*0.5, y-grid_height*0.5, pch = pch[index], size = size[index], gp = subset_gp(legend_gp, index)))
250
+=======
251
+			if(inherits(pch, "character")) {
252
+				gf = placeGrob(gf, row = 1, col = 2*i-1, grob = textGrob(pch[index], x+grid_width*0.5, y-grid_height*0.5, gp = subset_gp(legend_gp, index)))
253
+			} else {
254
+				gf = placeGrob(gf, row = 1, col = 2*i-1, grob = pointsGrob(x+grid_width*0.5, y-grid_height*0.5, pch = pch[index], size = size[index], gp = subset_gp(legend_gp, index)))
255
+			}
256
+>>>>>>> bioc/master
225 257
 		}
226 258
 		if(any(c("lines", "l") %in% type)) {
227 259
 			gf = placeGrob(gf, row = 1, col = 2*i-1, grob = segmentsGrob(x+unit(0.5, "mm"), y-grid_height*0.5, x+grid_width - unit(0.5, "mm"), y-grid_height*0.5, gp = subset_gp(legend_gp, index)))
... ...
@@ -35,8 +35,12 @@ SingleAnnotation = setClass("SingleAnnotation",
35 35
 		show_legend = "logical",
36 36
 		which = "character",
37 37
 		name_to_data_vp = "logical",
38
+<<<<<<< HEAD
38 39
 		name_param = "list",
39 40
         is_anno_matrix = "logical"
41
+=======
42
+		name_param = "list"
43
+>>>>>>> bioc/master
40 44
 	),
41 45
 	prototype = list(
42 46
 		color_mapping = NULL,
... ...
@@ -138,6 +142,7 @@ SingleAnnotation = function(name, value, col, fun,
138 142
         stop("`name_rot` can only take values in c(0, 90, 180, 270)")
139 143
     }
140 144
 
145
+<<<<<<< HEAD
141 146
     .Object@is_anno_matrix = FALSE
142 147
     use_mat_column_names = FALSE
143 148
     if(!missing(value)) {
... ...
@@ -156,11 +161,15 @@ SingleAnnotation = function(name, value, col, fun,
156 161
         }
157 162
     }
158 163
 
164
+=======
165
+    
166
+>>>>>>> bioc/master
159 167
     if(which == "column") {
160 168
     	if(!name_side %in% c("left", "right")) {
161 169
     		stop("`name_side` should be 'left' or 'right' when it is a column annotation.")
162 170
     	}
163 171
     	if(name_side == "left") {
172
+<<<<<<< HEAD
164 173
     		
165 174
             if(use_mat_column_names) {
166 175
                 name_x = unit(rep(0, use_mat_nc), "npc") - name_offset
... ...
@@ -169,6 +178,10 @@ SingleAnnotation = function(name, value, col, fun,
169 178
                 name_x = unit(0, "npc") - name_offset
170 179
                 name_y = unit(0.5, "npc")
171 180
             }
181
+=======
182
+    		name_x = unit(0, "npc") - name_offset
183
+    		name_y = unit(0.5, "npc")
184
+>>>>>>> bioc/master
172 185
             if(name_rot == 0) {
173 186
                 name_just = "right"
174 187
             } else if(name_rot == 90) {
... ...
@@ -179,6 +192,7 @@ SingleAnnotation = function(name, value, col, fun,
179 192
                 name_just = "top"
180 193
             }
181 194
     	} else {
195
+<<<<<<< HEAD
182 196
             if(use_mat_column_names) {
183 197
                 name_x = unit(rep(1, use_mat_nc), "npc") + name_offset
184 198
                 name_y = unit((use_mat_nc - seq_len(use_mat_nc) + 0.5)/use_mat_nc, "npc")
... ...
@@ -186,6 +200,10 @@ SingleAnnotation = function(name, value, col, fun,
186 200
         		name_x = unit(1, "npc") + name_offset
187 201
         		name_y = unit(0.5, "npc")
188 202
             }
203
+=======
204
+    		name_x = unit(1, "npc") + name_offset
205
+    		name_y = unit(0.5, "npc")
206
+>>>>>>> bioc/master
189 207
             if(name_rot == 0) {
190 208
                 name_just = "left"
191 209
             } else if(name_rot == 90) {
... ...
@@ -201,6 +219,7 @@ SingleAnnotation = function(name, value, col, fun,
201 219
     		stop("`name_side` should be 'left' or 'right' when it is a column annotation.")
202 220
     	}
203 221
     	if(name_side == "top") {
222
+<<<<<<< HEAD
204 223
             if(use_mat_column_names) {
205 224
                 name_x = unit((seq_len(use_mat_nc) - 0.5)/use_mat_nc, "npc")
206 225
                 name_y = unit(rep(1, use_mat_nc), "npc") + name_offset
... ...
@@ -208,6 +227,10 @@ SingleAnnotation = function(name, value, col, fun,
208 227
         		name_x = unit(0.5, "npc")
209 228
         		name_y = unit(1, "npc") + name_offset
210 229
             }
230
+=======
231
+    		name_x = unit(0.5, "npc")
232
+    		name_y = unit(1, "npc") + name_offset
233
+>>>>>>> bioc/master
211 234
             if(name_rot == 0) {
212 235
                 name_just = "bottom"
213 236
             } else if(name_rot == 90) {
... ...
@@ -218,6 +241,7 @@ SingleAnnotation = function(name, value, col, fun,
218 241
                 name_just = "right"
219 242
             }
220 243
     	} else {
244
+<<<<<<< HEAD
221 245
             if(use_mat_column_names) {
222 246
                 name_x = unit((seq_len(use_mat_nc) - 0.5)/use_mat_nc, "npc")
223 247
                 name_y = unit(rep(0, use_mat_nc), "npc") - name_offset
... ...
@@ -225,6 +249,10 @@ SingleAnnotation = function(name, value, col, fun,
225 249
         		name_x = unit(0.5, "npc")
226 250
         		name_y = unit(0, "npc") - name_offset
227 251
             }
252
+=======
253
+    		name_x = unit(0.5, "npc")
254
+    		name_y = unit(0, "npc") - name_offset
255
+>>>>>>> bioc/master
228 256
             if(name_rot == 0) {
229 257
                 name_just = "top"
230 258
             } else if(name_rot == 90) {
... ...
@@ -241,18 +269,38 @@ SingleAnnotation = function(name, value, col, fun,
241 269
     						  y = name_y,
242 270
     						  just = name_just,
243 271
     	                      gp = check_gp(name_gp),
272
+<<<<<<< HEAD
244 273
     	                      rot = name_rot,
245 274
                               side = name_side)
275
+=======
276
+    	                      rot = name_rot)
277
+>>>>>>> bioc/master
246 278
 
247 279
     gp = check_gp(gp)
248 280
     if(!is.null(gp$fill)) {
249 281
     	stop("You should not set `fill`.")
250 282
     }
251 283
 
284
+<<<<<<< HEAD
285
+=======
286
+    if(!missing(value)) {
287
+	    if(is.logical(value)) {
288
+	    	value = as.character(value)
289
+	    }
290
+	    if(is.factor(value)) {
291
+            value = as.vector(value)
292
+        }
293
+	}
294
+
295
+>>>>>>> bioc/master
252 296
     if(missing(fun)) {
253 297
     	if(missing(col)) {
254 298
     		col = default_col(value)
255 299
     	}
300
+<<<<<<< HEAD
301
+=======
302
+        
303
+>>>>>>> bioc/master
256 304
     	if(is.atomic(col)) {
257 305
     	    if(is.null(names(col))) {
258 306
                 if(is.factor(value)) {
... ...
@@ -280,6 +328,7 @@ SingleAnnotation = function(name, value, col, fun,
280 328
 	        .Object@fun = function(index) {
281 329
 	        	n = length(index)
282 330
 				x = (seq_len(n) - 0.5) / n
331
+<<<<<<< HEAD
283 332
                 if(is.matrix(value)) {
284 333
                     nc = ncol(value)
285 334
                     for(i in seq_len(nc)) {
... ...
@@ -290,11 +339,17 @@ SingleAnnotation = function(name, value, col, fun,
290 339
     				fill = map_to_colors(color_mapping, value[index])
291 340
     				grid.rect(x, y = 0.5, width = 1/n, height = 1, gp = do.call("gpar", c(list(fill = fill), gp)))
292 341
                 }
342
+=======
343
+				fill = map_to_colors(color_mapping, value[index])
344
+				#l = which(!is.na(value[index]))
345
+				grid.rect(x, y = 0.5, width = 1/n, height = 1, gp = do.call("gpar", c(list(fill = fill), gp)))
346
+>>>>>>> bioc/master
293 347
 			}
294 348
 		} else {
295 349
 			.Object@fun = function(index, k = NULL, N = NULL) {
296 350
 				n = length(index)
297 351
 				y = (n - seq_len(n) + 0.5) / n
352
+<<<<<<< HEAD
298 353
                 if(is.matrix(value)) {
299 354
                     nc = ncol(value)
300 355
                     for(i in seq_len(nc)) {
... ...
@@ -305,6 +360,11 @@ SingleAnnotation = function(name, value, col, fun,
305 360
     				fill = map_to_colors(color_mapping, value[index])
306 361
     				grid.rect(x = 0.5, y, height = 1/n, width = 1, gp = do.call("gpar", c(list(fill = fill), gp)))
307 362
                 }
363
+=======
364
+				fill = map_to_colors(color_mapping, value[index])
365
+				#l = which(!is.na(value[index]))
366
+				grid.rect(x = 0.5, y, height = 1/n, width = 1, gp = do.call("gpar", c(list(fill = fill), gp)))
367
+>>>>>>> bioc/master
308 368
 			}
309 369
 		}
310 370
 
... ...
@@ -347,7 +407,11 @@ SingleAnnotation = function(name, value, col, fun,
347 407
 # == param
348 408
 # -object a `SingleAnnotation-class` object.
349 409
 # -index a vector of orders
410
+<<<<<<< HEAD
350 411
 # -k if row annotation is splitted, the value identifies which row slice. It is only used for the names of the viewport
412
+=======
413
+# -k if row annotation is splitted, the value identifies which row slice. It is only used for the naems of the viewport
414
+>>>>>>> bioc/master
351 415
 #    which contains the annotation graphics.
352 416
 # -n total number of row slices
353 417
 #
... ...
@@ -386,6 +450,7 @@ setMethod(f = "draw",
386 450
 	}
387 451
 	# add annotation name
388 452
 	if(object@name_param$show) {
453
+<<<<<<< HEAD
389 454
         draw_name = TRUE
390 455
         if(object@which == "row") {
391 456
             if(!is.null(k)) {
... ...
@@ -415,6 +480,10 @@ setMethod(f = "draw",
415 480
         			rot = object@name_param$rot, gp = object@name_param$gp)
416 481
             }
417 482
         }
483
+=======
484
+		grid.text(object@name, x = object@name_param$x, y = object@name_param$y, just = object@name_param$just, 
485
+			rot = object@name_param$rot, gp = object@name_param$gp)
486
+>>>>>>> bioc/master
418 487
 	}
419 488
 	upViewport()
420 489
 
... ...
@@ -435,7 +504,11 @@ setMethod(f = "draw",
435 504
 setMethod(f = "show",
436 505
 	signature = "SingleAnnotation",
437 506
 	definition = function(object) {
507
+<<<<<<< HEAD
438 508
 	if(is_fun_annotation(object)) {
509
+=======
510
+	if(is.null(object@color_mapping)) {
511
+>>>>>>> bioc/master
439 512
 		cat("An annotation with self-defined function\n")
440 513
 		cat("name:", object@name, "\n")
441 514
 		cat("position:", object@which, "\n")
... ...
@@ -444,6 +517,7 @@ setMethod(f = "show",
444 517
 		cat("name:", object@name, "\n")
445 518
 		cat("position:", object@which, "\n")
446 519
 		cat("show legend:", object@show_legend, "\n")
520
+<<<<<<< HEAD
447 521
         if(is_matrix_annotation(object)) {
448 522
             cat("a matrix with", attr(object@is_anno_matrix, "k"), "columns\n")
449 523
         }
... ...
@@ -462,3 +536,7 @@ is_matrix_annotation = function(single_anno) {
462 536
 is_fun_annotation = function(single_anno) {
463 537
     is.null(single_anno@color_mapping)
464 538
 }
539
+=======
540
+	}
541
+})
542
+>>>>>>> bioc/master
... ...
@@ -1050,7 +1050,11 @@ column_anno_text = function(...) {
1050 1050
 # == param
1051 1051
 # -at numeric index in the original matrix
1052 1052
 # -labels corresponding labels
1053
+<<<<<<< HEAD
1053 1054
 # -which column annotation or row annotation
1055
+=======
1056
+# -which column annotaiton or row annotation
1057
+>>>>>>> bioc/master
1054 1058
 # -side side of the labels. If it is a column annotation, permitted values are "top" and "bottom";
1055 1059
 #       If it is a row annotation, permitted values are "left" and "right".
1056 1060
 # -lines_gp graphic settings for the segments
... ...
@@ -1137,7 +1141,11 @@ anno_link = function(at, labels, which = c("column", "row"), side = ifelse(which
1137 1141
 					grid.segments(rep(link_width*(1/3), n2), n-i2+1, rep(link_width*(2/3), n2), h, default.units = "native", gp = lines_gp)
1138 1142
 					grid.segments(rep(link_width*(2/3), n2), h, rep(link_width, n2), h, default.units = "native", gp = lines_gp)
1139 1143
 				} else {
1144
+<<<<<<< HEAD
1140 1145
 					grid.text(labels, unit(1, "npc")-rep(link_width, n2), h, default.units = "native", gp = labels_gp, just = "right")
1146
+=======
1147
+					grid.text(labels, rep(link_width, n2), h, default.units = "native", gp = labels_gp, just = "right")
1148
+>>>>>>> bioc/master
1141 1149
 					link_width = link_width - unit(1, "mm")
1142 1150
 					grid.segments(unit(rep(1, n2), "npc"), n-i2+1, unit(1, "npc")-rep(link_width*(1/3), n2), n-i2+1, default.units = "native", gp = lines_gp)
1143 1151
 					grid.segments(unit(1, "npc")-rep(link_width*(1/3), n2), n-i2+1, unit(1, "npc")-rep(link_width*(2/3), n2), h, default.units = "native", gp = lines_gp)
... ...
@@ -1229,6 +1237,7 @@ row_anno_link = function(...) {
1229 1237
 column_anno_link = function(...) {
1230 1238
 	anno_link(..., which = "column")
1231 1239
 }
1240
+<<<<<<< HEAD
1232 1241
 
1233 1242
 
1234 1243
 grid.xaxis = function(main = TRUE, at = NULL, label = NULL, gp = gpar()) {
... ...
@@ -1251,3 +1260,5 @@ grid.xaxis = function(main = TRUE, at = NULL, label = NULL, gp = gpar()) {
1251 1260
 		grid.text(label, at, unit(1, "npc") + unit(rep(1, n), "lines"), rot = 90, just = "left", gp = gp, default.units = "native")
1252 1261
 	}
1253 1262
 }
1263
+=======
1264
+>>>>>>> bioc/master
... ...
@@ -44,11 +44,14 @@
44 44
 #
45 45
 decorate_heatmap_body = function(heatmap, code, slice = 1, envir = new.env(parent = parent.frame())) {
46 46
 
47
+<<<<<<< HEAD
47 48
 	current_vp = current.viewport()$name
48 49
 	if(current_vp == "ROOT") {
49 50
 		current_vp = "global"
50 51
 	}
51 52
 	
53
+=======
54
+>>>>>>> bioc/master
52 55
 	if(is.null(slice)) {
53 56
 		vp_name = paste0(heatmap, "_heatmap_body_", 1)
54 57
 		seekViewport(vp_name)
... ...
@@ -60,7 +63,11 @@ decorate_heatmap_body = function(heatmap, code, slice = 1, envir = new.env(paren
60 63
 
61 64
 	eval(substitute(code), envir = envir)
62 65
 
66
+<<<<<<< HEAD
63 67
 	seekViewport(current_vp)
68
+=======
69
+	seekViewport("global")
70
+>>>>>>> bioc/master
64 71
 }
65 72
 
66 73
 # == title
... ...
@@ -103,11 +110,14 @@ decorate_heatmap_body = function(heatmap, code, slice = 1, envir = new.env(paren
103 110
 decorate_dend = function(heatmap, code, slice = 1, which = c("column", "row"), 
104 111
 	envir = new.env(parent = parent.frame())) {
105 112
 	
113
+<<<<<<< HEAD
106 114
 	current_vp = current.viewport()$name
107 115
 	if(current_vp == "ROOT") {
108 116
 		current_vp = "global"
109 117
 	}
110 118
 
119
+=======
120
+>>>>>>> bioc/master
111 121
 	which = match.arg(which)[1]
112 122
 	if(which == "column") {
113 123
 		vp_name = paste0(heatmap, "_dend_", which)
... ...
@@ -126,7 +136,11 @@ decorate_dend = function(heatmap, code, slice = 1, which = c("column", "row"),
126 136
 	e = new.env(parent = parent.frame())
127 137
 	eval(substitute(code), envir = e)
128 138
 
139
+<<<<<<< HEAD
129 140
 	seekViewport(current_vp)
141
+=======
142
+	seekViewport("global")
143
+>>>>>>> bioc/master
130 144
 }
131 145
 
132 146
 # == title
... ...
@@ -222,11 +236,14 @@ decorate_row_dend = function(..., envir = new.env(parent = parent.frame())) {
222 236
 decorate_dimnames = function(heatmap, code, slice = 1, which = c("column", "row"), 
223 237
 	envir = new.env(parent = parent.frame())) {
224 238
 	
239
+<<<<<<< HEAD
225 240
 	current_vp = current.viewport()$name
226 241
 	if(current_vp == "ROOT") {
227 242
 		current_vp = "global"
228 243
 	}
229 244
 
245
+=======
246
+>>>>>>> bioc/master
230 247
 	which = match.arg(which)[1]
231 248
 	if(which == "column") {
232 249
 		vp_name = paste0(heatmap, "_", which, "_names")
... ...
@@ -243,7 +260,11 @@ decorate_dimnames = function(heatmap, code, slice = 1, which = c("column", "row"
243 260
 
244 261
 	seekViewport(vp_name)
245 262
 	eval(substitute(code), envir = envir)
263
+<<<<<<< HEAD
246 264
 	seekViewport(current_vp)
265
+=======
266
+	seekViewport("global")
267
+>>>>>>> bioc/master
247 268
 }
248 269
 
249 270
 # == title
... ...
@@ -327,11 +348,14 @@ decorate_column_names = function(..., envir = new.env(parent = parent.frame()))
327 348
 decorate_title = function(heatmap, code, slice = 1, which = c("column", "row"), 
328 349
 	envir = new.env(parent = parent.frame())) {
329 350
 	
351
+<<<<<<< HEAD
330 352
 	current_vp = current.viewport()$name
331 353
 	if(current_vp == "ROOT") {
332 354
 		current_vp = "global"
333 355
 	}
334 356
 
357
+=======
358
+>>>>>>> bioc/master
335 359
 	which = match.arg(which)[1]
336 360
 	if(which == "column") {
337 361
 		vp_name = paste0(heatmap, "_", which, "_title")
... ...
@@ -348,7 +372,11 @@ decorate_title = function(heatmap, code, slice = 1, which = c("column", "row"),
348 372
 
349 373
 	seekViewport(vp_name)
350 374
 	eval(substitute(code), envir = envir)
375
+<<<<<<< HEAD
351 376
 	seekViewport(current_vp)
377
+=======
378
+	seekViewport("global")
379
+>>>>>>> bioc/master
352 380
 }
353 381
 
354 382
 # == title
... ...
@@ -436,11 +464,14 @@ decorate_column_title = function(..., envir = new.env(parent = parent.frame()))
436 464
 #
437 465
 decorate_annotation = function(annotation, code, slice, envir = new.env(parent = parent.frame())) {
438 466
 
467
+<<<<<<< HEAD
439 468
 	current_vp = current.viewport()$name
440 469
 	if(current_vp == "ROOT") {
441 470
 		current_vp = "global"
442 471
 	}
443 472
 	
473
+=======
474
+>>>>>>> bioc/master
444 475
 	if(missing(slice)) {
445 476
 		vp_name = paste0("annotation_", annotation)
446 477
 		o = try(seekViewport(vp_name), silent = TRUE)
... ...
@@ -465,6 +496,10 @@ decorate_annotation = function(annotation, code, slice, envir = new.env(parent =
465 496
 	}
466 497
 
467 498
 	eval(substitute(code), envir = envir)
499
+<<<<<<< HEAD
468 500
 	seekViewport(current_vp)
501
+=======
502
+	seekViewport("global")
503
+>>>>>>> bioc/master
469 504
 }
470 505
 
... ...
@@ -5,7 +5,10 @@
5 5
 # == param
6 6
 # -data  a matrix or a list. If it is a matrix, density will be calculated by columns.
7 7
 # -col a list of colors that density values are mapped to.
8
+<<<<<<< HEAD
8 9
 # -density_param parameters send to `stats::density`, ``na.rm`` is enforced to ``TRUE``.
10
+=======
11
+>>>>>>> bioc/master
9 12
 # -color_space the color space in which colors are interpolated. Pass to `circlize::colorRamp2`.
10 13
 # -anno annotation for the matrix columns or the list. The value should be a vector or a data frame 
11 14
 #       and colors for annotations are randomly assigned. If you want to customize the annotation colors,
... ...
@@ -34,9 +37,12 @@
34 37
 # in each column (or each vector in the list) through a heatmap. It is useful if you have huge number 
35 38
 # of columns in ``data`` to visualize.
36 39
 #
40
+<<<<<<< HEAD
37 41
 # The density matrix is generated with 500 rows ranging between the maximun and minimal values in all densities.
38 42
 # The density values in each row are linearly intepolated between the two density values at the two nearest bounds.
39 43
 #
44
+=======
45
+>>>>>>> bioc/master
40 46
 # == value
41 47
 # No value is returned.
42 48
 #
... ...
@@ -58,7 +64,10 @@
58 64
 #
59 65
 densityHeatmap = function(data, 
60 66
 	col = rev(brewer.pal(11, "Spectral")),
67
+<<<<<<< HEAD
61 68
 	density_param = list(na.rm = TRUE),
69
+=======
70
+>>>>>>> bioc/master
62 71
 	color_space = "LAB", 
63 72
 	anno = NULL, 
64 73
 	ylab = deparse(substitute(data)), 
... ...
@@ -79,6 +88,7 @@ densityHeatmap = function(data,
79 88
 	column_order = NULL,
80 89
 	...) {
81 90
 
91
+<<<<<<< HEAD
82 92
 	density_param$na.rm = TRUE
83 93
 
84 94
 	if(is.matrix(data)) {
... ...
@@ -87,6 +97,14 @@ densityHeatmap = function(data,
87 97
 		mean_value = apply(data, 2, mean, na.rm = TRUE)
88 98
 	} else if(is.data.frame(data) || is.list(data)) {
89 99
 		density_list = lapply(data, function(x) do.call(density, c(list(x = x), density_param)))
100
+=======
101
+	if(is.matrix(data)) {
102
+		density_list = apply(data, 2, density, na.rm = TRUE)
103
+		quantile_list = apply(data, 2, quantile, na.rm = TRUE)
104
+		mean_value = apply(data, 2, mean, na.rm = TRUE)
105
+	} else if(is.data.frame(data) || is.list(data)) {
106
+		density_list = lapply(data, density, na.rm = TRUE)
107
+>>>>>>> bioc/master
90 108
 		quantile_list = sapply(data, quantile, na.rm = TRUE)
91 109
 		mean_value = sapply(data, mean, na.rm = TRUE)
92 110
 	} else {
... ...
@@ -16,6 +16,10 @@
16 16
 #                            Set it to ``NULL`` if you don't want to set the order
17 17
 # -column_order order of samples. By default the order is calculated by the 'memo sort' method which can visualize
18 18
 #                                 the mutual exclusivity across genes. Set it to ``NULL`` if you don't want to set the order
19
+<<<<<<< HEAD
20
+=======
21
+# -show_column_names whether show column names
22
+>>>>>>> bioc/master
19 23
 # -show_pct whether show percent values on the left of the oncoprint
20 24
 # -pct_gp graphic paramters for percent row annotation
21 25
 # -pct_digits digits for percent values
... ...
@@ -25,6 +29,7 @@
25 29
 # -remove_empty_columns if there is no alteration in that sample, whether remove it on the heatmap
26 30
 # -heatmap_legend_param pass to `Heatmap`
27 31
 # -top_annotation by default the top annotation contains barplots representing frequency of mutations in every sample.
32
+<<<<<<< HEAD
28 33
 # -top_annotation_height total height of the column annotations on the top.
29 34
 # -bottom_annotation a `HeatmapAnnotation` object.
30 35
 # -bottom_annotation_height total height of the column annotations on the bottom.
... ...
@@ -50,6 +55,10 @@
50 55
 #                 The input parameter for this function is a vector which contains level names under each column in ``split``.
51 56
 # -width the width of the single heatmap, should be a fixed `grid::unit` object. It is used for the layout when the heatmap
52 57
 #        is appended to a list of heatmaps.
58
+=======
59
+# -barplot_ignore specific alterations that you don't want to put on the barplots. If you want to really suppress the top barplot
60
+#        set ``top_annotation`` to ``NULL``.
61
+>>>>>>> bioc/master
53 62
 # -... pass to `Heatmap`, so can set ``bottom_annotation`` here.
54 63
 #
55 64
 # == details
... ...
@@ -73,7 +82,12 @@ oncoPrint = function(mat, get_type = function(x) x,
73 82
 	alter_fun = alter_fun_list, alter_fun_list = NULL, col, 
74 83
 	row_order = oncoprint_row_order(),
75 84
 	column_order = oncoprint_column_order(),
85
+<<<<<<< HEAD
76 86
 	show_pct = TRUE, pct_gp = row_names_gp, pct_digits = 0,
87
+=======
88
+	show_column_names = FALSE,
89
+	show_pct = TRUE, pct_gp = gpar(), pct_digits = 0,
90
+>>>>>>> bioc/master
77 91
 	axis_gp = gpar(fontsize = 8), 
78 92
 	show_row_barplot = TRUE, 
79 93
 	row_barplot_width = unit(2, "cm"),
... ...
@@ -81,6 +95,7 @@ oncoPrint = function(mat, get_type = function(x) x,
81 95
 	heatmap_legend_param = list(title = "Alterations"),
82 96
 	top_annotation = HeatmapAnnotation(column_bar = anno_oncoprint_barplot(), 
83 97
 		annotation_height = unit(2, "cm")),
98
+<<<<<<< HEAD
84 99
 	top_annotation_height = top_annotation@size,
85 100
 	bottom_annotation = new("HeatmapAnnotation"),
86 101
     bottom_annotation_height = bottom_annotation@size,
... ...
@@ -101,6 +116,9 @@ oncoPrint = function(mat, get_type = function(x) x,
101 116
     gap = unit(1, "mm"),
102 117
     combined_name_fun = function(x) paste(x, collapse = "/"),
103 118
     width = NULL,
119
+=======
120
+	barplot_ignore = NULL,
121
+>>>>>>> bioc/master
104 122
 	...) {
105 123
 
106 124
 	if(length(names(list(...))) > 0) {
... ...
@@ -322,6 +340,7 @@ oncoPrint = function(mat, get_type = function(x) x,
322 340
 			z = arr[i, j, ]
323 341
 			names(z) = dimnames(arr)[[3]]
324 342
 			af(x, y, width, height, z)
343
+<<<<<<< HEAD
325 344
 		},
326 345
 		top_annotation = top_annotation,
327 346
 		top_annotation_height = top_annotation_height,
... ...
@@ -345,6 +364,11 @@ oncoPrint = function(mat, get_type = function(x) x,
345 364
 		combined_name_fun = combined_name_fun,
346 365
 		width = width,
347 366
 		...)
367
+=======
368
+		}, show_column_names = show_column_names,
369
+		top_annotation = top_annotation,
370
+		heatmap_legend_param = heatmap_legend_param, ...)
371
+>>>>>>> bioc/master
348 372
 
349 373
 	ht@matrix_param$oncoprint = list()
350 374
 	ht@matrix_param$oncoprint$arr = arr
... ...
@@ -400,7 +424,11 @@ unify_mat_list = function(mat_list, default = 0) {
400 424
 
401 425
 
402 426
 # == title
427
+<<<<<<< HEAD
403 428
 # Column barplot annotation for oncoPrint
429
+=======
430
+# Column barplot annotaiton for oncoPrint
431
+>>>>>>> bioc/master
404 432
 #
405 433
 # == details
406 434
 # This function is only used for column annotation
... ...
@@ -2,12 +2,16 @@
2 2
 # environment that contains global variables
3 3
 INDEX_ENV = new.env()
4 4
 
5
+<<<<<<< HEAD
5 6
 INDEX_ENV$I_FIGURE = 0
7
+=======
8
+>>>>>>> bioc/master
6 9
 INDEX_ENV$I_HEATMAP = 0
7 10
 INDEX_ENV$I_ANNOTATION = 0
8 11
 INDEX_ENV$I_ROW_ANNOTATION = 0
9 12
 INDEX_ENV$I_COLOR_MAPPING = 0
10 13
 
14
+<<<<<<< HEAD
11 15
 get_figure_index = function() {
12 16
     INDEX_ENV$I_FIGURE
13 17
 }
... ...
@@ -16,6 +20,8 @@ increase_figure_index = function() {
16 20
     INDEX_ENV$I_FIGURE = INDEX_ENV$I_FIGURE + 1
17 21
 }
18 22
 
23
+=======
24
+>>>>>>> bioc/master
19 25
 get_heatmap_index = function() {
20 26
 	INDEX_ENV$I_HEATMAP
21 27
 }
... ...
@@ -66,8 +72,12 @@ default_col = function(x, main_matrix = FALSE) {
66 72
 
67 73
     if(is.character(x)) {  # discrete
68 74
         levels = unique(x)
75
+<<<<<<< HEAD
69 76
         #colors = hsv(runif(length(levels)), 1-runif(1)/2, 1-runif(1)/2)
70 77
         colors = rand_color(length(levels), luminosity = sample(c("bright", "light", "dark", "random"), 1))
78
+=======
79
+        colors = hsv(runif(length(levels)), 1-runif(1)/2, 1-runif(1)/2)
80
+>>>>>>> bioc/master
71 81
         names(colors) = levels
72 82
         return(colors)
73 83
     } else if(is.numeric(x)) {
... ...
@@ -78,8 +88,12 @@ default_col = function(x, main_matrix = FALSE) {
78 88
                 col_fun = colorRamp2(seq(min(x), max(x), length = 3), c("blue", "#EEEEEE", "red"))
79 89
             }
80 90
         } else {
91
+<<<<<<< HEAD
81 92
             #col_fun = colorRamp2(range(min(x), max(x)), c("white", hsv(runif(1), 1, 1)))
82 93
             col_fun = colorRamp2(range(min(x), max(x)), c("white", rand_color(1, luminosity = sample(c("bright", "dark"), 1))))
94
+=======
95
+            col_fun = colorRamp2(range(min(x), max(x)), c("white", hsv(runif(1), 1, 1)))
96
+>>>>>>> bioc/master
83 97
         }
84 98
         return(col_fun)
85 99
     }
... ...
@@ -133,6 +147,11 @@ grid.dendrogram = function(dend, facing = c("bottom", "top", "left", "right"),
133 147
             leaf
134 148
         }
135 149
     }
150
+<<<<<<< HEAD
151
+=======
152
+
153
+    labels(dend) = paste0("leaf_", seq_len(nnodes(dend)))
154
+>>>>>>> bioc/master
136 155
     
137 156
     draw.d = function(dend, max_height, facing = "bottom", order = "normal", max_width = 0, env = NULL) {
138 157
         leaf = attr(dend, "leaf")
... ...
@@ -283,6 +302,7 @@ grid.dendrogram = function(dend, facing = c("bottom", "top", "left", "right"),
283 302
 }
284 303
 
285 304
 # == title
305
+<<<<<<< HEAD
286 306
 # Adjust dendrogram based on width of leaves
287 307
 #
288 308
 # == param
... ...
@@ -564,6 +584,8 @@ grid.dendrogram2 = function(dend, facing = c("bottom", "top", "left", "right"),
564 584
 }
565 585
 
566 586
 # == title
587
+=======
588
+>>>>>>> bioc/master
567 589
 # Calculate pairwise distance from a matrix
568 590
 #
569 591
 # == param
... ...
@@ -654,12 +676,17 @@ get_dend_order = function(x) {
654 676
 
655 677
 # can only cut dendrogram for which branches at every node are two
656 678
 cut_dendrogram = function(dend, k) {
679
+<<<<<<< HEAD
657 680
     h = sort(dend_branches_heights(dend), decreasing = TRUE)
681
+=======
682
+    h = sort(get_branches_heights(dend), decreasing = TRUE)
683
+>>>>>>> bioc/master
658 684
     height = (h[k-1] + h[k])/2
659 685
     trees = cut(dend, h = height)
660 686
     trees$lower
661 687
 }
662 688
 
689
+<<<<<<< HEAD
663 690
 dend_branches_heights = function(d, v = NULL) {
664 691
     if(!is.leaf(d)) {
665 692
         v = c(v, attr(d, "height"))
... ...
@@ -669,6 +696,8 @@ dend_branches_heights = function(d, v = NULL) {
669 696
     return(v)
670 697
 }
671 698
 
699
+=======
700
+>>>>>>> bioc/master
672 701
 recycle_gp = function(gp, n = 1) {
673 702
     for(i in seq_along(gp)) {
674 703
         x = gp[[i]]
... ...
@@ -789,9 +818,12 @@ list_component = function() {
789 818
 # max_text_width(x, gp = gpar(fontsize = 10))
790 819
 #
791 820
 max_text_width = function(text, ...) {
821
+<<<<<<< HEAD
792 822
     if(is.null(text)) {
793 823
         return(unit(0, "mm"))
794 824
     }
825
+=======
826
+>>>>>>> bioc/master
795 827
     max(do.call("unit.c", lapply(text, function(x) grobWidth(textGrob(x, ...)))))
796 828
 }
797 829
 
... ...
@@ -819,8 +851,11 @@ max_text_width = function(text, ...) {
819 851
 # max_text_height(x, gp = gpar(fontsize = 10))
820 852
 #
821 853
 max_text_height = function(text, ...) {
854
+<<<<<<< HEAD
822 855
     if(is.null(text)) {
823 856
         return(unit(0, "mm"))
824 857
     }
858
+=======
859
+>>>>>>> bioc/master
825 860
     max(do.call("unit.c", lapply(text, function(x) grobHeight(textGrob(x, ...)))))
826 861
 }
... ...
@@ -11,7 +11,11 @@ Heatmap(matrix, col, name,
11 11
     na_col = "grey",
12 12
     color_space = "LAB",
13 13
     rect_gp = gpar(col = NA),
14
+<<<<<<< HEAD
14 15
     cell_fun = NULL,
16
+=======
17
+    cell_fun = function(j, i, x, y, width, height, fill) NULL,
18
+>>>>>>> bioc/master
15 19
     row_title = character(0),
16 20
     row_title_side = c("left", "right"),
17 21
     row_title_gp = gpar(fontsize = 14),
... ...
@@ -50,11 +54,19 @@ Heatmap(matrix, col, name,
50 54
     column_order = NULL,
51 55
     row_names_side = c("right", "left"),
52 56
     show_row_names = TRUE,
57
+<<<<<<< HEAD
53 58
     row_names_max_width = default_row_names_max_width(),
54 59
     row_names_gp = gpar(fontsize = 12),
55 60
     column_names_side = c("bottom", "top"),
56 61
     show_column_names = TRUE,
57 62
     column_names_max_height = default_column_names_max_height(),
63
+=======
64
+    row_names_max_width = unit(4, "cm"),
65
+    row_names_gp = gpar(fontsize = 12),
66
+    column_names_side = c("bottom", "top"),
67
+    show_column_names = TRUE,
68
+    column_names_max_height = unit(4, "cm"),
69
+>>>>>>> bioc/master
58 70
     column_names_gp = gpar(fontsize = 12),
59 71
     top_annotation = new("HeatmapAnnotation"),
60 72
     top_annotation_height = top_annotation@size,
... ...
@@ -67,7 +79,11 @@ Heatmap(matrix, col, name,
67 79
     combined_name_fun = function(x) paste(x, collapse = "/"),
68 80
     width = NULL,
69 81
     show_heatmap_legend = TRUE,
82
+<<<<<<< HEAD
70 83
     heatmap_legend_param = list(title = name),
84
+=======
85
+    heatmap_legend_param = list(title = name, color_bar = "discrete"),
86
+>>>>>>> bioc/master
71 87
     use_raster = FALSE,
72 88
     raster_device = c("png", "jpeg", "tiff", "CairoPNG", "CairoJPEG", "CairoTIFF"),
73 89
     raster_quality = 1,
... ...
@@ -131,14 +147,22 @@ Heatmap(matrix, col, name,
131 147
   \item{bottom_annotation}{a \code{\link{HeatmapAnnotation}} object.}
132 148
   \item{bottom_annotation_height}{total height of the column annotations on the bottom.}
133 149
   \item{km}{do k-means clustering on rows. If the value is larger than 1, the heatmap will be split by rows according to the k-means clustering. For each row-clusters, hierarchical clustering is still applied with parameters above.}
150
+<<<<<<< HEAD
134 151
   \item{km_title}{row title for each cluster when \code{km} is set. It must a text with format of ".*\%i.*" where "\%i" is replaced by the index of the cluster.}
152
+=======
153
+  \item{km_title}{row title for each cluster when \code{km} is set. It must a text with format of "*\%i*" where "\%i" is replaced by the index of the cluster.}
154
+>>>>>>> bioc/master
135 155
   \item{split}{a vector or a data frame by which the rows are split. But if \code{cluster_rows} is a clustering object, \code{split} can be a single number indicating rows are to be split according to the split on the tree.}
136 156
   \item{gap}{gap between row-slices if the heatmap is split by rows, should be \code{\link[grid]{unit}} object. If it is a vector, the order corresponds to top to bottom in the heatmap}
137 157
   \item{combined_name_fun}{if the heatmap is split by rows, how to make a combined row title for each slice? The input parameter for this function is a vector which contains level names under each column in \code{split}.}
138 158
   \item{width}{the width of the single heatmap, should be a fixed \code{\link[grid]{unit}} object. It is used for the layout when the heatmap is appended to a list of heatmaps.}
139 159
   \item{show_heatmap_legend}{whether show heatmap legend?}
140 160
   \item{heatmap_legend_param}{a list contains parameters for the heatmap legend. See \code{\link{color_mapping_legend,ColorMapping-method}} for all available parameters.}
161
+<<<<<<< HEAD
141 162
   \item{use_raster}{whether render the heatmap body as a raster image. It helps to reduce file size when the matrix is huge. Note if \code{cell_fun} is set, \code{use_raster} is enforced to be \code{FALSE}.}
163
+=======
164
+  \item{use_raster}{whether render the heatmap body as a raster image. It helps to reduce file size when the matrix is huge.}
165
+>>>>>>> bioc/master
142 166
   \item{raster_device}{graphic device which is used to generate the raster image}
143 167
   \item{raster_quality}{a value set to larger than 1 will improve the quality of the raster image.}
144 168
   \item{raster_device_param}{a list of further parameters for the selected graphic device}
... ...
@@ -11,8 +11,13 @@ Method dispatch page for \code{add_heatmap}.
11 11
 
12 12
 \itemize{
13 13
 \item \code{\link{add_heatmap,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
14
+<<<<<<< HEAD
14 15
 \item \code{\link{add_heatmap,Heatmap-method}}, \code{\link{Heatmap-class}} class method
15 16
 \item \code{\link{add_heatmap,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
17
+=======
18
+\item \code{\link{add_heatmap,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
19
+\item \code{\link{add_heatmap,Heatmap-method}}, \code{\link{Heatmap-class}} class method
20
+>>>>>>> bioc/master
16 21
 }
17 22
 }
18 23
 \examples{
... ...
@@ -14,7 +14,11 @@ anno_link(at, labels, which = c("column", "row"), side = ifelse(which == "column
14 14
 
15 15
   \item{at}{numeric index in the original matrix}
16 16
   \item{labels}{corresponding labels}
17
+<<<<<<< HEAD
17 18
   \item{which}{column annotation or row annotation}
19
+=======
20
+  \item{which}{column annotaiton or row annotation}
21
+>>>>>>> bioc/master
18 22
   \item{side}{side of the labels. If it is a column annotation, permitted values are "top" and "bottom"; If it is a row annotation, permitted values are "left" and "right".}
19 23
   \item{lines_gp}{graphic settings for the segments}
20 24
   \item{labels_gp}{graphic settings for the labels}
... ...
@@ -1,10 +1,17 @@
1 1
 \name{anno_oncoprint_barplot}
2 2
 \alias{anno_oncoprint_barplot}
3 3
 \title{
4
+<<<<<<< HEAD
4 5
 Column barplot annotation for oncoPrint
5 6
 }
6 7
 \description{
7 8
 Column barplot annotation for oncoPrint
9
+=======
10
+Column barplot annotaiton for oncoPrint
11
+}
12
+\description{
13
+Column barplot annotaiton for oncoPrint
14
+>>>>>>> bioc/master
8 15
 }
9 16
 \usage{
10 17
 anno_oncoprint_barplot()
... ...
@@ -13,10 +13,17 @@ Draw legend based on color mapping
13 13
     title = object@name,
14 14
     title_gp = gpar(fontsize = 10, fontface = "bold"),
15 15
     title_position = c("topleft", "topcenter", "leftcenter", "lefttop"),
16
+<<<<<<< HEAD
16 17
     color_bar = object@type,
17 18
     grid_height = unit(4, "mm"),
18 19
     grid_width = unit(4, "mm"),
19 20
     border = NULL,
21
+=======
22
+    color_bar = c("discrete", "continuous"),
23
+    grid_height = unit(4, "mm"),
24
+    grid_width = unit(4, "mm"),
25
+    grid_border = NULL,
26
+>>>>>>> bioc/master
20 27
     at = object@levels,
21 28
     labels = at,
22 29
     labels_gp = gpar(fontsize = 10),
... ...
@@ -33,10 +40,17 @@ Draw legend based on color mapping
33 40
   \item{title}{title of the legend, by default it is the name of the legend}
34 41
   \item{title_gp}{graphical parameters for legend title}
35 42
   \item{title_position}{position of the title}
43
+<<<<<<< HEAD
36 44
   \item{color_bar}{a string of "continous" or "discrete". If the mapping is continuous, whether show the legend as discrete color bar or continuous color bar}
37 45
   \item{grid_height}{height of each legend grid.}
38 46
   \item{grid_width}{width of each legend grid.}
39 47
   \item{border}{color for legend grid borders.}
48
+=======
49
+  \item{color_bar}{if the mapping is continuous, whether show the legend as discrete color bar or continuous color bar}
50
+  \item{grid_height}{height of each legend grid.}
51
+  \item{grid_width}{width of each legend grid.}
52
+  \item{grid_border}{color for legend grid borders.}
53
+>>>>>>> bioc/master
40 54
   \item{at}{break values of the legend}
41 55
   \item{labels}{labels corresponding to break values}
42 56
   \item{labels_gp}{graphcial parameters for legend labels}
... ...
@@ -10,8 +10,13 @@ Method dispatch page for \code{component_height}.
10 10
 \code{component_height} can be dispatched on following classes:
11 11
 
12 12
 \itemize{
13
+<<<<<<< HEAD
13 14
 \item \code{\link{component_height,Heatmap-method}}, \code{\link{Heatmap-class}} class method
14 15
 \item \code{\link{component_height,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
16
+=======
17
+\item \code{\link{component_height,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
18
+\item \code{\link{component_height,Heatmap-method}}, \code{\link{Heatmap-class}} class method
19
+>>>>>>> bioc/master
15 20
 }
16 21
 }
17 22
 \examples{
... ...
@@ -10,8 +10,13 @@ Method dispatch page for \code{component_width}.
10 10
 \code{component_width} can be dispatched on following classes:
11 11
 
12 12
 \itemize{
13
+<<<<<<< HEAD
13 14
 \item \code{\link{component_width,Heatmap-method}}, \code{\link{Heatmap-class}} class method
14 15
 \item \code{\link{component_width,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
16
+=======
17
+\item \code{\link{component_width,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
18
+\item \code{\link{component_width,Heatmap-method}}, \code{\link{Heatmap-class}} class method
19
+>>>>>>> bioc/master
15 20
 }
16 21
 }
17 22
 \examples{
... ...
@@ -9,7 +9,10 @@ Use colors to represent density distribution
9 9
 \usage{
10 10
 densityHeatmap(data,
11 11
     col = rev(brewer.pal(11, "Spectral")),
12
+<<<<<<< HEAD
12 13
     density_param = list(na.rm = TRUE),
14
+=======
15
+>>>>>>> bioc/master
13 16
     color_space = "LAB",
14 17
     anno = NULL,
15 18
     ylab = deparse(substitute(data)),
... ...
@@ -34,7 +37,10 @@ densityHeatmap(data,
34 37
 
35 38
   \item{data}{a matrix or a list. If it is a matrix, density will be calculated by columns.}
36 39
   \item{col}{a list of colors that density values are mapped to.}
40
+<<<<<<< HEAD
37 41
   \item{density_param}{parameters send to \code{\link[stats]{density}}, \code{na.rm} is enforced to \code{TRUE}.}
42
+=======
43
+>>>>>>> bioc/master
38 44
   \item{color_space}{the color space in which colors are interpolated. Pass to \code{\link[circlize]{colorRamp2}}.}
39 45
   \item{anno}{annotation for the matrix columns or the list. The value should be a vector or a data frame  and colors for annotations are randomly assigned. If you want to customize the annotation colors, use a \code{\link{HeatmapAnnotation-class}} object directly.}
40 46
   \item{ylab}{label on y-axis in the plot}
... ...
@@ -61,9 +67,12 @@ To visualize data distribution in a matrix or in a list, sometimes we use boxplo
61 67
 Here we use colors to map the density values and visualize distribution of values
62 68
 in each column (or each vector in the list) through a heatmap. It is useful if you have huge number 
63 69
 of columns in \code{data} to visualize.
70
+<<<<<<< HEAD
64 71
 
65 72
 The density matrix is generated with 500 rows ranging between the maximun and minimal values in all densities.
66 73
 The density values in each row are linearly intepolated between the two density values at the two nearest bounds.
74
+=======
75
+>>>>>>> bioc/master
67 76
 }
68 77
 \value{
69 78
 No value is returned.
... ...
@@ -13,7 +13,11 @@ Draw the single annotation
13 13
 
14 14
   \item{object}{a \code{\link{SingleAnnotation-class}} object.}
15 15
   \item{index}{a vector of orders}
16
+<<<<<<< HEAD
16 17
   \item{k}{if row annotation is splitted, the value identifies which row slice. It is only used for the names of the viewport which contains the annotation graphics.}
18
+=======
19
+  \item{k}{if row annotation is splitted, the value identifies which row slice. It is only used for the naems of the viewport which contains the annotation graphics.}
20
+>>>>>>> bioc/master
17 21
   \item{n}{total number of row slices}
18 22
 
19 23
 }
... ...
@@ -10,9 +10,15 @@ Method dispatch page for \code{draw}.
10 10
 \code{draw} can be dispatched on following classes:
11 11
 
12 12
 \itemize{
13
+<<<<<<< HEAD
13 14
 \item \code{\link{draw,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
14 15
 \item \code{\link{draw,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
15 16
 \item \code{\link{draw,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method
17
+=======
18
+\item \code{\link{draw,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
19
+\item \code{\link{draw,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method
20
+\item \code{\link{draw,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
21
+>>>>>>> bioc/master
16 22
 \item \code{\link{draw,Heatmap-method}}, \code{\link{Heatmap-class}} class method
17 23
 }
18 24
 }
... ...
@@ -14,7 +14,10 @@ Make layout for the complete plot
14 14
     column_title_side = c("top", "bottom"),
15 15
     column_title_gp = gpar(fontsize = 14),
16 16
     heatmap_legend_side = c("right", "left", "bottom", "top"),
17
+<<<<<<< HEAD
17 18
     merge_legends = FALSE,
19
+=======
20
+>>>>>>> bioc/master
18 21
     show_heatmap_legend = TRUE,
19 22
     heatmap_legend_list = list(),
20 23
     annotation_legend_side = c("right", "left", "bottom", "top"),
... ...
@@ -34,8 +37,12 @@ Make layout for the complete plot
34 37
     row_dend_gp = NULL,
35 38
     row_order = NULL,
36 39
     km = NULL,
40
+<<<<<<< HEAD
37 41
     split = NULL,
38 42
     combined_name_fun = NULL)
43
+=======
44
+    split = NULL)
45
+>>>>>>> bioc/master
39 46
 }
40 47
 \arguments{
41 48
 
... ...
@@ -47,7 +54,10 @@ Make layout for the complete plot
47 54
   \item{column_title_side}{will the title be put on the top or bottom of the heatmap.}
48 55
   \item{column_title_gp}{graphic parameters for drawing text.}
49 56
   \item{heatmap_legend_side}{side of the heatmap legend.}
57
+<<<<<<< HEAD
50 58
   \item{merge_legends}{whether put heatmap legends and annotation legends in a same column}
59
+=======
60
+>>>>>>> bioc/master
51 61
   \item{show_heatmap_legend}{whether show heatmap legend.}
52 62
   \item{heatmap_legend_list}{a list of self-defined legend, should be wrapped into \code{\link[grid]{grob}} objects.}
53 63
   \item{annotation_legend_side}{side of annotation legend.}
... ...
@@ -68,7 +78,10 @@ Make layout for the complete plot
68 78
   \item{row_order}{same setting as in \code{\link{Heatmap}}, if it is specified, \code{row_order} in main heatmap is ignored.}
69 79
   \item{km}{same setting as in \code{\link{Heatmap}}, if it is specified, \code{km} in main heatmap is ignored.}
70 80
   \item{split}{same setting as in \code{\link{Heatmap}}, if it is specified, \code{split} in main heatmap is ignored.}
81
+<<<<<<< HEAD
71 82
   \item{combined_name_fun}{same setting as in \code{\link{Heatmap}}, if it is specified, \code{combined_name_fun} in main heatmap is ignored.}
83
+=======
84
+>>>>>>> bioc/master
72 85
 
73 86
 }
74 87
 \details{
... ...
@@ -11,7 +11,12 @@ oncoPrint(mat, get_type = function(x) x,
11 11
     alter_fun = alter_fun_list, alter_fun_list = NULL, col,
12 12
     row_order = oncoprint_row_order(),
13 13
     column_order = oncoprint_column_order(),
14
+<<<<<<< HEAD
14 15
     show_pct = TRUE, pct_gp = row_names_gp, pct_digits = 0,
16
+=======
17
+    show_column_names = FALSE,
18
+    show_pct = TRUE, pct_gp = gpar(), pct_digits = 0,
19
+>>>>>>> bioc/master
15 20
     axis_gp = gpar(fontsize = 8),
16 21
     show_row_barplot = TRUE,
17 22
     row_barplot_width = unit(2, "cm"),
... ...
@@ -19,6 +24,7 @@ oncoPrint(mat, get_type = function(x) x,
19 24
     heatmap_legend_param = list(title = "Alterations"),
20 25
     top_annotation = HeatmapAnnotation(column_bar = anno_oncoprint_barplot(),
21 26
     annotation_height = unit(2, "cm")),
27
+<<<<<<< HEAD
22 28
     top_annotation_height = top_annotation@size,
23 29
     bottom_annotation = new("HeatmapAnnotation"),
24 30
     bottom_annotation_height = bottom_annotation@size,
... ...
@@ -39,6 +45,9 @@ oncoPrint(mat, get_type = function(x) x,
39 45
     gap = unit(1, "mm"),
40 46
     combined_name_fun = function(x) paste(x, collapse = "/"),
41 47
     width = NULL,
48
+=======
49
+    barplot_ignore = NULL,
50
+>>>>>>> bioc/master
42 51
     ...)
43 52
 }
44 53
 \arguments{
... ...
@@ -50,6 +59,10 @@ oncoPrint(mat, get_type = function(x) x,
50 59
   \item{col}{a vector of color for which names correspond to alteration types.}
51 60
   \item{row_order}{order of genes. By default it is sorted by frequency of alterations decreasingly. Set it to \code{NULL} if you don't want to set the order}
52 61
   \item{column_order}{order of samples. By default the order is calculated by the 'memo sort' method which can visualize the mutual exclusivity across genes. Set it to \code{NULL} if you don't want to set the order}
62
+<<<<<<< HEAD
63
+=======
64
+  \item{show_column_names}{whether show column names}
65
+>>>>>>> bioc/master
53 66
   \item{show_pct}{whether show percent values on the left of the oncoprint}
54 67
   \item{pct_gp}{graphic paramters for percent row annotation}
55 68
   \item{pct_digits}{digits for percent values}
... ...
@@ -59,6 +72,7 @@ oncoPrint(mat, get_type = function(x) x,
59 72
   \item{remove_empty_columns}{if there is no alteration in that sample, whether remove it on the heatmap}
60 73
   \item{heatmap_legend_param}{pass to \code{\link{Heatmap}}}
61 74
   \item{top_annotation}{by default the top annotation contains barplots representing frequency of mutations in every sample.}
75
+<<<<<<< HEAD
62 76
   \item{top_annotation_height}{total height of the column annotations on the top.}
63 77
   \item{bottom_annotation}{a \code{\link{HeatmapAnnotation}} object.}
64 78
   \item{bottom_annotation_height}{total height of the column annotations on the bottom.}
... ...
@@ -79,6 +93,9 @@ oncoPrint(mat, get_type = function(x) x,
79 93
   \item{gap}{gap between row-slices if the heatmap is split by rows, should be \code{\link[grid]{unit}} object. If it is a vector, the order corresponds to top to bottom in the heatmap}
80 94
   \item{combined_name_fun}{if the heatmap is split by rows, how to make a combined row title for each slice? The input parameter for this function is a vector which contains level names under each column in \code{split}.}
81 95
   \item{width}{the width of the single heatmap, should be a fixed \code{\link[grid]{unit}} object. It is used for the layout when the heatmap is appended to a list of heatmaps.}
96
+=======
97
+  \item{barplot_ignore}{specific alterations that you don't want to put on the barplots. If you want to really suppress the top barplot set \code{top_annotation} to \code{NULL}.}
98
+>>>>>>> bioc/master
82 99
   \item{...}{pass to \code{\link{Heatmap}}, so can set \code{bottom_annotation} here.}
83 100
 
84 101
 }
... ...
@@ -10,10 +10,17 @@ Method dispatch page for \code{show}.
10 10
 \code{show} can be dispatched on following classes:
11 11
 
12 12
 \itemize{
13
+<<<<<<< HEAD
13 14
 \item \code{\link{show,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
14 15
 \item \code{\link{show,ColorMapping-method}}, \code{\link{ColorMapping-class}} class method
15 16
 \item \code{\link{show,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
16 17
 \item \code{\link{show,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method
18
+=======
19
+\item \code{\link{show,ColorMapping-method}}, \code{\link{ColorMapping-class}} class method
20
+\item \code{\link{show,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
21
+\item \code{\link{show,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method
22
+\item \code{\link{show,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
23
+>>>>>>> bioc/master
17 24
 \item \code{\link{show,Heatmap-method}}, \code{\link{Heatmap-class}} class method
18 25
 }
19 26
 }
... ...
@@ -6,7 +6,11 @@ draw(anno, c(1, 4, 3, 5, 2))
6 6
 dev.off()
7 7
 
8 8
 test_that("discrete color mapping", {
9
+<<<<<<< HEAD
9 10
 	expect_that(show(anno), prints_text("An annotation with discrete color mapping"))
11
+=======
12
+	expect_that(show(anno), prints_text("An annotaiton with discrete color mapping"))
13
+>>>>>>> bioc/master
10 14
 })
11 15
 
12 16
 pdf(NULL)
... ...
@@ -19,7 +23,11 @@ draw(anno, 1:10)
19 23
 dev.off()
20 24
 
21 25
 test_that("continuous color mapping", {
26
+<<<<<<< HEAD
22 27
 	expect_that(show(anno), prints_text("An annotation with continuous color mapping"))
28
+=======
29
+	expect_that(show(anno), prints_text("An annotaiton with continuous color mapping"))
30
+>>>>>>> bioc/master
23 31
 })
24 32
 
25 33
 pdf(NULL)
... ...
@@ -194,7 +194,11 @@ ha = HeatmapAnnotation(boxplot = anno_boxplot(mat))
194 194
 draw(ha, 1:10)
195 195
 ```
196 196
 
197
+<<<<<<< HEAD
197 198
 You can mix simple annotations and complex annotations:
199
+=======
200
+You can mix simple annotaitons and complex annotations:
201
+>>>>>>> bioc/master
198 202
 
199 203
 ```{r heatmap_annotation_mixed_with_complex, fig.width = 7, fig.height = 2}
200 204
 ha = HeatmapAnnotation(df = df, 
... ...
@@ -157,36 +157,59 @@ ht1 = Heatmap(mat, name = "ht1", show_heatmap_legend = FALSE)
157 157
 draw(ht1 + ha_chr, heatmap_legend_side = "bottom")
158 158
 ```
159 159
 
160
+<<<<<<< HEAD
160 161
 Discrete color bar for can be used for continuous values, if you specify `color_bar` to `discrete`.
161 162
 For the simple annotation which contains continuous values, `color_bar` can also be set to `discrete`.
163
+=======
164
+If you don't like the default discrete color bar for continuous values, you can specify `color_bar` to `continuous`.
165
+For the simple annotation which contains continuous values, `color_bar` can also be set to `continuous`.
166
+>>>>>>> bioc/master
162 167
 
163 168
 ```{r}
164 169
 ha = HeatmapAnnotation(df = data.frame(value = runif(10)), 
165 170
     col = list(value = colorRamp2(c(0, 1), c("white", "blue"))), 
171
+<<<<<<< HEAD
166 172
     annotation_legend_param = list(color_bar = "discrete", at = c(0, 0.5, 1)))
167 173
 Heatmap(mat, name = "ht1", top_annotation = ha, heatmap_legend_param = list(color_bar = "discrete"))
174
+=======
175
+    annotation_legend_param = list(color_bar = "continuous", at = c(0, 0.5, 1), 
176
+        labels = c("low", "median", "high"), legend_height = unit(4, "cm")))
177
+Heatmap(mat, name = "ht1", top_annotation = ha, heatmap_legend_param = list(color_bar = "continuous"))
178
+>>>>>>> bioc/master
168 179
 ```
169 180
 
170 181
 Some users prefer to put the legend at the bottom of heatmaps.
171 182
 
172 183
 ```{r}
184
+<<<<<<< HEAD
173 185
 ht = Heatmap(mat, name = "ht1", heatmap_legend_param = list(legend_direction = "horizontal",
186
+=======
187
+ht = Heatmap(mat, name = "ht1", heatmap_legend_param = list(color_bar = "continuous", legend_direction = "horizontal",
188
+>>>>>>> bioc/master
174 189
     legend_width = unit(5, "cm"), title_position = "lefttop"))
175 190
 draw(ht, heatmap_legend_side = "bottom")
176 191
 ```
177 192
 
193
+<<<<<<< HEAD
178 194
 Similarly, the height of the legend can be adjusted by `legend_height` if the legend is vertical.
179 195
 
180 196
 ```{r}
181 197
 Heatmap(mat, name = "ht1", heatmap_legend_param = list(legend_height = unit(5, "cm")))
182 198
 ```
183 199
 
200
+=======
201
+>>>>>>> bioc/master
184 202
 If you want to change default settings for all heatmaps/annotations, you can set it globally by `ht_global_opt()`.
185 203
 
186 204
 ```{r, fig.width = 10}
187 205
 ht_global_opt(heatmap_legend_title_gp = gpar(fontsize = 16), annotation_legend_labels_gp = gpar(fontface = "italic"))
188 206
 ha = HeatmapAnnotation(df = data.frame(value = runif(10)), 
207
+<<<<<<< HEAD
189 208
     col = list(value = colorRamp2(c(0, 1), c("white", "blue"))))
209
+=======
210
+    col = list(value = colorRamp2(c(0, 1), c("white", "blue"))), 
211
+    annotation_legend_param = list(color_bar = "continuous"))
212
+>>>>>>> bioc/master
190 213
 ht1 = Heatmap(mat, name = "ht1", column_title = "Heatmap 1", top_annotation = ha)
191 214
 ht2 = Heatmap(mat, name = "ht2", column_title = "Heatmap 2", heatmap_legend_param = list(title_gp = gpar(fontsize = 8)))
192 215
 ht1 + ht2