Browse code

oncoPrint(): print messages if NA in the matrix

jokergoo authored on 13/01/2020 10:58:23
Showing3 changed files

... ...
@@ -2,6 +2,7 @@ CHANGES in VERSION 2.3.1
2 2
 
3 3
 * `anno_points()`: allows images as symbols.
4 4
 * add `HEATMAP_LEGEND_PADDING` and `ANNOTATION_LEGEND_PADDING` options in `ht_opt`
5
+* `oncoPrint()`: print messages if there are NA values in the input matrix
5 6
 
6 7
 ========================
7 8
 
... ...
@@ -239,7 +239,7 @@ densityHeatmap = function(data,
239 239
 				labels = labels[od]
240 240
 				
241 241
 				pushViewport(viewport(xscale = c(0.5, n + 0.5), yscale = c(min_x, max_x), clip = FALSE))
242
-				text_height = convertHeight(grobHeight(textGrob(labels[1])) * 1.5, "native", valueOnly = TRUE)
242
+				text_height = convertHeight(grobHeight(textGrob(labels[1])) * 2, "native", valueOnly = TRUE)
243 243
 		        h1 = y - text_height*0.5
244 244
 		        h2 = y + text_height*0.5
245 245
 		        pos = rev(smartAlign(h1, h2, c(min_x, max_x)))
... ...
@@ -128,6 +128,11 @@ oncoPrint = function(mat,
128 128
 		all_type = all_type[!is.na(all_type)]
129 129
 		all_type = all_type[grepl("\\S", all_type)]
130 130
 
131
+		## check whether there are NA values in the matrix
132
+		if(any(is.na(mat))) {
133
+			message_wrap("Found NA values in the matrix and treat as no alteration. If `NA` means no alteration, you can explicitly set it to empty strings like ''. If `NA` is an alteration type, you should format it to a string like `'NA'` and define a graphic for it.")
134
+		}
135
+
131 136
 		mat_list = lapply(all_type, function(type) {
132 137
 			m = sapply(mat, function(x) type %in% get_type2(x))
133 138
 			dim(m) = dim(mat)