Browse code

get_type automatically splits ',;:|'

Zuguang Gu authored on 10/12/2018 10:01:04
Showing5 changed files

... ...
@@ -2,7 +2,7 @@ Package: ComplexHeatmap
2 2
 Type: Package
3 3
 Title: Make Complex Heatmaps
4 4
 Version: 1.99.4
5
-Date: 2018-12-7
5
+Date: 2018-12-10
6 6
 Author: Zuguang Gu
7 7
 Maintainer: Zuguang Gu <z.gu@dkfz.de>
8 8
 Depends: R (>= 3.1.2), methods, grid, graphics, stats, grDevices
... ...
@@ -1,6 +1,8 @@
1 1
 CHANGES in VERSION 1.99.4
2 2
 
3 3
 * anno_mark() is now calculated in multiple slices.
4
+* oncoPrint(): automatically split the alteration type if the separator is one of
5
+  ";:,|".
4 6
 
5 7
 ========================
6 8
 
... ...
@@ -1085,7 +1085,10 @@ setMethod(f = "re_size",
1085 1085
 		} else {
1086 1086
 			if(length(annotation_height) == 1) {
1087 1087
 				if(length(object@anno_list) > 1) {
1088
-					warning_wrap("`annotation_height` is set with length of one while with multiplt annotations, `annotation_height` is treated as `height`.")
1088
+					warning_wrap("`annotation_height` is set with length of one while with multiple annotations, `annotation_height` is treated as `height`.")
1089
+				}
1090
+				if(length(object@anno_list) == 1 && !inherits(annotation_height, "unit")) {
1091
+					stop_wrap("When there is only one annotation, `annotation_height` should be set as a unit object.")
1089 1092
 				}
1090 1093
 				height = annotation_height[1]
1091 1094
 				if(!inherits(height, "unit")) {
... ...
@@ -1120,7 +1123,10 @@ setMethod(f = "re_size",
1120 1123
 		} else {
1121 1124
 			if(length(annotation_width) == 1) {
1122 1125
 				if(length(object@anno_list) > 1) {
1123
-					warning_wrap("`annotation_width` is set with length of one while with multiplt annotations, `annotation_width` is treated as `width`.")
1126
+					warning_wrap("`annotation_width` is set with length of one while with multiple annotations, `annotation_width` is treated as `width`.")
1127
+				}
1128
+				if(length(object@anno_list) == 1 && !inherits(annotation_width, "unit")) {
1129
+					stop_wrap("When there is only one annotation, `annotation_width` should be set as a unit object.")
1124 1130
 				}
1125 1131
 				width = annotation_width[1]
1126 1132
 				if(!inherits(width, "unit")) {
... ...
@@ -51,7 +51,7 @@
51 51
 # Zuguang Gu <z.gu@dkfz.de>
52 52
 #
53 53
 oncoPrint = function(mat, 
54
-	get_type = function(x) x,
54
+	get_type = function(x) strsplit(x, "\\s*[;:,|]\\s*")[[1]],
55 55
 	alter_fun, 
56 56
 	alter_fun_is_vectorized = NULL,
57 57
 	col, 
... ...
@@ -8,7 +8,7 @@ Make oncoPrint
8 8
 }
9 9
 \usage{
10 10
 oncoPrint(mat,
11
-    get_type = function(x) x,
11
+    get_type = function(x) strsplit(x, "\\\\s*[;:,|]\\\\s*")[[1]],
12 12
     alter_fun,
13 13
     alter_fun_is_vectorized = NULL,
14 14
     col,