Browse code

scales for row barplots are the name if rows are split

Zuguang Gu authored on 23/07/2018 08:16:47
Showing3 changed files

... ...
@@ -1,6 +1,7 @@
1 1
 CHANGES in VERSION 1.19.1
2 2
 
3 3
 * `Heatmap()`: no column name added if the input matrix is a one-column matrix.
4
+* `oncoPrint()`: scales the the row annotations are now the same if rows are split.
4 5
 
5 6
 =======================
6 7
 
... ...
@@ -71,6 +71,10 @@ Legend = function(at, labels = at, nrow = NULL, ncol = 1, col_fun, by_row = FALS
71 71
 	title = "", title_gp = gpar(fontsize = 10, fontface = "bold"),
72 72
 	title_position = c("topleft", "topcenter", "leftcenter", "lefttop")) {
73 73
 
74
+	if(missing(at) && !missing(labels)) {
75
+		at = seq_along(labels)
76
+	}
77
+
74 78
 	# odevlist = dev.list()
75 79
 	direction = match.arg(direction)[1]
76 80
 	if(missing(col_fun)) {
... ...
@@ -270,10 +270,11 @@ oncoPrint = function(mat, get_type = function(x) x,
270 270
 	# row annotation which is a barplot
271 271
 	anno_row_bar = function(index, k = NULL, N = NULL) {
272 272
 		n = length(index)
273
-		count = apply(arr, c(1, 3), sum)[index, , drop = FALSE]
273
+		count = apply(arr, c(1, 3), sum)[, , drop = FALSE]
274 274
 		all_type = all_type[!(colnames(count) %in% barplot_ignore)]
275 275
 		count = count[, setdiff(colnames(count), barplot_ignore), drop = FALSE]
276 276
 		max_count = max(rowSums(count))
277
+		count = count[index, , drop = FALSE]
277 278
 		pushViewport(viewport(xscale = c(0, max_count*1.1), yscale = c(0.5, n + 0.5)))
278 279
 		for(i in seq_len(nrow(count))) {
279 280
 			if(any(count[i, ] > 0)) {