Browse code

fixed a bug i noncoPrint

Zuguang Gu authored on 08/03/2016 15:31:18
Showing 1 changed files

... ...
@@ -140,17 +140,25 @@ oncoPrint = function(mat, get_type = function(x) x,
140 140
 			stop(paste0("You should define shape function for: ", paste(sdf, collapse = ", ")))
141 141
 		}
142 142
 
143
+		alter_fun = alter_fun[unique(c("background", intersect(names(alter_fun), all_type)))]
144
+
143 145
 		af = function(x, y, w, h, v) {
144 146
 			if(!is.null(alter_fun$background)) alter_fun$background(x, y, w, h)
147
+
145 148
 			alter_fun = alter_fun[names(alter_fun) != "background"]
146
-			for(nm in names(alter_fun)) {
147
-				if(v[nm]) alter_fun[[nm]](x, y, w, h)
149
+
150
+			if(sum(v)) {
151
+				for(nm in names(alter_fun)) {
152
+					if(v[nm]) alter_fun[[nm]](x, y, w, h)
153
+				}
148 154
 			}
149 155
 		}
150 156
 	} else {
151 157
 		af = alter_fun
152 158
 	}
153 159
 
160
+	col = col[intersect(names(col), all_type)]
161
+
154 162
 	# type as the third dimension
155 163
 	arr = array(FALSE, dim = c(dim(mat_list[[1]]), length(all_type)), dimnames = c(dimnames(mat_list[[1]]), list(all_type)))
156 164
 	for(i in seq_along(all_type)) {