Browse code

anno_mark(), anno_zoom(); print message under RStudio

Zuguang Gu authored on 14/06/2020 20:51:54
Showing2 changed files

... ...
@@ -2794,12 +2794,6 @@ anno_mark = function(at, labels, which = c("column", "row"),
2794 2794
 	link_gp = lines_gp, 
2795 2795
 	extend = unit(0, "mm")) {
2796 2796
 
2797
-	if(is_RStudio_current_dev()) {
2798
-		if(ht_opt$message) {
2799
-			message_wrap("It seems you are using RStudio IDE. `anno_mark()` needs to work with the physical size of the graphics device. It only generates correct plot in the figure panel, while in the zoomed plot (by clicking the icon 'Zoom') or in the exported plot (by clicking the icon 'Export'), the connection to heatmap rows/columns might be wrong. You can directly use e.g. pdf() to save the plot into a file.\n\nUse `ht_opt$message = FALSE` to turn off this message.")
2800
-		}
2801
-	}
2802
-
2803 2797
 	if(is.null(.ENV$current_annotation_which)) {
2804 2798
 		which = match.arg(which)[1]
2805 2799
 	} else {
... ...
@@ -2840,6 +2834,13 @@ anno_mark = function(at, labels, which = c("column", "row"),
2840 2834
 	# a map between row index and positions
2841 2835
 	# pos_map = 
2842 2836
 	row_fun = function(index) {
2837
+
2838
+		if(is_RStudio_current_dev()) {
2839
+			if(ht_opt$message) {
2840
+				message_wrap("It seems you are using RStudio IDE. `anno_mark()` needs to work with the physical size of the graphics device. It only generates correct plot in the figure panel, while in the zoomed plot (by clicking the icon 'Zoom') or in the exported plot (by clicking the icon 'Export'), the connection to heatmap rows/columns might be wrong. You can directly use e.g. pdf() to save the plot into a file.\n\nUse `ht_opt$message = FALSE` to turn off this message.")
2841
+			}
2842
+		}
2843
+
2843 2844
 		n = length(index)
2844 2845
 		# adjust at and labels
2845 2846
 		at = intersect(index, at)
... ...
@@ -2910,6 +2911,13 @@ anno_mark = function(at, labels, which = c("column", "row"),
2910 2911
 		upViewport()
2911 2912
 	}
2912 2913
 	column_fun = function(index) {
2914
+
2915
+		if(is_RStudio_current_dev()) {
2916
+			if(ht_opt$message) {
2917
+				message_wrap("It seems you are using RStudio IDE. `anno_mark()` needs to work with the physical size of the graphics device. It only generates correct plot in the figure panel, while in the zoomed plot (by clicking the icon 'Zoom') or in the exported plot (by clicking the icon 'Export'), the connection to heatmap rows/columns might be wrong. You can directly use e.g. pdf() to save the plot into a file.\n\nUse `ht_opt$message = FALSE` to turn off this message.")
2918
+			}
2919
+		}
2920
+		
2913 2921
 		n = length(index)
2914 2922
 		# adjust at and labels
2915 2923
 		at = intersect(index, at)
... ...
@@ -3340,12 +3348,6 @@ anno_zoom = function(align_to, panel_fun = function(index, nm = NULL) { grid.rec
3340 3348
 	size = NULL, gap = unit(1, "mm"), 
3341 3349
 	link_width = unit(5, "mm"), link_height = link_width, link_gp = gpar(),
3342 3350
 	extend = unit(0, "mm"), width = NULL, height = NULL, internal_line = TRUE) {
3343
-	
3344
-	if(is_RStudio_current_dev()) {
3345
-		if(ht_opt$message) {
3346
-			message_wrap("It seems you are using RStudio IDE. `anno_zoom()` needs to work with the physical size of the graphics device. It only generates correct plot in the figure panel, while in the zoomed plot (by clicking the icon 'Zoom') or in the exported plot (by clicking the icon 'Export'), the connection to heatmap rows/columns might be wrong. You can directly use e.g. pdf() to save the plot into a file.\n\nUse `ht_opt$message = FALSE` to turn off this message.")
3347
-		}
3348
-	}
3349 3351
 
3350 3352
 	if(is.null(.ENV$current_annotation_which)) {
3351 3353
 		which = match.arg(which)[1]
... ...
@@ -3378,6 +3380,13 @@ anno_zoom = function(align_to, panel_fun = function(index, nm = NULL) { grid.rec
3378 3380
 	# anno_zoom is always executed in one-slice mode (which means mulitple slices
3379 3381
 	# are treated as one big slilce)
3380 3382
 	row_fun = function(index) {
3383
+
3384
+		if(is_RStudio_current_dev()) {
3385
+			if(ht_opt$message) {
3386
+				message_wrap("It seems you are using RStudio IDE. `anno_zoom()` needs to work with the physical size of the graphics device. It only generates correct plot in the figure panel, while in the zoomed plot (by clicking the icon 'Zoom') or in the exported plot (by clicking the icon 'Export'), the connection to heatmap rows/columns might be wrong. You can directly use e.g. pdf() to save the plot into a file.\n\nUse `ht_opt$message = FALSE` to turn off this message.")
3387
+			}
3388
+		}
3389
+
3381 3390
 		n = length(index)
3382 3391
 		if(is.atomic(align_to)) {
3383 3392
 			if(length(setdiff(align_to, index)) == 0 && !any(duplicated(align_to))) {
... ...
@@ -3558,6 +3567,13 @@ anno_zoom = function(align_to, panel_fun = function(index, nm = NULL) { grid.rec
3558 3567
 	}
3559 3568
 
3560 3569
 	column_fun = function(index) {
3570
+
3571
+		if(is_RStudio_current_dev()) {
3572
+			if(ht_opt$message) {
3573
+				message_wrap("It seems you are using RStudio IDE. `anno_zoom()` needs to work with the physical size of the graphics device. It only generates correct plot in the figure panel, while in the zoomed plot (by clicking the icon 'Zoom') or in the exported plot (by clicking the icon 'Export'), the connection to heatmap rows/columns might be wrong. You can directly use e.g. pdf() to save the plot into a file.\n\nUse `ht_opt$message = FALSE` to turn off this message.")
3574
+			}
3575
+		}
3576
+
3561 3577
 		n = length(index)
3562 3578
 		
3563 3579
 		if(is.atomic(align_to)) {
... ...
@@ -15,7 +15,9 @@ Legends = setClass("Legends",
15 15
     slots = list(
16 16
         grob = "ANY",
17 17
         type = "character",
18
-        n = "numeric"
18
+        n = "numeric",
19
+        nr = "numeric",
20
+        nc = "numeric"
19 21
     )
20 22
 )
21 23