Browse code

argument are explicitly specified instead of using '...'

Zuguang Gu authored on 14/04/2016 09:08:33
Showing 5 changed files

... ...
@@ -1,114 +1,114 @@
1
-export(column_anno_histogram)
2
-export(anno_boxplot)
3
-exportMethods(column_order)
1
+export('+.AdditiveUnit')
2
+export(AdditiveUnit)
4 3
 export(ColorMapping)
4
+export(Heatmap)
5 5
 export(HeatmapAnnotation)
6
+export(HeatmapList)
7
+export(SingleAnnotation)
8
+export(anno_barplot)
9
+export(anno_boxplot)
10
+export(anno_density)
11
+export(anno_histogram)
12
+export(anno_link)
13
+export(anno_points)
14
+export(anno_text)
15
+export(columnAnnotation)
16
+export(column_anno_barplot)
6 17
 export(column_anno_boxplot)
7
-export(selectArea)
8
-export(row_anno_barplot)
9
-export(Heatmap)
10
-export(row_anno_points)
18
+export(column_anno_density)
19
+export(column_anno_histogram)
20
+export(column_anno_link)
21
+export(column_anno_points)
11 22
 export(column_anno_text)
12
-export(decorate_row_dend)
13
-export(decorate_column_dend)
14
-exportMethods(draw)
15
-export(unify_mat_list)
16
-exportMethods(draw_heatmap_body)
17
-exportMethods(color_mapping_legend)
18
-exportMethods(prepare)
19 23
 export(decorate_annotation)
20
-exportMethods(map_to_colors)
24
+export(decorate_column_dend)
25
+export(decorate_column_names)
26
+export(decorate_column_title)
27
+export(decorate_dend)
21 28
 export(decorate_dimnames)
22
-export(column_anno_points)
23
-exportMethods(component_height)
24
-export(row_anno_text)
25
-exportClasses(SingleAnnotation)
26
-export(SingleAnnotation)
27
-export(oncoPrint)
28
-exportClasses(AdditiveUnit)
29
-export(AdditiveUnit)
30
-export(max_text_height)
29
+export(decorate_heatmap_body)
30
+export(decorate_row_dend)
31
+export(decorate_row_names)
32
+export(decorate_row_title)
33
+export(decorate_title)
34
+export(densityHeatmap)
35
+export(dist2)
31 36
 export(enhanced_basicplot)
32
-exportMethods(annotation_legend_size)
33
-exportMethods(row_order)
34
-export(AdditiveUnit)
35
-exportMethods(draw_heatmap_list)
36
-export(row_anno_density)
37
+export(grid.dendrogram)
38
+export(ht_global_opt)
37 39
 export(is_abs_unit)
38
-export(dist2)
39
-export(decorate_heatmap_body)
40
-exportMethods(draw_heatmap_legend)
41
-exportMethods(add_heatmap)
42
-export(anno_barplot)
43
-exportMethods(row_dend)
44
-export(row_anno_boxplot)
40
+export(max_text_height)
45 41
 export(max_text_width)
46
-export(anno_link)
47
-exportMethods(make_layout)
48
-export(decorate_row_title)
49
-export(anno_histogram)
42
+export(oncoPrint)
50 43
 export(plotDataFrame)
51
-exportMethods(draw_dimnames)
44
+export(rowAnnotation)
45
+export(row_anno_barplot)
46
+export(row_anno_boxplot)
47
+export(row_anno_density)
48
+export(row_anno_histogram)
49
+export(row_anno_link)
50
+export(row_anno_points)
51
+export(row_anno_text)
52
+export(selectArea)
53
+export(unify_mat_list)
54
+exportClasses(AdditiveUnit)
55
+export(AdditiveUnit)
52 56
 exportClasses(ColorMapping)
53 57
 export(ColorMapping)
58
+exportClasses(Heatmap)
59
+export(Heatmap)
54 60
 exportClasses(HeatmapAnnotation)
55 61
 export(HeatmapAnnotation)
56
-export(anno_points)
57
-exportMethods(draw_title)
58
-export(ht_global_opt)
59
-export('+.AdditiveUnit')
60
-export(decorate_column_names)
61
-export(column_anno_barplot)
62
-export(densityHeatmap)
63
-exportMethods(heatmap_legend_size)
64 62
 exportClasses(HeatmapList)
65 63
 export(HeatmapList)
66
-export(column_anno_density)
67
-exportClasses(Heatmap)
68
-export(Heatmap)
69
-exportMethods(draw_annotation_legend)
70
-exportMethods(column_dend)
71
-exportMethods(set_component_height)
72
-export(row_anno_link)
73
-exportMethods(make_column_cluster)
74
-export(HeatmapList)
75
-exportMethods(draw_annotation)
64
+exportClasses(SingleAnnotation)
76 65
 export(SingleAnnotation)
77
-export(row_anno_histogram)
78
-exportMethods(get_color_mapping_list)
79
-exportMethods(make_row_cluster)
66
+exportMethods(add_heatmap)
67
+exportMethods(annotation_legend_size)
68
+exportMethods(color_mapping_legend)
69
+exportMethods(column_dend)
70
+exportMethods(column_order)
71
+exportMethods(component_height)
80 72
 exportMethods(component_width)
81
-export(decorate_column_title)
73
+exportMethods(draw)
74
+exportMethods(draw_annotation)
75
+exportMethods(draw_annotation_legend)
82 76
 exportMethods(draw_dend)
77
+exportMethods(draw_dimnames)
78
+exportMethods(draw_heatmap_body)
79
+exportMethods(draw_heatmap_legend)
80
+exportMethods(draw_heatmap_list)
81
+exportMethods(draw_title)
82
+exportMethods(get_color_mapping_list)
83 83
 exportMethods(get_color_mapping_param_list)
84
-export(grid.dendrogram)
85
-export(decorate_title)
86
-export(decorate_dend)
87
-export(rowAnnotation)
88
-export(column_anno_link)
89
-export(columnAnnotation)
90
-export(decorate_row_names)
91
-export(anno_text)
92
-export(anno_density)
84
+exportMethods(heatmap_legend_size)
85
+exportMethods(make_column_cluster)
86
+exportMethods(make_layout)
87
+exportMethods(make_row_cluster)
88
+exportMethods(map_to_colors)
89
+exportMethods(prepare)
90
+exportMethods(row_dend)
91
+exportMethods(row_order)
92
+exportMethods(set_component_height)
93 93
 
94
+import(grDevices)
95
+import(graphics)
94 96
 import(grid)
95
-importFrom("methods", setClass)
96
-importFrom("methods", setMethod)
97
-importFrom("methods", setGeneric)
97
+import(stats)
98
+importFrom("GetoptLong", qq)
99
+importFrom("GetoptLong", qq.options)
100
+importFrom("GetoptLong", qqcat)
101
+importFrom("GlobalOptions", setGlobalOptions)
102
+importFrom("RColorBrewer", brewer.pal)
98 103
 importFrom("circlize", colorRamp2)
99 104
 importFrom("circlize", rand_color)
100 105
 importFrom("circlize", smartAlign)
101
-importFrom("GetoptLong", qq)
102
-importFrom("GetoptLong", qqcat)
103
-importFrom("GetoptLong", qq.options)
104
-importFrom("colorspace", rainbow_hcl)
105 106
 importFrom("colorspace", diverge_hcl)
106
-importFrom("RColorBrewer", brewer.pal)
107
+importFrom("colorspace", rainbow_hcl)
108
+importFrom("dendextend", "labels<-")
107 109
 importFrom("dendextend", get_branches_heights)
108 110
 importFrom("dendextend", nnodes)
109
-importFrom("dendextend", "labels<-")
110
-import(graphics)
111
-import(stats)
112
-import(grDevices)
113
-importFrom("GlobalOptions", setGlobalOptions)
111
+importFrom("methods", setClass)
112
+importFrom("methods", setGeneric)
113
+importFrom("methods", setMethod)
114 114
 
... ...
@@ -4,6 +4,8 @@ CHANGES in VERSION 1.9.5
4 4
   of column names when there are bottom annotations.
5 5
 * fixed a bug that character NA values can not to assigned with na_col
6 6
 * extra character 'at' and 'labels' in legends will be removed automatically
7
+* all arguments which are passed to `make_layout()` are all explicitly put
8
+  in `draw()` instead of using ...
7 9
 
8 10
 =============================
9 11
 
... ...
@@ -591,6 +591,22 @@ setMethod(f = "make_layout",
591 591
 # -object a `HeatmapList-class` object
592 592
 # -padding padding of the plot. Elements correspond to bottom, left, top, right paddings.
593 593
 # -newpage whether create a new page for the graphics.
594
+# -row_title title on the row.
595
+# -row_title_side will the title be put on the left or right of the heatmap.
596
+# -row_title_gp graphic parameters for drawing text.
597
+# -column_title title on the column.
598
+# -column_title_side will the title be put on the top or bottom of the heatmap.
599
+# -column_title_gp graphic parameters for drawing text.
600
+# -heatmap_legend_side side of the heatmap legend.
601
+# -show_heatmap_legend whether show heatmap legend.
602
+# -heatmap_legend_list a list of self-defined legend, should be wrapped into `grid::grob` objects.
603
+# -annotation_legend_side side of annotation legend.
604
+# -show_annotation_legend whether show annotation legend.
605
+# -annotation_legend_list a list of self-defined legend, should be wrapped into `grid::grob` objects.
606
+# -gap gap between heatmaps, should be a `grid::unit` object.
607
+# -main_heatmap name or index for the main heatmap
608
+# -row_dend_side if auto adjust, where to put the row dendrograms for the main heatmap
609
+# -row_sub_title_side if auto adjust, where to put sub row titles for the main heatmap
594 610
 # -... pass to `make_layout,HeatmapList-method`
595 611
 #
596 612
 # == detail
... ...
@@ -610,7 +626,22 @@ setMethod(f = "draw",
610 626
     definition = function(object, 
611 627
         padding = unit(c(2, 2, 2, 2), "mm"), 
612 628
         newpage = TRUE,
613
-        ...) {
629
+        row_title = character(0), 
630
+        row_title_side = c("left", "right"), 
631
+        row_title_gp = gpar(fontsize = 14),
632
+        column_title = character(0), 
633
+        column_title_side = c("top", "bottom"), 
634
+        column_title_gp = gpar(fontsize = 14), 
635
+        heatmap_legend_side = c("right", "left", "bottom", "top"), 
636
+        show_heatmap_legend = TRUE, 
637
+        heatmap_legend_list = list(),
638
+        annotation_legend_side = c("right", "left", "bottom", "top"), 
639
+        show_annotation_legend = TRUE, 
640
+        annotation_legend_list = list(),
641
+        gap = unit(3, "mm"), 
642
+        main_heatmap = which(sapply(object@ht_list, inherits, "Heatmap"))[1],
643
+        row_dend_side = c("original", "left", "right"),
644
+        row_sub_title_side = c("original", "left", "right"), ...) {
614 645
 
615 646
     l = sapply(object@ht_list, inherits, "Heatmap")
616 647
     if(! any(l)) {
... ...
@@ -624,7 +655,12 @@ setMethod(f = "draw",
624 655
         grid.newpage()
625 656
     }
626 657
     
627
-    object = make_layout(object, ...)
658
+    object = make_layout(object, row_title = row_title, row_title_gp = row_title_gp, row_title_side = row_title_side,
659
+        column_title = column_title, column_title_side = column_title_side, column_title_gp = column_title_gp,
660
+        heatmap_legend_side = heatmap_legend_side, show_heatmap_legend = show_heatmap_legend, heatmap_legend_list = heatmap_legend_list,
661
+        annotation_legend_side = annotation_legend_side, show_annotation_legend = show_annotation_legend,
662
+        annotation_legend_list = annotation_legend_list, gap = gap, main_heatmap = main_heatmap, row_dend_side = row_dend_side,
663
+        row_sub_title_side = row_sub_title_side, ...)
628 664
 
629 665
     if(length(padding) == 1) {
630 666
         padding = rep(padding, 4)
... ...
@@ -10,13 +10,44 @@ Draw a list of heatmaps
10 10
 \S4method{draw}{HeatmapList}(object,
11 11
     padding = unit(c(2, 2, 2, 2), "mm"),
12 12
     newpage = TRUE,
13
-    ...)
13
+    row_title = character(0),
14
+    row_title_side = c("left", "right"),
15
+    row_title_gp = gpar(fontsize = 14),
16
+    column_title = character(0),
17
+    column_title_side = c("top", "bottom"),
18
+    column_title_gp = gpar(fontsize = 14),
19
+    heatmap_legend_side = c("right", "left", "bottom", "top"),
20
+    show_heatmap_legend = TRUE,
21
+    heatmap_legend_list = list(),
22
+    annotation_legend_side = c("right", "left", "bottom", "top"),
23
+    show_annotation_legend = TRUE,
24
+    annotation_legend_list = list(),
25
+    gap = unit(3, "mm"),
26
+    main_heatmap = which(sapply(object@ht_list, inherits, "Heatmap"))[1],
27
+    row_dend_side = c("original", "left", "right"),
28
+    row_sub_title_side = c("original", "left", "right"), ...)
14 29
 }
15 30
 \arguments{
16 31
 
17 32
   \item{object}{a \code{\link{HeatmapList-class}} object}
18 33
   \item{padding}{padding of the plot. Elements correspond to bottom, left, top, right paddings.}
19 34
   \item{newpage}{whether create a new page for the graphics.}
35
+  \item{row_title}{title on the row.}
36
+  \item{row_title_side}{will the title be put on the left or right of the heatmap.}
37
+  \item{row_title_gp}{graphic parameters for drawing text.}
38
+  \item{column_title}{title on the column.}
39
+  \item{column_title_side}{will the title be put on the top or bottom of the heatmap.}
40
+  \item{column_title_gp}{graphic parameters for drawing text.}
41
+  \item{heatmap_legend_side}{side of the heatmap legend.}
42
+  \item{show_heatmap_legend}{whether show heatmap legend.}
43
+  \item{heatmap_legend_list}{a list of self-defined legend, should be wrapped into \code{\link[grid]{grob}} objects.}
44
+  \item{annotation_legend_side}{side of annotation legend.}
45
+  \item{show_annotation_legend}{whether show annotation legend.}
46
+  \item{annotation_legend_list}{a list of self-defined legend, should be wrapped into \code{\link[grid]{grob}} objects.}
47
+  \item{gap}{gap between heatmaps, should be a \code{\link[grid]{unit}} object.}
48
+  \item{main_heatmap}{name or index for the main heatmap}
49
+  \item{row_dend_side}{if auto adjust, where to put the row dendrograms for the main heatmap}
50
+  \item{row_sub_title_side}{if auto adjust, where to put sub row titles for the main heatmap}
20 51
   \item{...}{pass to \code{\link{make_layout,HeatmapList-method}}}
21 52
 
22 53
 }
... ...
@@ -77,7 +77,7 @@ From left to right, heatmaps are:
77 77
 8. overlapping between DMRs and enhancers (Color shows how much the DMR is covered by the enhancers).
78 78
 
79 79
 
80
-```{r, fig.width = 10, fig.height = 8, echo = FALSE}
80
+```{r, fig.width = 10, fig.height = 8, echo = FALSE, results = "hide"}
81 81
 library(circlize)
82 82
 library(RColorBrewer)
83 83