Browse code

print message when the number of colors is the same as the number of unique values in the matrix

Zuguang Gu authored on 29/09/2022 07:58:52
Showing 2 changed files

... ...
@@ -597,6 +597,9 @@ Heatmap = function(matrix, col, name,
597 597
 
598 598
             if(is.null(names(col))) {
599 599
                 if(length(col) == length(unique(as.vector(matrix)))) {
600
+                    if(length(col) >= 50) {
601
+                        message_wrap(qq("There are @{length(col)} unique colors in the vector `col` and @{length(col)} unique values in `matrix`. `Heatmap()` will treat it as an exact discrete one-to-one mapping. If this is not what you want, slightly change the number of colors, e.g. by adding one more color or removing a color."))
602
+                    }
600 603
                     if(is.null(fa_level)) {
601 604
                         if(is.numeric(matrix)) {
602 605
                             names(col) = sort(unique(as.vector(matrix)))
... ...
@@ -1409,7 +1409,7 @@ UpSet = function(m,
1409 1409
 		if(length(ra) == 1) {
1410 1410
 			ta_call = substitute(top_annotation)
1411 1411
 			ta_call = as.list(ta_call)
1412
-			if(as.character(ta_call[[1]]) == "upset_top_annotation") {
1412
+			if("upset_top_annotation" %in% as.character(ta_call[[1]])) {
1413 1413
 				if(!"gp" %in% names(as.list(ta_call))) {
1414 1414
 					ra@anno_list[[1]]@fun@var_env$gp$fill = comb_col
1415 1415
 					ra@anno_list[[1]]@fun@var_env$gp$col = comb_col