Browse code

add secondary row ordering for oncoPrint

Zuguang Gu authored on 30/01/2018 09:19:29
Showing2 changed files

... ...
@@ -6,6 +6,8 @@ CHANGES in VERSIONS 1.17.1
6 6
 * `grid.dendrogram()`: fix a bug that the dendrogram is wrong when row/column
7 7
   names have duplicated names.
8 8
 * `anno_boxplot()`: axis rescaled when outline = FALSE
9
+* `oncoPrint()`: rows are first ordered by total number of mutations and then
10
+  ordered by number of samples that have mutations
9 11
 
10 12
 =======================
11 13
 
... ...
@@ -207,7 +207,7 @@ oncoPrint = function(mat, get_type = function(x) x,
207 207
 	}
208 208
 
209 209
 	oncoprint_row_order = function() {
210
-		order(rowSums(count_matrix), decreasing = TRUE)
210
+		order(rowSums(count_matrix), pct_num, decreasing = TRUE)
211 211
 	}
212 212
 
213 213
 	oncoprint_column_order = function() {
... ...
@@ -246,8 +246,8 @@ oncoPrint = function(mat, get_type = function(x) x,
246 246
 	}
247 247
 
248 248
 	# for each gene, percent of samples that have alterations
249
-	pct = rowSums(apply(arr, 1:2, any)) / ncol(mat_list[[1]])
250
-	pct = paste0(round(pct * 100, digits = pct_digits), "%")
249
+	pct_num = rowSums(apply(arr, 1:2, any)) / ncol(mat_list[[1]])
250
+	pct = paste0(round(pct_num * 100, digits = pct_digits), "%")
251 251
 	ha_pct = rowAnnotation(pct = row_anno_text(pct, just = "right", offset = unit(1, "npc"), gp = pct_gp), width = max_text_width(pct, gp = pct_gp))
252 252
 
253 253
 	#####################################################################