Browse code

add HEATMAP_LEGEND_PADDING and ANNOTATION_LEGEND_PADDING options

Zuguang Gu authored on 09/11/2019 09:18:39
Showing5 changed files

... ...
@@ -1,7 +1,7 @@
1 1
 Package: ComplexHeatmap
2 2
 Type: Package
3 3
 Title: Make Complex Heatmaps
4
-Version: 2.1.2
4
+Version: 2.3.1
5 5
 Date: 2019-10-22
6 6
 Author: Zuguang Gu
7 7
 Maintainer: Zuguang Gu <z.gu@dkfz.de>
... ...
@@ -1,3 +1,9 @@
1
+CHANGES in VERSION 2.3.1
2
+
3
+* add `HEATMAP_LEGEND_PADDING` and `ANNOTATION_LEGEND_PADDING` options in `ht_opt`
4
+
5
+========================
6
+
1 7
 CHANGES in VERSION 2.1.1
2 8
 
3 9
 * `Heatmap()`: give error when heatmap has empty string as its name.
... ...
@@ -909,25 +909,25 @@ setMethod(f = "make_layout",
909 909
     object@heatmap_legend_param$side = heatmap_legend_side   
910 910
     if(show_heatmap_legend) {
911 911
         if(heatmap_legend_side == "top") {
912
-            object@heatmap_legend_param$padding = unit(c(2, 0, 0, 0), "mm")
912
+            object@heatmap_legend_param$padding = unit.c(ht_opt$HEATMAP_LEGEND_PADDING, unit(c(0, 0, 0), "mm")) #unit(c(2, 0, 0, 0), "mm")
913 913
             size = heatmap_legend_size(object, legend_list = heatmap_legend_list, max_width = calc_legends_max_width(object))
914 914
             object@heatmap_legend_param$size = size
915 915
             object@layout$layout_heatmap_legend_top_height = size[2]
916 916
             object@layout$layout_index = rbind(object@layout$layout_index, heatmap_legend_top = heatmap_list_layout_index("heatmap_legend_top"))
917 917
         } else if(heatmap_legend_side == "bottom") {
918
-            object@heatmap_legend_param$padding = unit(c(0, 0, 2, 0), "mm")
918
+            object@heatmap_legend_param$padding = unit.c(unit(c(0, 0), "mm"), ht_opt$HEATMAP_LEGEND_PADDING, unit(0, "mm")) # unit(c(0, 0, 2, 0), "mm")
919 919
             size = heatmap_legend_size(object, legend_list = heatmap_legend_list, max_width = calc_legends_max_width(object))
920 920
             object@heatmap_legend_param$size = size
921 921
             object@layout$layout_heatmap_legend_bottom_height = size[2]
922 922
             object@layout$layout_index = rbind(object@layout$layout_index, heatmap_legend_bottom = heatmap_list_layout_index("heatmap_legend_bottom"))
923 923
         } else if(heatmap_legend_side == "left") {
924
-            object@heatmap_legend_param$padding = unit(c(0, 0, 0, 2), "mm")
924
+            object@heatmap_legend_param$padding = unit.c(unit(c(0, 0, 0), "mm"), ht_opt$HEATMAP_LEGEND_PADDING) # unit(c(0, 0, 0, 2), "mm")
925 925
             size = heatmap_legend_size(object, legend_list = heatmap_legend_list, max_height = calc_legends_max_height(object))
926 926
             object@heatmap_legend_param$size = size
927 927
             object@layout$layout_heatmap_legend_left_width = size[1]
928 928
             object@layout$layout_index = rbind(object@layout$layout_index, heatmap_legend_left = heatmap_list_layout_index("heatmap_legend_left"))
929 929
         } else if(heatmap_legend_side == "right") {
930
-            object@heatmap_legend_param$padding = unit(c(0, 2, 0, 0), "mm")
930
+            object@heatmap_legend_param$padding = unit.c(unit(0, "mm"), ht_opt$HEATMAP_LEGEND_PADDING, unit(c(0, 0), "mm")) # unit(c(0, 2, 0, 0), "mm")
931 931
             size = heatmap_legend_size(object, legend_list = heatmap_legend_list, max_height = calc_legends_max_height(object))
932 932
             object@heatmap_legend_param$size = size
933 933
             object@layout$layout_heatmap_legend_right_width = size[1]
... ...
@@ -980,25 +980,25 @@ setMethod(f = "make_layout",
980 980
     object@annotation_legend_param$side = annotation_legend_side
981 981
     if(show_annotation_legend) {
982 982
         if(annotation_legend_side == "top") {
983
-            object@annotation_legend_param$padding = unit(c(2, 0, 0, 0), "mm")
983
+            object@annotation_legend_param$padding = unit.c(ht_opt$ANNOTATION_LEGEND_PADDING, unit(c(0, 0, 0), "mm")) # unit(c(2, 0, 0, 0), "mm")
984 984
             size = annotation_legend_size(object, legend_list = annotation_legend_list, max_width = calc_legends_max_width(object))
985 985
             object@annotation_legend_param$size = size
986 986
             object@layout$layout_annotation_legend_top_height = size[2]
987 987
             object@layout$layout_index = rbind(object@layout$layout_index, annotation_legend_top = heatmap_list_layout_index("annotation_legend_top"))
988 988
         } else if(annotation_legend_side == "bottom") {
989
-            object@annotation_legend_param$padding = unit(c(0, 0, 2, 0), "mm")
989
+            object@annotation_legend_param$padding = unit.c(unit(c(0, 0), "mm"), ht_opt$ANNOTATION_LEGEND_PADDING, unit(0, "mm")) # unit(c(0, 0, 2, 0), "mm")
990 990
             size = annotation_legend_size(object, legend_list = annotation_legend_list, max_width = calc_legends_max_width(object))
991 991
             object@annotation_legend_param$size = size
992 992
             object@layout$layout_annotation_legend_bottom_height = size[2]
993 993
             object@layout$layout_index = rbind(object@layout$layout_index, annotation_legend_bottom = heatmap_list_layout_index("annotation_legend_bottom"))
994 994
         } else if(annotation_legend_side == "left") {
995
-            object@annotation_legend_param$padding = unit(c(0, 0, 0, 2), "mm")
995
+            object@annotation_legend_param$padding = unit.c(unit(c(0, 0, 0), "mm"), ht_opt$ANNOTATION_LEGEND_PADDING) # unit(c(0, 0, 0, 2), "mm")
996 996
             size = annotation_legend_size(object, legend_list = annotation_legend_list, max_height = calc_legends_max_height(object))
997 997
             object@annotation_legend_param$size = size
998 998
             object@layout$layout_annotation_legend_left_width = size[1]
999 999
             object@layout$layout_index = rbind(object@layout$layout_index, annotation_legend_left = heatmap_list_layout_index("annotation_legend_left"))
1000 1000
         } else if(annotation_legend_side == "right") {
1001
-            object@annotation_legend_param$padding = unit(c(0, 2, 0, 0), "mm")
1001
+            object@annotation_legend_param$padding = unit.c(unit(0, "mm"), ht_opt$ANNOTATION_LEGEND_PADDING, unit(c(0, 0), "mm")) # unit(c(0, 2, 0, 0), "mm")
1002 1002
             size = annotation_legend_size(object, legend_list = annotation_legend_list, max_height = calc_legends_max_height(object))
1003 1003
             object@annotation_legend_param$size = size
1004 1004
             object@layout$layout_annotation_legend_right_width = size[1]
... ...
@@ -44,6 +44,8 @@
44 44
 # -TITLE_PADDING space between row/column titles and heatmap body.
45 45
 # -COLUMN_ANNO_PADDING space between column annotations and heatmap body.
46 46
 # -ROW_ANNO_PADDING space between row annotations and heatmap body.
47
+# -HEATMAP_LEGEND_PADDING space between heatmap legends and heatmaps
48
+# -ANNOTATION_LEGEND_PADDING space between annotation legends and heatmaps
47 49
 #
48 50
 # Other parameters:
49 51
 #
... ...
@@ -150,6 +152,14 @@ ht_opt = setGlobalOptions(
150 152
 	ROW_ANNO_PADDING = list(
151 153
 		.value = unit(1, "mm"),
152 154
 		.class = "unit"
155
+	),
156
+	HEATMAP_LEGEND_PADDING = list(
157
+		.value = unit(2, "mm"),
158
+		.class = "unit"
159
+	),
160
+	ANNOTATION_LEGEND_PADDING = list(
161
+		.value = unit(2, "mm"),
162
+		.class = "unit"
153 163
 	)
154 164
 )
155 165
 
... ...
@@ -59,6 +59,8 @@ Following parameters control the space between heatmap components:
59 59
   \item{TITLE_PADDING}{space between row/column titles and heatmap body.}
60 60
   \item{COLUMN_ANNO_PADDING}{space between column annotations and heatmap body.}
61 61
   \item{ROW_ANNO_PADDING}{space between row annotations and heatmap body.}
62
+  \item{HEATMAP_LEGEND_PADDING}{space between heatmap legends and heatmaps}
63
+  \item{ANNOTATION_LEGEND_PADDING}{space between annotation legends and heatmaps}
62 64
 }
63 65
 
64 66
 Other parameters: