Browse code

update

Zuguang Gu authored on 16/10/2018 05:54:05
Showing6 changed files

... ...
@@ -9,7 +9,7 @@ Depends: R (>= 3.1.2), methods, grid, graphics, stats, grDevices
9 9
 Imports: circlize (>= 0.4.1), GetoptLong, colorspace,
10 10
     RColorBrewer, GlobalOptions (>= 0.1.0)
11 11
 Suggests: testthat (>= 0.3), knitr, markdown, cluster, MASS, pvclust, 
12
-    dendsort, HilbertCurve, Cairo, png, jpeg, tiff, fastcluster,
12
+    dendsort, HilbertCurve (>= 1.11.1), Cairo, png, jpeg, tiff, fastcluster,
13 13
     dendextend (>= 1.0.1), grImport, grImport2, rsvg, glue
14 14
 VignetteBuilder: knitr
15 15
 Description: Complex heatmaps are efficient to visualize associations 
... ...
@@ -42,8 +42,6 @@ S3method("length", "HeatmapAnnotation")
42 42
 export("length.HeatmapAnnotation")
43 43
 S3method("length", "HeatmapList")
44 44
 export("length.HeatmapList")
45
-S3method("merge", "dendrogram")
46
-export("merge.dendrogram")
47 45
 S3method("names", "HeatmapAnnotation")
48 46
 export("names.HeatmapAnnotation")
49 47
 S3method("names", "HeatmapList")
... ...
@@ -154,6 +152,7 @@ export("is_abs_unit")
154 152
 export("list_component")
155 153
 export("max_text_height")
156 154
 export("max_text_width")
155
+export("merge_dendrogram")
157 156
 export("oncoPrint")
158 157
 export("packLegend")
159 158
 export("pindex")
... ...
@@ -129,14 +129,23 @@ HeatmapAnnotation = function(...,
129 129
 	n_anno = 0
130 130
 
131 131
 	#### check system calls ####
132
+
133
+	# HeatmapAnnotation is either called by `HeatmapAnnotation()` or by `rowAnnotation()`/`columnAnnotation()`
132 134
 	sc = sys.calls()
133
-	for(i in seq_along(sc)) {
134
-		scl = as.list(sc[[i]])
135
+	nsc = length(sc)
136
+	if(nsc == 1) {
137
+		scl = as.list(sc[[1]])
138
+		arg_list = scl[-1]
139
+	} else {
140
+		scl = as.list(sc[[nsc-1]])
135 141
 		if(any(as.character(scl[[1]]) %in% c("HeatmapAnnotation", "rowAnnotation", "columnAnnotation"))) {
136 142
 			arg_list = scl[-1]
137
-			break
143
+		} else {
144
+			scl = as.list(sc[[nsc]])
145
+			arg_list = scl[-1]
138 146
 		}
139 147
 	}
148
+
140 149
     called_args = names(arg_list)
141 150
     anno_args = setdiff(called_args, fun_args)
142 151
     if(any(anno_args == "")) stop("annotations should have names.")
... ...
@@ -80,7 +80,7 @@ Heatmap(matrix, col, name,
80 80
     show_heatmap_legend = TRUE,
81 81
     heatmap_legend_param = list(title = name),
82 82
     
83
-    use_raster = nrow(matrix) > 2000 || ncol(matrix) > 2000,
83
+    use_raster = (nrow(matrix) > 2000 && ncol(matrix) > 1) || (ncol(matrix) > 2000 && nrow(matrix) > 1),
84 84
     raster_device = c("png", "jpeg", "tiff", "CairoPNG", "CairoJPEG", "CairoTIFF"),
85 85
     raster_quality = 2,
86 86
     raster_device_param = list(),
... ...
@@ -18,7 +18,7 @@ cluster_within_group(mat, factor)
18 18
 \details{
19 19
 The clustering is firstly applied in each group, then clustering is applied
20 20
 to group means. The within-group dendrograms and between-group dendrogram
21
-are finally connected by \code{\link{merge.dendrogram}}.
21
+are finally connected by \code{\link{merge_dendrogram}}.
22 22
 
23 23
 In the final dendrogram, the within group dendrograms are enforced to be 
24 24
 flat lines to emphasize that the within group dendrograms have no sense to 
25 25
similarity index 80%
26 26
rename from man/merge.dendrogram.rd
27 27
rename to man/merge_dendrogram.rd
... ...
@@ -1,5 +1,5 @@
1
-\name{merge.dendrogram}
2
-\alias{merge.dendrogram}
1
+\name{merge_dendrogram}
2
+\alias{merge_dendrogram}
3 3
 \title{
4 4
 Merge Dendrograms
5 5
 }
... ...
@@ -7,7 +7,7 @@ Merge Dendrograms
7 7
 Merge Dendrograms
8 8
 }
9 9
 \usage{
10
-\method{merge}{dendrogram}(x, y, only_parent = FALSE, ...)
10
+merge_dendrogram(x, y, only_parent = FALSE, ...)
11 11
 }
12 12
 \arguments{
13 13
 
... ...
@@ -28,10 +28,10 @@ dend1 = as.dendrogram(hclust(dist(m1)))
28 28
 dend2 = as.dendrogram(hclust(dist(m2)))
29 29
 dend3 = as.dendrogram(hclust(dist(m3)))
30 30
 dend_p = as.dendrogram(hclust(dist(rbind(colMeans(m1), colMeans(m2), colMeans(m3)))))
31
-dend_m = merge(dend_p, list(dend1, dend2, dend3))
31
+dend_m = merge_dendrogram(dend_p, list(dend1, dend2, dend3))
32 32
 grid.dendrogram(dend_m, test = TRUE)
33 33
 
34
-dend_m = merge(dend_p, list(dend1, dend2, dend3), only_parent = TRUE)
34
+dend_m = merge_dendrogram(dend_p, list(dend1, dend2, dend3), only_parent = TRUE)
35 35
 grid.dendrogram(dend_m, test = TRUE)
36 36
 
37 37
 require(dendextend)
... ...
@@ -39,6 +39,6 @@ dend1 = color_branches(dend1, k = 1, col = "red")
39 39
 dend2 = color_branches(dend2, k = 1, col = "blue")
40 40
 dend3 = color_branches(dend3, k = 1, col = "green")
41 41
 dend_p = color_branches(dend_p, k = 1, col = "orange")
42
-dend_m = merge(dend_p, list(dend1, dend2, dend3))
42
+dend_m = merge_dendrogram(dend_p, list(dend1, dend2, dend3))
43 43
 grid.dendrogram(dend_m, test = TRUE)
44 44
 }