Browse code

Commit made by the Bioconductor Git-SVN bridge.

Commit id: 73171be89c157222e8e71e85daa8a37ce509a4e2

add border argument in anno_* family functions



git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ComplexHeatmap@107201 bc3139a8-67e5-0310-9ffc-ced21a209358

z.gu authored on 06/08/2015 17:46:06
Showing 60 changed files

... ...
@@ -5,6 +5,7 @@
5 5
 # == param
6 6
 # -x a vector of numeric values.
7 7
 # -which is the annotation a column annotation or a row annotation?
8
+# -border whether show border of the annotation compoment
8 9
 # -gp graphic parameters.
9 10
 # -pch point type.
10 11
 # -size point size.
... ...
@@ -20,7 +21,7 @@
20 21
 # == author
21 22
 # Zuguang Gu <z.gu@dkfz.de>
22 23
 #
23
-anno_points = function(x, which = c("column", "row"), gp = gpar(), pch = 16, 
24
+anno_points = function(x, which = c("column", "row"), border = TRUE, gp = gpar(), pch = 16, 
24 25
 	size = unit(2, "mm"), axis = FALSE, axis_side = NULL, 
25 26
 	axis_gp = gpar(fontsize = 8), ...) {
26 27
 
... ...
@@ -54,7 +55,7 @@ anno_points = function(x, which = c("column", "row"), gp = gpar(), pch = 16,
54 55
 			}
55 56
 
56 57
 			pushViewport(viewport(xscale = data_scale, yscale = c(0.5, n+0.5)))
57
-			grid.rect()
58
+			if(border) grid.rect()
58 59
 			grid.points(x[index], n - seq_along(index) + 1, gp = gp, default.units = "native", pch = pch, size = size)
59 60
 			if(axis) {
60 61
 				if(k == 1 && axis_side == "top") {
... ...
@@ -70,7 +71,7 @@ anno_points = function(x, which = c("column", "row"), gp = gpar(), pch = 16,
70 71
 			gp = subset_gp(gp, index)
71 72
 
72 73
 			pushViewport(viewport(xscale = c(0.5, n+0.5), yscale = data_scale))
73
-			grid.rect()
74
+			if(border) grid.rect()
74 75
 			grid.points(seq_along(index), x[index], gp = gp, default.units = "native", pch = pch, size = size)
75 76
 			if(axis) {
76 77
 				if(axis_side == "left") {
... ...
@@ -89,6 +90,8 @@ anno_points = function(x, which = c("column", "row"), gp = gpar(), pch = 16,
89 90
 # == param
90 91
 # -x a vector of numeric values.
91 92
 # -which is the annotation a column annotation or a row annotation?
93
+# -border whether show border of the annotation compoment
94
+# -bar_width relative width of the bars, should less than one
92 95
 # -gp graphic parameters.
93 96
 # -axis whether add axis
94 97
 # -axis_side if it is placed as column annotation, value can only be "left" or "right".
... ...
@@ -102,14 +105,14 @@ anno_points = function(x, which = c("column", "row"), gp = gpar(), pch = 16,
102 105
 # == author
103 106
 # Zuguang Gu <z.gu@dkfz.de>
104 107
 #
105
-anno_barplot = function(x, which = c("column", "row"), 
108
+anno_barplot = function(x, which = c("column", "row"), border = TRUE, bar_width = 0.6,
106 109
 	gp = gpar(fill = "#CCCCCC"), axis = FALSE, axis_side = NULL, 
107 110
 	axis_gp = gpar(fontsize = 8), ...) {
108 111
 
109 112
 	x = x
110 113
 	which = match.arg(which)[1]
111 114
 
112
-	factor = 0.6
115
+	factor = bar_width
113 116
 	data_scale = range(x)
114 117
 	data_scale = data_scale + c(-0.05, 0.05)*(data_scale[2] - data_scale[1])
115 118
 	gp = check_gp(gp)
... ...
@@ -138,7 +141,7 @@ anno_barplot = function(x, which = c("column", "row"),
138 141
 			}
139 142
 
140 143
 			pushViewport(viewport(xscale = data_scale, yscale = c(0.5, n+0.5)))
141
-			grid.rect()
144
+			if(border) grid.rect()
142 145
 			grid.rect(x = data_scale[1], y = n - seq_along(index) + 1, width = x[index] - data_scale[1], height = 1*factor, just = "left", default.units = "native", gp = gp)
143 146
 			if(axis) {
144 147
 				if(k == 1 && axis_side == "top") {
... ...
@@ -155,7 +158,7 @@ anno_barplot = function(x, which = c("column", "row"),
155 158
 			gp = subset_gp(gp, index)
156 159
 			
157 160
 			pushViewport(viewport(xscale = c(0.5, n+0.5), yscale = data_scale))
158
-			grid.rect()
161
+			if(border) grid.rect()
159 162
 			grid.rect(x = seq_along(index), y = data_scale[1], height = x[index] - data_scale[1], width = 1*factor, just = "bottom", default.units = "native", gp = gp)
160 163
 			if(axis) {
161 164
 				if(axis_side == "left") {
... ...
@@ -175,6 +178,7 @@ anno_barplot = function(x, which = c("column", "row"),
175 178
 # -x a matrix or a list. If ``x`` is a matrix and if ``which`` is ``column``, statistics for boxplot
176 179
 #    is calculated by columns, if ``which`` is ``row``, the calculation is by rows.
177 180
 # -which is the annotation a column annotation or a row annotation?
181
+# -border whether show border of the annotation compoment
178 182
 # -gp graphic parameters
179 183
 # -pch point type
180 184
 # -size point size
... ...
@@ -189,7 +193,8 @@ anno_barplot = function(x, which = c("column", "row"),
189 193
 # == author
190 194
 # Zuguang Gu <z.gu@dkfz.de>
191 195
 #
192
-anno_boxplot = function(x, which = c("column", "row"), gp = gpar(fill = "#CCCCCC"), 
196
+anno_boxplot = function(x, which = c("column", "row"), border = TRUE,
197
+	gp = gpar(fill = "#CCCCCC"), 
193 198
 	pch = 16, size = unit(2, "mm"), axis = FALSE, axis_side = NULL, 
194 199
 	axis_gp = gpar(fontsize = 8)) {
195 200
 
... ...
@@ -234,7 +239,7 @@ anno_boxplot = function(x, which = c("column", "row"), gp = gpar(fill = "#CCCCCC
234 239
 				stop(paste0("Length of index should be ", ncol(boxplot_stats)))
235 240
 			}
236 241
 			pushViewport(viewport(xscale = data_scale, yscale = c(0.5, n+0.5)))
237
-			grid.rect()
242
+			if(border) grid.rect()
238 243
 			grid.segments(boxplot_stats[5, ], n - seq_along(index) + 1 - 0.5*factor, 
239 244
 				          boxplot_stats[5, ], n - seq_along(index) + 1 + 0.5*factor, default.units = "native", gp = gp)
240 245
 			grid.segments(boxplot_stats[5, ], n - seq_along(index) + 1,
... ...
@@ -271,7 +276,7 @@ anno_boxplot = function(x, which = c("column", "row"), gp = gpar(fill = "#CCCCCC
271 276
 				stop(paste0("Length of index should be ", ncol(boxplot_stats)))
272 277
 			}
273 278
 			pushViewport(viewport(xscale = c(0.5, n+0.5), yscale = data_scale))
274
-			grid.rect()
279
+			if(border) grid.rect()
275 280
 			grid.segments(seq_along(index) - 0.5*factor, boxplot_stats[5, ],
276 281
 				          seq_along(index) + 0.5*factor, boxplot_stats[5, ], default.units = "native", gp = gp)
277 282
 			grid.segments(seq_along(index), boxplot_stats[5, ],
278 283
new file mode 100644
279 284
Binary files /dev/null and b/inst/extdata/measles.rds differ
... ...
@@ -21,5 +21,6 @@ It is only designed for \code{+} generic method so that above three classes can
21 21
 
22 22
 
23 23
 
24
+
24 25
 # no example
25 26
 NULL}
... ...
@@ -33,5 +33,6 @@ Zuguang Gu <z.gu@dkfz.de>
33 33
 
34 34
 
35 35
 
36
+
36 37
 # no example
37 38
 NULL}
... ...
@@ -36,5 +36,6 @@ Zuguang Gu <z.gu@dkfz.de>
36 36
 
37 37
 
38 38
 
39
+
39 40
 # for examples, please go to `ColorMapping` method page
40 41
 NULL}
... ...
@@ -44,6 +44,7 @@ Zuguang Gu <z.gu@dkfz.de>
44 44
 
45 45
 
46 46
 
47
+
47 48
 # discrete color mapping for characters
48 49
 cm = ColorMapping(name = "test",
49 50
     colors = c("blue", "white", "red"),
... ...
@@ -78,5 +78,6 @@ Zuguang Gu <z.gu@dkfz.de>
78 78
 
79 79
 
80 80
 
81
+
81 82
 # for examples, please go to `Heatmap` method page
82 83
 NULL}
... ...
@@ -128,6 +128,7 @@ Zuguang Gu <z.gu@dkfz.de>
128 128
 
129 129
 
130 130
 
131
+
131 132
 mat = matrix(rnorm(80, 2), 8, 10)
132 133
 mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
133 134
 rownames(mat) = letters[1:12]
... ...
@@ -35,5 +35,6 @@ Zuguang Gu <z.gu@dkfz.de>
35 35
 
36 36
 
37 37
 
38
+
38 39
 # for examples, please go to `HeatmapAnnotation` method page
39 40
 NULL}
... ...
@@ -54,6 +54,7 @@ Zuguang Gu <z.gu@dkfz.de>
54 54
 
55 55
 
56 56
 
57
+
57 58
 df = data.frame(type = c("a", "a", "a", "b", "b", "b"))
58 59
 ha = HeatmapAnnotation(df = df)
59 60
 
... ...
@@ -74,6 +74,7 @@ Zuguang Gu <z.gu@dkfz.de>
74 74
 
75 75
 
76 76
 
77
+
77 78
 mat = matrix(rnorm(80, 2), 8, 10)
78 79
 mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
79 80
 rownames(mat) = letters[1:12]
... ...
@@ -33,6 +33,7 @@ Zuguang Gu <z.gu@dkfz.de>
33 33
 
34 34
 
35 35
 
36
+
36 37
 There is no public constructor method for the \code{\link{HeatmapList-class}}.}
37 38
 \examples{
38 39
 
... ...
@@ -41,5 +42,6 @@ There is no public constructor method for the \code{\link{HeatmapList-class}}.}
41 42
 
42 43
 
43 44
 
45
+
44 46
 # no example
45 47
 NULL}
... ...
@@ -45,5 +45,6 @@ Zuguang Gu <z.gu@dkfz.de>
45 45
 
46 46
 
47 47
 
48
+
48 49
 # for examples, please go to `SingleAnnotation` method page
49 50
 NULL}
... ...
@@ -55,6 +55,7 @@ Zuguang Gu <z.gu@dkfz.de>
55 55
 
56 56
 
57 57
 
58
+
58 59
 # discrete character
59 60
 SingleAnnotation(name = "test", value = c("a", "a", "a", "b", "b", "b"))
60 61
 SingleAnnotation(name = "test", value = c("a", "a", "a", "b", "b", "b"), 
... ...
@@ -37,6 +37,7 @@ Zuguang Gu <z.gu@dkfz.de>
37 37
 
38 38
 
39 39
 
40
+
40 41
 mat = matrix(rnorm(80, 2), 8, 10)
41 42
 mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
42 43
 rownames(mat) = letters[1:12]
... ...
@@ -34,6 +34,7 @@ Zuguang Gu <z.gu@dkfz.de>
34 34
 
35 35
 
36 36
 
37
+
37 38
 mat = matrix(rnorm(80, 2), 8, 10)
38 39
 mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
39 40
 rownames(mat) = letters[1:12]
... ...
@@ -34,6 +34,7 @@ Zuguang Gu <z.gu@dkfz.de>
34 34
 
35 35
 
36 36
 
37
+
37 38
 mat = matrix(rnorm(80, 2), 8, 10)
38 39
 mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
39 40
 rownames(mat) = letters[1:12]
... ...
@@ -34,6 +34,7 @@ Zuguang Gu <z.gu@dkfz.de>
34 34
 
35 35
 
36 36
 
37
+
37 38
 mat = matrix(rnorm(80, 2), 8, 10)
38 39
 mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
39 40
 rownames(mat) = letters[1:12]
... ...
@@ -9,13 +9,15 @@ Using barplot as annotation
9 9
 
10 10
 }
11 11
 \usage{
12
-anno_barplot(x, which = c("column", "row"),
12
+anno_barplot(x, which = c("column", "row"), border = TRUE, bar_width = 0.6,
13 13
     gp = gpar(fill = "#CCCCCC"), axis = FALSE, axis_side = NULL,
14 14
     axis_gp = gpar(fontsize = 8), ...)}
15 15
 \arguments{
16 16
 
17 17
   \item{x}{a vector of numeric values.}
18 18
   \item{which}{is the annotation a column annotation or a row annotation?}
19
+  \item{border}{whether show border of the annotation compoment}
20
+  \item{bar_width}{relative width of the bars, should less than one}
19 21
   \item{gp}{graphic parameters.}
20 22
   \item{axis}{whether add axis}
21 23
   \item{axis_side}{if it is placed as column annotation, value can only be "left" or "right".If it is placed as row annotation, value can only be "bottom" or "top".}
... ...
@@ -37,6 +39,7 @@ Zuguang Gu <z.gu@dkfz.de>
37 39
 
38 40
 
39 41
 
42
+
40 43
 f = anno_barplot(rnorm(10))
41 44
 grid.newpage(); f(1:10)
42 45
 
... ...
@@ -9,13 +9,15 @@ Using boxplot as annotation
9 9
 
10 10
 }
11 11
 \usage{
12
-anno_boxplot(x, which = c("column", "row"), gp = gpar(fill = "#CCCCCC"),
12
+anno_boxplot(x, which = c("column", "row"), border = TRUE,
13
+    gp = gpar(fill = "#CCCCCC"),
13 14
     pch = 16, size = unit(2, "mm"), axis = FALSE, axis_side = NULL,
14 15
     axis_gp = gpar(fontsize = 8))}
15 16
 \arguments{
16 17
 
17 18
   \item{x}{a matrix or a list. If \code{x} is a matrix and if \code{which} is \code{column}, statistics for boxplotis calculated by columns, if \code{which} is \code{row}, the calculation is by rows.}
18 19
   \item{which}{is the annotation a column annotation or a row annotation?}
20
+  \item{border}{whether show border of the annotation compoment}
19 21
   \item{gp}{graphic parameters}
20 22
   \item{pch}{point type}
21 23
   \item{size}{point size}
... ...
@@ -38,6 +40,7 @@ Zuguang Gu <z.gu@dkfz.de>
38 40
 
39 41
 
40 42
 
43
+
41 44
 mat = matrix(rnorm(32), nrow = 4)
42 45
 f = anno_boxplot(mat)
43 46
 grid.newpage(); f(1:8)
... ...
@@ -34,6 +34,7 @@ Zuguang Gu <z.gu@dkfz.de>
34 34
 
35 35
 
36 36
 
37
+
37 38
 mat = matrix(rnorm(32), nrow = 4)
38 39
 f = anno_density(mat)
39 40
 grid.newpage(); f(1:8)
... ...
@@ -32,6 +32,7 @@ Zuguang Gu <z.gu@dkfz.de>
32 32
 
33 33
 
34 34
 
35
+
35 36
 mat = matrix(rnorm(32), nrow = 4)
36 37
 f = anno_histogram(mat)
37 38
 grid.newpage(); f(1:8)
... ...
@@ -9,13 +9,14 @@ Using points as annotation
9 9
 
10 10
 }
11 11
 \usage{
12
-anno_points(x, which = c("column", "row"), gp = gpar(), pch = 16,
12
+anno_points(x, which = c("column", "row"), border = TRUE, gp = gpar(), pch = 16,
13 13
     size = unit(2, "mm"), axis = FALSE, axis_side = NULL,
14 14
     axis_gp = gpar(fontsize = 8), ...)}
15 15
 \arguments{
16 16
 
17 17
   \item{x}{a vector of numeric values.}
18 18
   \item{which}{is the annotation a column annotation or a row annotation?}
19
+  \item{border}{whether show border of the annotation compoment}
19 20
   \item{gp}{graphic parameters.}
20 21
   \item{pch}{point type.}
21 22
   \item{size}{point size.}
... ...
@@ -39,5 +40,6 @@ Zuguang Gu <z.gu@dkfz.de>
39 40
 
40 41
 
41 42
 
43
+
42 44
 f = anno_points(rnorm(10))
43 45
 grid.newpage(); f(1:10)}
... ...
@@ -35,6 +35,7 @@ Zuguang Gu <z.gu@dkfz.de>
35 35
 
36 36
 
37 37
 
38
+
38 39
 mat = matrix(rnorm(100), 10)
39 40
 colnames(mat) = letters[1:10]
40 41
 rownames(mat) = LETTERS[1:10]
... ...
@@ -39,5 +39,6 @@ Zuguang Gu <z.gu@dkfz.de>
39 39
 
40 40
 
41 41
 
42
+
42 43
 # no example for this internal method
43 44
 NULL}
... ...
@@ -44,6 +44,7 @@ Zuguang Gu <z.gu@dkfz.de>
44 44
 
45 45
 
46 46
 
47
+
47 48
 # discrete color mapping for characters
48 49
 cm = ColorMapping(name = "test",
49 50
     colors = c("blue", "white", "red"),
... ...
@@ -37,5 +37,6 @@ Zuguang Gu <z.gu@dkfz.de>
37 37
 
38 38
 
39 39
 
40
+
40 41
 df = data.frame(type = c("a", "a", "a", "b", "b", "b"))
41 42
 ha = rowAnnotation(df = df)}
... ...
@@ -34,4 +34,5 @@ Zuguang Gu <z.gu@dkfz.de>
34 34
 
35 35
 
36 36
 
37
+
37 38
 # no example for this internal method}
... ...
@@ -30,4 +30,5 @@ Zuguang Gu <z.gu@dkfz.de>
30 30
 
31 31
 
32 32
 
33
+
33 34
 # no example for this internal method}
... ...
@@ -26,6 +26,7 @@ This function is only for internal use.
26 26
 
27 27
 
28 28
 
29
+
29 30
 This function is only for internal use.}
30 31
 \value{
31 32
 A \code{\link[grid]{unit}} object.
... ...
@@ -42,4 +43,5 @@ Zuguang Gu <z.gu@dkfz.de>
42 43
 
43 44
 
44 45
 
46
+
45 47
 # no example for this internal method}
... ...
@@ -34,4 +34,5 @@ Zuguang Gu <z.gu@dkfz.de>
34 34
 
35 35
 
36 36
 
37
+
37 38
 # no example for this internal method}
... ...
@@ -36,6 +36,7 @@ Zuguang Gu <z.gu@dkfz.de>
36 36
 
37 37
 
38 38
 
39
+
39 40
 mat = matrix(rnorm(40), nr = 4, ncol = 10)
40 41
 rownames(mat) = letters[1:4]
41 42
 colnames(mat) = letters[1:10]
... ...
@@ -37,6 +37,7 @@ Zuguang Gu <z.gu@dkfz.de>
37 37
 
38 38
 
39 39
 
40
+
40 41
 mat = matrix(rnorm(80, 2), 8, 10)
41 42
 mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
42 43
 rownames(mat) = letters[1:12]
... ...
@@ -37,6 +37,7 @@ Zuguang Gu <z.gu@dkfz.de>
37 37
 
38 38
 
39 39
 
40
+
40 41
 df = data.frame(type = c("a", "a", "a", "b", "b", "b"))
41 42
 ha = HeatmapAnnotation(df = df)
42 43
 grid.newpage(); draw(ha, 1:6)
... ...
@@ -40,6 +40,7 @@ Zuguang Gu <z.gu@dkfz.de>
40 40
 
41 41
 
42 42
 
43
+
43 44
 mat = matrix(rnorm(80, 2), 8, 10)
44 45
 mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
45 46
 rownames(mat) = letters[1:12]
... ...
@@ -38,6 +38,7 @@ Zuguang Gu <z.gu@dkfz.de>
38 38
 
39 39
 
40 40
 
41
+
41 42
 anno = SingleAnnotation(name = "test", value = c("a", "a", "a", "b", "b", "b"))
42 43
 grid.newpage(); draw(anno, 1:5)
43 44
 grid.newpage(); draw(anno, c(1, 4, 3, 5, 2))
... ...
@@ -40,5 +40,6 @@ Zuguang Gu <z.gu@dkfz.de>
40 40
 
41 41
 
42 42
 
43
+
43 44
 # no example for this internal method
44 45
 NULL}
... ...
@@ -38,5 +38,6 @@ Zuguang Gu <z.gu@dkfz.de>
38 38
 
39 39
 
40 40
 
41
+
41 42
 # no example for this internal method
42 43
 NULL}
... ...
@@ -41,5 +41,6 @@ Zuguang Gu <z.gu@dkfz.de>
41 41
 
42 42
 
43 43
 
44
+
44 45
 # no example for this internal method
45 46
 NULL}
... ...
@@ -48,5 +48,6 @@ Zuguang Gu <z.gu@dkfz.de>
48 48
 
49 49
 
50 50
 
51
+
51 52
 # no example for this internal method
52 53
 NULL}
... ...
@@ -42,5 +42,6 @@ Zuguang Gu <z.gu@dkfz.de>
42 42
 
43 43
 
44 44
 
45
+
45 46
 # no example for this internal method
46 47
 NULL}
... ...
@@ -38,5 +38,6 @@ Zuguang Gu <z.gu@dkfz.de>
38 38
 
39 39
 
40 40
 
41
+
41 42
 # no example for this internal method
42 43
 NULL}
... ...
@@ -36,5 +36,6 @@ Zuguang Gu <z.gu@dkfz.de>
36 36
 
37 37
 
38 38
 
39
+
39 40
 # no example for this internal method
40 41
 NULL}
... ...
@@ -39,5 +39,6 @@ Zuguang Gu <z.gu@dkfz.de>
39 39
 
40 40
 
41 41
 
42
+
42 43
 # no example for this internal method
43 44
 NULL}
... ...
@@ -37,5 +37,6 @@ Zuguang Gu <z.gu@dkfz.de>
37 37
 
38 38
 
39 39
 
40
+
40 41
 # no example for this internal method
41 42
 NULL}
... ...
@@ -36,5 +36,6 @@ Zuguang Gu <z.gu@dkfz.de>
36 36
 
37 37
 
38 38
 
39
+
39 40
 # no example for this internal method
40 41
 NULL}
... ...
@@ -40,6 +40,7 @@ Zuguang Gu <z.gu@dkfz.de>
40 40
 
41 41
 
42 42
 
43
+
43 44
 hc = hclust(dist(USArrests[1:5, ]))
44 45
 dend = as.dendrogram(hc)
45 46
 
... ...
@@ -36,5 +36,6 @@ Zuguang Gu <z.gu@dkfz.de>
36 36
 
37 37
 
38 38
 
39
+
39 40
 # no example for this internal method
40 41
 NULL}
... ...
@@ -36,5 +36,6 @@ Zuguang Gu <z.gu@dkfz.de>
36 36
 
37 37
 
38 38
 
39
+
39 40
 # no example for this internal method
40 41
 NULL}
... ...
@@ -39,5 +39,6 @@ Zuguang Gu <z.gu@dkfz.de>
39 39
 
40 40
 
41 41
 
42
+
42 43
 # no example for this internal method
43 44
 NULL}
... ...
@@ -65,5 +65,6 @@ Zuguang Gu <z.gu@dkfz.de>
65 65
 
66 66
 
67 67
 
68
+
68 69
 # no example for this internal method
69 70
 NULL}
... ...
@@ -38,5 +38,6 @@ Zuguang Gu <z.gu@dkfz.de>
38 38
 
39 39
 
40 40
 
41
+
41 42
 # no example for this internal method
42 43
 NULL}
... ...
@@ -35,6 +35,7 @@ Zuguang Gu <z.gu@dkfz.de>
35 35
 
36 36
 
37 37
 
38
+
38 39
 # discrete color mapping for characters
39 40
 cm = ColorMapping(name = "test",
40 41
     colors = c("blue", "white", "red"),
... ...
@@ -53,6 +53,7 @@ Zuguang Gu <z.gu@dkfz.de>
53 53
 
54 54
 
55 55
 
56
+
56 57
 df = data.frame(matrix(rnorm(40), nrow = 10, dimnames = list(letters[1:10], letters[1:4])),
57 58
                 large = runif(10)*100,
58 59
                 t1 = sample(letters[1:3], 10, replace = TRUE),
... ...
@@ -43,5 +43,6 @@ Zuguang Gu <z.gu@dkfz.de>
43 43
 
44 44
 
45 45
 
46
+
46 47
 # no example for this internal method
47 48
 NULL}
... ...
@@ -37,5 +37,6 @@ Zuguang Gu <z.gu@dkfz.de>
37 37
 
38 38
 
39 39
 
40
+
40 41
 df = data.frame(type = c("a", "a", "a", "b", "b", "b"))
41 42
 ha = columnAnnotation(df = df)}
... ...
@@ -36,5 +36,6 @@ Zuguang Gu <z.gu@dkfz.de>
36 36
 
37 37
 
38 38
 
39
+
39 40
 # no example for this internal method
40 41
 NULL}
... ...
@@ -34,6 +34,7 @@ Zuguang Gu <z.gu@dkfz.de>
34 34
 
35 35
 
36 36
 
37
+
37 38
 mat = matrix(rnorm(80, 2), 8, 10)
38 39
 mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
39 40
 rownames(mat) = letters[1:12]
... ...
@@ -30,4 +30,5 @@ This function returns no value.
30 30
 
31 31
 
32 32
 
33
+
33 34
 Zuguang Gu <z.gu@dkfz.de>}
... ...
@@ -83,3 +83,18 @@ for colors for continous values.
83 83
 Heatmap(mat, col = topo.colors(50), row_hclust_width = unit(2, "cm"), 
84 84
     column_hclust_height = unit(2, "cm"))
85 85
 ```
86
+
87
+```
88
+mat = readRDS(paste0(system.files("extdata", package = "ComplexHeatmap"), "/measles.RData"))
89
+ha = HeatmapAnnotation(dist = anno_barplot(colSums(mat)))
90
+Heatmap(mat, name = "mat", col = colorRamp2(c(0, 800, 1000, 127000), c("white", "cornflowerblue", "yellow", "red")),
91
+    cluster_columns = FALSE, show_row_hclust = FALSE, rect_gp = gpar(col= "white"),
92
+    column_title = 'Measles cases in US states 1930-2001\nVaccine introduced 1961\n(data from Project Tycho)',
93
+    top_annotation = ha, top_annotation_height = unit(4, "cm"))
94
+
95
+decorate_heatmap_body("mat", {
96
+    i = which(yd$year == 1961)
97
+    x = i/ncol(mat)
98
+    grid.lines(c(x, x), c(0, 1), gp = gpar(lty = 2, lwd = 2))
99
+})
100
+```
86 101
\ No newline at end of file