Browse code

Commit made by the Bioconductor Git-SVN bridge.

Commit id: 174dbdcbcad3be858d664784793f1b2424acc2c0

remove plot.HeatmapList and print.HeatmapList



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

z.gu authored on 18/07/2015 18:14:29
Showing 71 changed files

... ...
@@ -2,7 +2,7 @@ Package: ComplexHeatmap
2 2
 Type: Package
3 3
 Title: Making Complex Heatmaps
4 4
 Version: 1.2.4
5
-Date: 2015-7-11
5
+Date: 2015-7-18
6 6
 Author: Zuguang Gu
7 7
 Maintainer: Zuguang Gu <z.gu@dkfz.de>
8 8
 Depends: R (>= 3.1.0), grid
... ...
@@ -17,6 +17,6 @@ Description: Complex heatmaps are efficient to visualize associations
17 17
 biocViews: Software, Visualization, Sequencing
18 18
 URL: https://github.com/jokergoo/ComplexHeatmap
19 19
 License: GPL (>= 2)
20
-Packaged: 2015-7-11 00:00:00 UTC; Administrator
20
+Packaged: 2015-7-18 00:00:00 UTC; Administrator
21 21
 Repository: Bioconductor
22
-Date/Publication: 2015-7-11 00:00:00
22
+Date/Publication: 2015-7-18 00:00:00
... ...
@@ -16,7 +16,7 @@
16 16
 #
17 17
 # - `ColorMapping`: contructor methods.
18 18
 # - `map_to_colors,ColorMapping-method`: mapping values to colors.
19
-# - `color_mapping_legend,ColorMapping-method`: draw legend or get the size of the legend.
19
+# - `color_mapping_legend,ColorMapping-method`: draw legend or get legend as a `grid::grob` object.
20 20
 #
21 21
 # == author
22 22
 # Zuguang Gu <z.gu@dkfz.de>
... ...
@@ -38,7 +38,7 @@ ColorMapping = setClass("ColorMapping",
38 38
 # Constructor methods for ColorMapping class
39 39
 #
40 40
 # == param
41
-# -name name for this color mapping. It is used for drawing the title of the legend.
41
+# -name name for this color mapping. The name is automatically generated if it is not specified.
42 42
 # -colors discrete colors.
43 43
 # -levels levels that correspond to ``colors``. If ``colors`` is name indexed, 
44 44
 #         ``levels`` can be ignored.
... ...
@@ -49,7 +49,8 @@ ColorMapping = setClass("ColorMapping",
49 49
 #            If it is ``FALSE``, proper breaks values will be automatically generated.
50 50
 # -na_col colors for ``NA`` values.
51 51
 # -legend_title title of the legend, by default it is the name of the legend
52
-# -color_bar if the color mapping is continuous, whether draw the legend discrete or continuous.
52
+# -color_bar if the color mapping is continuous, whether draw the legend discrete or continuous. 
53
+#         Possible values are "discrete" and "continuous". Current implementation of continuous color bar is not a nice one and will be improved in future.
53 54
 #
54 55
 # == detail
55 56
 # ``colors`` and ``levels`` are used for discrete color mapping, ``col_fun`` and 
... ...
@@ -179,7 +179,11 @@ Heatmap = setClass("Heatmap",
179 179
 #        is appended to a list of heatmaps.
180 180
 # -show_heatmap_legend whether show heatmap legend?
181 181
 # -heatmap_legend_title title for the heatmap legend. By default it is the name of the heatmap
182
-# -heatmap_legend_color_bar if the matrix is continuous, whether should the legend as continuous color bar as well?
182
+# -heatmap_legend_color_bar if the matrix is continuous, whether should the legend as continuous color bar as well? 
183
+#           Possible values are "discrete" and "continuous". Current implementation of continuous color bar is not a nice one and will be improved in future.
184
+# -heatmap_legend_enforce_breaks For numeric matrix, if it is set to `TRUE` and ``col`` is specified by `circlize::colorRamp2`
185
+#        break values specified in `circlize::colorRamp2` will be the final break value in the legend.
186
+#        Or else, proper breaks values will be automatically generated.
183 187
 #
184 188
 # == details
185 189
 # The initialization function only applies parameter checking and fill values to each slot with proper ones.
... ...
@@ -203,7 +207,8 @@ Heatmap = setClass("Heatmap",
203 207
 Heatmap = function(matrix, col, name, na_col = "grey", rect_gp = gpar(col = NA), 
204 208
     cell_fun = function(j, i, x, y, width, height, fill) NULL,
205 209
     row_title = character(0), row_title_side = c("left", "right"), 
206
-    row_title_gp = gpar(fontsize = 14), row_title_rot = switch(row_title_side[1], "left" = 90, "right" = 270),
210
+    row_title_gp = gpar(fontsize = 14), 
211
+    row_title_rot = switch(row_title_side[1], "left" = 90, "right" = 270),
207 212
     column_title = character(0), column_title_side = c("top", "bottom"), 
208 213
     column_title_gp = gpar(fontsize = 14), column_title_rot = 0,
209 214
     cluster_rows = TRUE, clustering_distance_rows = "euclidean",
... ...
@@ -227,7 +232,8 @@ Heatmap = function(matrix, col, name, na_col = "grey", rect_gp = gpar(col = NA),
227 232
     combined_name_fun = function(x) paste(x, collapse = "/"),
228 233
     width = NULL, show_heatmap_legend = TRUE,
229 234
     heatmap_legend_title = name,
230
-    heatmap_legend_color_bar = c("discrete", "continuous")) {
235
+    heatmap_legend_color_bar = c("discrete", "continuous"),
236
+    heatmap_legend_enforce_breaks = FALSE) {
231 237
 
232 238
     .Object = new("Heatmap")
233 239
 
... ...
@@ -303,21 +309,21 @@ Heatmap = function(matrix, col, name, na_col = "grey", rect_gp = gpar(col = NA),
303 309
             col = default_col(matrix, main_matrix = TRUE)
304 310
         }
305 311
         if(is.function(col)) {
306
-            .Object@matrix_color_mapping = ColorMapping(col_fun = col, name = name, legend_title = heatmap_legend_title, na_col = na_col, color_bar = heatmap_legend_color_bar)
312
+            .Object@matrix_color_mapping = ColorMapping(col_fun = col, name = name, legend_title = heatmap_legend_title, na_col = na_col, color_bar = heatmap_legend_color_bar, enforce_breaks = heatmap_legend_enforce_breaks)
307 313
         } else {
308 314
             if(is.null(names(col))) {
309 315
                 if(length(col) == length(unique(matrix))) {
310 316
                     names(col) = unique(matrix)
311
-                    .Object@matrix_color_mapping = ColorMapping(colors = col, name = name, legend_title = heatmap_legend_title, na_col = na_col, color_bar = heatmap_legend_color_bar)
317
+                    .Object@matrix_color_mapping = ColorMapping(colors = col, name = name, legend_title = heatmap_legend_title, na_col = na_col, color_bar = heatmap_legend_color_bar, enforce_breaks = heatmap_legend_enforce_breaks)
312 318
                 } else if(is.numeric(matrix)) {
313 319
                     col = colorRamp2(seq(min(matrix, na.rm = TRUE), max(matrix, na.rm = TRUE), length = length(col)),
314 320
                                      col)
315
-                    .Object@matrix_color_mapping = ColorMapping(col_fun = col, name = name, legend_title = heatmap_legend_title, na_col = na_col, color_bar = heatmap_legend_color_bar)
321
+                    .Object@matrix_color_mapping = ColorMapping(col_fun = col, name = name, legend_title = heatmap_legend_title, na_col = na_col, color_bar = heatmap_legend_color_bar, enforce_breaks = heatmap_legend_enforce_breaks)
316 322
                 } else {
317 323
                     stop("`col` should have names to map to values in `mat`.")
318 324
                 }
319 325
             } else {
320
-                .Object@matrix_color_mapping = ColorMapping(colors = col, name = name, legend_title = heatmap_legend_title, na_col = na_col, color_bar = heatmap_legend_color_bar)
326
+                .Object@matrix_color_mapping = ColorMapping(colors = col, name = name, legend_title = heatmap_legend_title, na_col = na_col, color_bar = heatmap_legend_color_bar, enforce_breaks = heatmap_legend_enforce_breaks)
321 327
             }
322 328
         }
323 329
     }
... ...
@@ -1,13 +1,11 @@
1 1
 
2
-
3
-
4 2
 # == title
5 3
 # Class for heatmap annotations
6 4
 #
7 5
 # == details
8
-# A complex heatmap contains a list of annotations which represent as different graphics
9
-# placed on rows and columns. The `HeatmapAnnotation-class` is a category of single annotations which are
10
-# by a list of `SingleAnnotation-class` objects with same number of rows or columns.
6
+# A complex heatmap contains a list of annotations which are represented as different graphics
7
+# placed on rows and columns. The `HeatmapAnnotation-class` contains a list of single annotations which are
8
+# represented as a list of `SingleAnnotation-class` objects with same number of rows or columns.
11 9
 #
12 10
 # == methods
13 11
 # The `HeatmapAnnotation-class` provides following methods:
... ...
@@ -42,7 +40,8 @@ HeatmapAnnotation = setClass("HeatmapAnnotation",
42 40
 # -df a data frame. Each column will be treated as a simple annotation. The data frame must have column names.
43 41
 # -name name of the heatmap annotation, optional.
44 42
 # -col a list of colors which contains color mapping to columns in ``df``. See `SingleAnnotation` for how to set colors.
45
-# -color_bar if there are continuous values in ``df``, show the legend as discrete or continuous
43
+# -color_bar if there are continuous values in ``df``, whether show the legend as discrete or continuous. 
44
+#            Possible values are "discrete" and "continuous". It can be a vector for which each one corresponds to each column in ``df``.
46 45
 # -show_legend whether show legend for each column in ``df``.
47 46
 # -... functions which define complex annotations. Values should be named arguments.
48 47
 # -which are the annotations row annotations or column annotations?
... ...
@@ -560,7 +560,8 @@ setMethod(f = "make_layout",
560 560
 #
561 561
 setMethod(f = "draw",
562 562
     signature = "HeatmapList",
563
-    definition = function(object, padding = unit(c(2, 2, 2, 2), "mm"), ..., newpage= TRUE) {
563
+    definition = function(object, padding = unit(c(2, 2, 2, 2), "mm"), ..., 
564
+        newpage= TRUE) {
564 565
 
565 566
     if(! any(sapply(object@ht_list, inherits, "Heatmap"))) {
566 567
         stop("There should be at least one Heatmap in the heatmap list. You can add a matrix with zero column to the list.")
... ...
@@ -45,8 +45,8 @@ SingleAnnotation = setClass("SingleAnnotation",
45 45
 # Constructor method for SingleAnnotation class
46 46
 #
47 47
 # == param
48
-# -name name for this annotation.
49
-# -value A vector of annotation.
48
+# -name name for this annotation. If it is not specified, an internal name is assigned to it.
49
+# -value A vector of discrete or continuous annotation.
50 50
 # -col colors corresponding to ``value``. If the mapping is discrete mapping, the value of ``col``
51 51
 #      should be a vector; If the mapping is continuous mapping, the value of ``col`` should be 
52 52
 #      a color mapping function. 
... ...
@@ -54,8 +54,9 @@ SingleAnnotation = setClass("SingleAnnotation",
54 54
 #      be a vector of index that corresponds to rows or columns.
55 55
 # -which is the annotation a row annotation or a column annotation?
56 56
 # -show_legend if it is a simple annotation, whether show legend when making the complete heatmap.
57
-# -gp graphic parameters for simple annotations.
57
+# -gp Since simple annotation is represented as a row of grids. This argument controls graphic parameters for the simple annotation.
58 58
 # -color_bar if the color mapping is continuous, whether draw the legend discrete or continuous. Onl works for simple annotation.
59
+#            Pass to `ColorMapping`.
59 60
 #
60 61
 # == details
61 62
 # The most simple annotation is one row or one column grids in which different colors
... ...
@@ -154,7 +155,8 @@ SingleAnnotation = function(name, value, col, fun, which = c("column", "row"),
154 155
 # == param
155 156
 # -object a `SingleAnnotation-class` object.
156 157
 # -index a vector of orders
157
-# -k if row annotation is splitted, the value identifies which row slice.
158
+# -k if row annotation is splitted, the value identifies which row slice. It is only used for the naems of the viewport
159
+#    which contains the annotation graphics.
158 160
 #
159 161
 # == details
160 162
 # A viewport is created.
... ...
@@ -3,13 +3,14 @@
3 3
 # Using points as annotation
4 4
 #
5 5
 # == param
6
-# -x a vector of values.
6
+# -x a vector of numeric values.
7 7
 # -which is the annotation a column annotation or a row annotation?
8 8
 # -gp graphic parameters.
9 9
 # -pch point type.
10 10
 # -size point size.
11
-# -axis whether add axis
12
-# -axis_side value in "left", "right", "bottom" and "top"
11
+# -axis whether add axis.
12
+# -axis_side if it is placed as column annotation, value can only be "left" or "right".
13
+#            If it is placed as row annotation, value can only be "bottom" or "top".
13 14
 # -axis_gp graphic parameters for axis
14 15
 # -... for future use.
15 16
 #
... ...
@@ -83,11 +84,12 @@ anno_points = function(x, which = c("column", "row"), gp = gpar(), pch = 16,
83 84
 # Using barplot as annotation
84 85
 #
85 86
 # == param
86
-# -x a vector of values.
87
+# -x a vector of numeric values.
87 88
 # -which is the annotation a column annotation or a row annotation?
88 89
 # -gp graphic parameters.
89 90
 # -axis whether add axis
90
-# -axis_side value in "left", "right", "bottom" and "top"
91
+# -axis_side if it is placed as column annotation, value can only be "left" or "right".
92
+#            If it is placed as row annotation, value can only be "bottom" or "top".
91 93
 # -axis_gp graphic parameters for axis
92 94
 # -... for future use.
93 95
 #
... ...
@@ -170,7 +172,8 @@ anno_barplot = function(x, which = c("column", "row"),
170 172
 # -pch point type
171 173
 # -size point size
172 174
 # -axis whether add axis
173
-# -axis_side value in "left", "right", "bottom" and "top"
175
+# -axis_side if it is placed as column annotation, value can only be "left" or "right".
176
+#            If it is placed as row annotation, value can only be "bottom" or "top".
174 177
 # -axis_gp graphic parameters for axis
175 178
 #
176 179
 # == value
... ...
@@ -508,7 +511,9 @@ anno_density = function(x, which = c("column", "row"), gp = gpar(fill = "#CCCCCC
508 511
 # -gp graphic parameters.
509 512
 # -rot rotation of text
510 513
 # -just justification of text, pass to `grid::grid.text`
511
-# -offset offset relative to start position
514
+# -offset if it is a row annotation, ``offset`` corresponds to the x-coordinates of text.
515
+#         and if it is a column annotation, ``offset`` corresponds to the y-coordinates of text.
516
+#         The value should be a `grid::unit` object.
512 517
 #
513 518
 # == value
514 519
 # A graphic function which can be set in `HeatmapAnnotation` constructor method.
... ...
@@ -3,16 +3,17 @@
3 3
 # Use colors to represent density distribution
4 4
 #
5 5
 # == param
6
-# -data  a matrix or a list. If it is a matrix, density will be calculated by columns
7
-# -col a list of colors that density values are mapped to
8
-# -anno annotation for matrix columns or list, a vector or a data frame. The order of elements or rows corresponding to the orders of elements of rows of ``data``
6
+# -data  a matrix or a list. If it is a matrix, density will be calculated by columns.
7
+# -col a list of colors that density values are scaled to.
8
+# -anno annotation for matrix columns or list. The value should be a vector or a data frame. 
9
+#       It can also be a `HeatmapAnnotation-class` object.
9 10
 # -ylab label on y-axis in the plot
10 11
 # -title title of the plot
11 12
 #
12 13
 # == details
13 14
 # To visualize distribution of columns in a matrix or in a list, sometimes we use boxplot or beanplot.
14 15
 # Here we use colors to map to the density values and visualize distribution of values
15
-# in each column (or each list element) through a heatmap. It is useful if you have huge number of columns in ``data`` to visualize.
16
+# in each column (or each element in the list) through a heatmap. It is useful if you have huge number of columns in ``data`` to visualize.
16 17
 #
17 18
 # == value
18 19
 # No value is returned.
... ...
@@ -23,12 +24,15 @@
23 24
 # densityHeatmap(matrix, anno = rep(c("A", "B"), each = 5))
24 25
 # densityHeatmap(matrix, col = c("white", "red"), anno = rep(c("A", "B"), each = 5))
25 26
 #
27
+# ha = HeatmapAnnotation(points = anno_points(runif(10)))
28
+# densityHeatmap(matrix, anno = ha)
29
+#
26 30
 # lt = list(rnorm(10), rnorm(10))
27 31
 # densityHeatmap(lt)
28 32
 #
29 33
 densityHeatmap = function(data, col = rev(brewer.pal(11, "Spectral")),
30 34
 	anno = NULL, ylab = deparse(substitute(data)), 
31
-	title = paste0("density heatmap of ", deparse(substitute(data)))) {
35
+	title = paste0("Density heatmap of ", deparse(substitute(data)))) {
32 36
 
33 37
 	if(is.matrix(data)) {
34 38
 		density_list = apply(data, 2, density)
... ...
@@ -59,6 +63,8 @@ densityHeatmap = function(data, col = rev(brewer.pal(11, "Spectral")),
59 63
 
60 64
 	if(is.null(anno)) {
61 65
 		ht = Heatmap(mat, col = col, name = "density", cluster_rows = FALSE, cluster_columns = FALSE)
66
+	} else if(inherits(anno, "HeatmapAnnotation")) {
67
+		ht = Heatmap(mat, col = col, top_annotation = ha, name = "density", cluster_rows = FALSE, cluster_columns = FALSE)
62 68
 	} else {
63 69
 		if(!is.data.frame(anno)) anno = data.frame(anno = anno)
64 70
 		ha = HeatmapAnnotation(df = anno)
... ...
@@ -1,42 +1,44 @@
1 1
 
2 2
 # == title
3
-# Visualize a data frame
3
+# Quickly visualize a data frame
4 4
 #
5 5
 # == param
6
-# -df a data frame
6
+# -df a data frame.
7 7
 # -overlap how to group numeric columns. If the overlapping rate between the ranges in the
8 8
 #          current column and previous numeric column is larger than this value, the two columns
9
-#          are thought under same measurement and should be grouped.
9
+#          are treated as under same measurement and should be grouped.
10 10
 # -nlevel If the number of levels of a character column is larger than this value, the column will
11
-#         be excluded.
11
+#         be excluded, because it doesn't make any sense to visualize a character vector or matrix
12
+#         that contains huge number of unique elements through a heatmap.
12 13
 # -show_row_names whether show row names after the last heatmap if there are row names.
13
-# -show_column_names whether show column names for all heatmaps
14
-# -group a list of index that defines the groupping
15
-# -group_names names for each group
16
-# -main_heatmap which group is the main heatmap
17
-# -km apply k-means clustering on rows for the main heatmap
18
-# -split set a splitting variable on rows for the main heatmap
19
-# -cluster_rows whether perform clustering on rows of the first heatmap
20
-# -cluster_columns whether perform clustering on columns for all heatmaps
14
+# -show_column_names whether show column names for all heatmaps.
15
+# -group a list of index that defines the groupping.
16
+# -group_names names for each group.
17
+# -main_heatmap which group is the main heatmap?
18
+# -km a value larger than 1 means applying k-means clustering on rows for the main heatmap.
19
+# -split one or multiple variables that split the rows.
20
+# -cluster_rows whether perform clustering on rows of the main heatmap.
21
+# -cluster_columns whether perform clustering on columns for all heatmaps.
21 22
 # -... pass to `draw,HeatmapList-method` or `make_layout,HeatmapList-method`
22 23
 #
23 24
 # == details
24
-# The data frame contains information from different aspects and different measurements are applied
25
-# on the same element for each row. The `plotDataFrame` function provides a simple and quick way to
25
+# The data frame contains heterogeneous information. The `plotDataFrame` function provides a simple and quick way to
26 26
 # visualize information that are stored in a data frame.
27 27
 #
28
-# There are not many advanced settings in this function. Users can customize the style of the heatmaps
29
-# by constructing a `HeatmapList` object.
28
+# There are only a few advanced settings in this function, so the heamtap generated by this functioin
29
+# may look ugly (in most of the time). However, users can customize the style of the heatmaps by manually
30
+# constructing a `HeatmapList` object.
30 31
 # 
31 32
 # == value
32
-# a `HeatmapList` object
33
+# a `HeatmapList` object.
33 34
 #
34 35
 # == author
35 36
 # Zuguang Gu <z.gu@dkfz.de>
36 37
 #
37
-plotDataFrame = function(df, overlap = 0.25, nlevel = 30, show_row_names = TRUE, show_column_names = TRUE,
38
-	group = NULL, group_names = names(group), main_heatmap = NULL, km = 1, split = NULL,
39
-	cluster_rows = TRUE, cluster_columns = TRUE, ...) {
38
+plotDataFrame = function(df, overlap = 0.25, nlevel = 30, show_row_names = TRUE, 
39
+	show_column_names = TRUE, group = NULL, group_names = names(group), 
40
+	main_heatmap = NULL, km = 1, split = NULL, cluster_rows = TRUE, 
41
+	cluster_columns = TRUE, ...) {
40 42
 
41 43
 	if(is.matrix(df)) {
42 44
 		ht_list = Heatmap(df, show_row_names = show_row_names, show_column_names = show_column_names)
... ...
@@ -262,16 +262,16 @@ grid.dendrogram = function(dend, facing = c("bottom", "top", "left", "right"),
262 262
 }
263 263
 
264 264
 # == title
265
-# Calculate distance from a matrix
265
+# Calculate pairwise distance from a matrix
266 266
 #
267 267
 # == param
268 268
 # -mat a matrix. The distance is calculated by rows.
269 269
 # -pairwise_fun a function which calculates distance between two vectors.
270
-# -... pass to `stats::dist`.
270
+# -... pass to `stats::as.dist`.
271 271
 #
272 272
 # == detail
273 273
 # You can construct any type of distance measurements by defining a pair-wise distance function.
274
-# The function is implemented by two nested ``for`` loops, thus the efficiency may not be so good.
274
+# The function is implemented by two nested ``for`` loops, so the efficiency may not be so good.
275 275
 #
276 276
 # == value
277 277
 # A `stats::dist` object.
... ...
@@ -15,6 +15,5 @@ It is only designed for \code{+} generic method so that above three classes can
15 15
 
16 16
 }
17 17
 \examples{
18
-
19 18
 # no example
20 19
 NULL}
... ...
@@ -27,6 +27,5 @@ Zuguang Gu <z.gu@dkfz.de>
27 27
 
28 28
 }
29 29
 \examples{
30
-
31 30
 # no example
32 31
 NULL}
... ...
@@ -21,7 +21,7 @@ The \code{\link{ColorMapping-class}} provides following methods:
21 21
 \itemize{
22 22
   \item \code{\link{ColorMapping}}: contructor methods.
23 23
   \item \code{\link{map_to_colors,ColorMapping-method}}: mapping values to colors.
24
-  \item \code{\link{color_mapping_legend,ColorMapping-method}}: draw legend or get the size of the legend.
24
+  \item \code{\link{color_mapping_legend,ColorMapping-method}}: draw legend or get legend as a \code{\link[grid]{grob}} object.
25 25
 }
26 26
 
27 27
 }
... ...
@@ -30,6 +30,5 @@ Zuguang Gu <z.gu@dkfz.de>
30 30
 
31 31
 }
32 32
 \examples{
33
-
34 33
 # for examples, please go to `ColorMapping` method page
35 34
 NULL}
... ...
@@ -14,7 +14,7 @@ ColorMapping(name, colors = NULL, levels = NULL,
14 14
     legend_title = name, color_bar = c("discrete", "continuous"))}
15 15
 \arguments{
16 16
 
17
-  \item{name}{name for this color mapping. It is used for drawing the title of the legend.}
17
+  \item{name}{name for this color mapping. The name is automatically generated if it is not specified.}
18 18
   \item{colors}{discrete colors.}
19 19
   \item{levels}{levels that correspond to \code{colors}. If \code{colors} is name indexed, \code{levels} can be ignored.}
20 20
   \item{col_fun}{color mapping function that maps continuous values to colors.}
... ...
@@ -22,7 +22,7 @@ ColorMapping(name, colors = NULL, levels = NULL,
22 22
   \item{enforce_breaks}{If it is set to \code{\link{TRUE}}, values of \code{breaks} will be the final break value in the legend.If it is \code{FALSE}, proper breaks values will be automatically generated.}
23 23
   \item{na_col}{colors for \code{NA} values.}
24 24
   \item{legend_title}{title of the legend, by default it is the name of the legend}
25
-  \item{color_bar}{if the color mapping is continuous, whether draw the legend discrete or continuous.}
25
+  \item{color_bar}{if the color mapping is continuous, whether draw the legend discrete or continuous. Possible values are "discrete" and "continuous". Current implementation of continuous color bar is not a nice one and will be improved in future.}
26 26
 }
27 27
 \details{
28 28
 \code{colors} and \code{levels} are used for discrete color mapping, \code{col_fun} and 
... ...
@@ -38,7 +38,6 @@ Zuguang Gu <z.gu@dkfz.de>
38 38
 
39 39
 }
40 40
 \examples{
41
-
42 41
 # discrete color mapping for characters
43 42
 cm = ColorMapping(name = "test",
44 43
     colors = c("blue", "white", "red"),
... ...
@@ -72,6 +72,5 @@ Zuguang Gu <z.gu@dkfz.de>
72 72
 
73 73
 }
74 74
 \examples{
75
-
76 75
 # for examples, please go to `Heatmap` method page
77 76
 NULL}
... ...
@@ -12,7 +12,8 @@ Constructor method for Heatmap class
12 12
 Heatmap(matrix, col, name, na_col = "grey", rect_gp = gpar(col = NA),
13 13
     cell_fun = function(j, i, x, y, width, height, fill) NULL,
14 14
     row_title = character(0), row_title_side = c("left", "right"),
15
-    row_title_gp = gpar(fontsize = 14), row_title_rot = switch(row_title_side[1], "left" = 90, "right" = 270),
15
+    row_title_gp = gpar(fontsize = 14),
16
+    row_title_rot = switch(row_title_side[1], "left" = 90, "right" = 270),
16 17
     column_title = character(0), column_title_side = c("top", "bottom"),
17 18
     column_title_gp = gpar(fontsize = 14), column_title_rot = 0,
18 19
     cluster_rows = TRUE, clustering_distance_rows = "euclidean",
... ...
@@ -36,7 +37,8 @@ Heatmap(matrix, col, name, na_col = "grey", rect_gp = gpar(col = NA),
36 37
     combined_name_fun = function(x) paste(x, collapse = "/"),
37 38
     width = NULL, show_heatmap_legend = TRUE,
38 39
     heatmap_legend_title = name,
39
-    heatmap_legend_color_bar = c("discrete", "continuous"))}
40
+    heatmap_legend_color_bar = c("discrete", "continuous"),
41
+    heatmap_legend_enforce_breaks = FALSE)}
40 42
 \arguments{
41 43
 
42 44
   \item{matrix}{a matrix. Either numeric or character. If it is a simple vector, it will beconverted to a one-column matrix.}
... ...
@@ -88,7 +90,8 @@ Heatmap(matrix, col, name, na_col = "grey", rect_gp = gpar(col = NA),
88 90
   \item{width}{the width of the single heatmap, should be a fixed \code{\link[grid]{unit}} object. It is used for the layout when the heatmapis appended to a list of heatmaps.}
89 91
   \item{show_heatmap_legend}{whether show heatmap legend?}
90 92
   \item{heatmap_legend_title}{title for the heatmap legend. By default it is the name of the heatmap}
91
-  \item{heatmap_legend_color_bar}{if the matrix is continuous, whether should the legend as continuous color bar as well? Accepts either "discrete" or "continuous".}
93
+  \item{heatmap_legend_color_bar}{if the matrix is continuous, whether should the legend as continuous color bar as well? Possible values are "discrete" and "continuous". Current implementation of continuous color bar is not a nice one and will be improved in future.}
94
+  \item{heatmap_legend_enforce_breaks}{For numeric matrix, if it is set to \code{\link{TRUE}} and \code{col} is specified by \code{\link[circlize]{colorRamp2}}break values specified in \code{\link[circlize]{colorRamp2}} will be the final break value in the legend.Or else, proper breaks values will be automatically generated.}
92 95
 }
93 96
 \details{
94 97
 The initialization function only applies parameter checking and fill values to each slot with proper ones.
... ...
@@ -115,7 +118,6 @@ Zuguang Gu <z.gu@dkfz.de>
115 118
 
116 119
 }
117 120
 \examples{
118
-
119 121
 mat = matrix(rnorm(80, 2), 8, 10)
120 122
 mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
121 123
 rownames(mat) = letters[1:12]
... ...
@@ -10,9 +10,9 @@ Class for heatmap annotations
10 10
 
11 11
 }
12 12
 \details{
13
-A complex heatmap contains a list of annotations which represent as different graphics
14
-placed on rows and columns. The \code{\link{HeatmapAnnotation-class}} is a category of single annotations which are
15
-by a list of \code{\link{SingleAnnotation-class}} objects with same number of rows or columns.
13
+A complex heatmap contains a list of annotations which are represented as different graphics
14
+placed on rows and columns. The \code{\link{HeatmapAnnotation-class}} contains a list of single annotations which are
15
+represented as a list of \code{\link{SingleAnnotation-class}} objects with same number of rows or columns.
16 16
 
17 17
 }
18 18
 \section{Methods}{
... ...
@@ -29,6 +29,5 @@ Zuguang Gu <z.gu@dkfz.de>
29 29
 
30 30
 }
31 31
 \examples{
32
-
33 32
 # for examples, please go to `HeatmapAnnotation` method page
34 33
 NULL}
... ...
@@ -19,7 +19,7 @@ HeatmapAnnotation(df, name, col, color_bar = rep("discrete", ncol(df)),
19 19
   \item{df}{a data frame. Each column will be treated as a simple annotation. The data frame must have column names.}
20 20
   \item{name}{name of the heatmap annotation, optional.}
21 21
   \item{col}{a list of colors which contains color mapping to columns in \code{df}. See \code{\link{SingleAnnotation}} for how to set colors.}
22
-  \item{color_bar}{if there are continuous values in \code{df}, show the legend as discrete or continuous}
22
+  \item{color_bar}{if there are continuous values in \code{df}, whether show the legend as discrete or continuous. Possible values are "discrete" and "continuous". It can be a vector for which each one corresponds to each column in \code{df}.}
23 23
   \item{show_legend}{whether show legend for each column in \code{df}.}
24 24
   \item{...}{functions which define complex annotations. Values should be named arguments.}
25 25
   \item{which}{are the annotations row annotations or column annotations?}
... ...
@@ -48,7 +48,6 @@ Zuguang Gu <z.gu@dkfz.de>
48 48
 
49 49
 }
50 50
 \examples{
51
-
52 51
 df = data.frame(type = c("a", "a", "a", "b", "b", "b"))
53 52
 ha = HeatmapAnnotation(df = df)
54 53
 
... ...
@@ -68,7 +68,6 @@ Zuguang Gu <z.gu@dkfz.de>
68 68
 
69 69
 }
70 70
 \examples{
71
-
72 71
 mat = matrix(rnorm(80, 2), 8, 10)
73 72
 mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
74 73
 rownames(mat) = letters[1:12]
... ...
@@ -27,9 +27,7 @@ Zuguang Gu <z.gu@dkfz.de>
27 27
 
28 28
 }
29 29
 \section{Detailes}{
30
-
31 30
 There is no public constructor method for the \code{\link{HeatmapList-class}}.}
32 31
 \examples{
33
-
34 32
 # no example
35 33
 NULL}
... ...
@@ -39,6 +39,5 @@ Zuguang Gu <z.gu@dkfz.de>
39 39
 
40 40
 }
41 41
 \examples{
42
-
43 42
 # for examples, please go to `SingleAnnotation` method page
44 43
 NULL}
... ...
@@ -13,14 +13,14 @@ SingleAnnotation(name, value, col, fun, which = c("column", "row"),
13 13
     show_legend = TRUE, gp = gpar(col = NA), color_bar = c("discrete", "continuous"))}
14 14
 \arguments{
15 15
 
16
-  \item{name}{name for this annotation.}
17
-  \item{value}{A vector of annotation.}
16
+  \item{name}{name for this annotation. If it is not specified, an internal name is assigned to it.}
17
+  \item{value}{A vector of discrete or continuous annotation.}
18 18
   \item{col}{colors corresponding to \code{value}. If the mapping is discrete mapping, the value of \code{col}should be a vector; If the mapping is continuous mapping, the value of \code{col} should be a color mapping function. }
19 19
   \item{fun}{a self-defined function to add annotation graphics. The argument of this function should only be a vector of index that corresponds to rows or columns.}
20 20
   \item{which}{is the annotation a row annotation or a column annotation?}
21 21
   \item{show_legend}{if it is a simple annotation, whether show legend when making the complete heatmap.}
22
-  \item{gp}{graphic parameters for simple annotations.}
23
-  \item{color_bar}{if the color mapping is continuous, whether draw the legend discrete or continuous. Onl works for simple annotation.}
22
+  \item{gp}{Since simple annotation is represented as a row of grids. This argument controls graphic parameters for the simple annotation.}
23
+  \item{color_bar}{if the color mapping is continuous, whether draw the legend discrete or continuous. Onl works for simple annotation.Pass to \code{\link{ColorMapping}}.}
24 24
 }
25 25
 \details{
26 26
 The most simple annotation is one row or one column grids in which different colors
... ...
@@ -49,7 +49,6 @@ Zuguang Gu <z.gu@dkfz.de>
49 49
 
50 50
 }
51 51
 \examples{
52
-
53 52
 # discrete character
54 53
 SingleAnnotation(name = "test", value = c("a", "a", "a", "b", "b", "b"))
55 54
 SingleAnnotation(name = "test", value = c("a", "a", "a", "b", "b", "b"), 
... ...
@@ -31,7 +31,6 @@ Zuguang Gu <z.gu@dkfz.de>
31 31
 
32 32
 }
33 33
 \examples{
34
-
35 34
 mat = matrix(rnorm(80, 2), 8, 10)
36 35
 mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
37 36
 rownames(mat) = letters[1:12]
... ...
@@ -28,7 +28,6 @@ Zuguang Gu <z.gu@dkfz.de>
28 28
 
29 29
 }
30 30
 \examples{
31
-
32 31
 mat = matrix(rnorm(80, 2), 8, 10)
33 32
 mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
34 33
 rownames(mat) = letters[1:12]
... ...
@@ -28,7 +28,6 @@ Zuguang Gu <z.gu@dkfz.de>
28 28
 
29 29
 }
30 30
 \examples{
31
-
32 31
 mat = matrix(rnorm(80, 2), 8, 10)
33 32
 mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
34 33
 rownames(mat) = letters[1:12]
... ...
@@ -28,7 +28,6 @@ Zuguang Gu <z.gu@dkfz.de>
28 28
 
29 29
 }
30 30
 \examples{
31
-
32 31
 mat = matrix(rnorm(80, 2), 8, 10)
33 32
 mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
34 33
 rownames(mat) = letters[1:12]
... ...
@@ -14,11 +14,11 @@ anno_barplot(x, which = c("column", "row"),
14 14
     axis_gp = gpar(fontsize = 8), ...)}
15 15
 \arguments{
16 16
 
17
-  \item{x}{a vector of values.}
17
+  \item{x}{a vector of numeric values.}
18 18
   \item{which}{is the annotation a column annotation or a row annotation?}
19 19
   \item{gp}{graphic parameters.}
20 20
   \item{axis}{whether add axis}
21
-  \item{axis_side}{value in "left", "right", "bottom" and "top"}
21
+  \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".}
22 22
   \item{axis_gp}{graphic parameters for axis}
23 23
   \item{...}{for future use.}
24 24
 }
... ...
@@ -31,7 +31,6 @@ Zuguang Gu <z.gu@dkfz.de>
31 31
 
32 32
 }
33 33
 \examples{
34
-
35 34
 f = anno_barplot(rnorm(10))
36 35
 grid.newpage(); f(1:10)
37 36
 
... ...
@@ -20,7 +20,7 @@ anno_boxplot(x, which = c("column", "row"), gp = gpar(fill = "#CCCCCC"),
20 20
   \item{pch}{point type}
21 21
   \item{size}{point size}
22 22
   \item{axis}{whether add axis}
23
-  \item{axis_side}{value in "left", "right", "bottom" and "top"}
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".}
24 24
   \item{axis_gp}{graphic parameters for axis}
25 25
 }
26 26
 \value{
... ...
@@ -32,7 +32,6 @@ Zuguang Gu <z.gu@dkfz.de>
32 32
 
33 33
 }
34 34
 \examples{
35
-
36 35
 mat = matrix(rnorm(32), nrow = 4)
37 36
 f = anno_boxplot(mat)
38 37
 grid.newpage(); f(1:8)
... ...
@@ -28,7 +28,6 @@ Zuguang Gu <z.gu@dkfz.de>
28 28
 
29 29
 }
30 30
 \examples{
31
-
32 31
 mat = matrix(rnorm(32), nrow = 4)
33 32
 f = anno_density(mat)
34 33
 grid.newpage(); f(1:8)
... ...
@@ -26,7 +26,6 @@ Zuguang Gu <z.gu@dkfz.de>
26 26
 
27 27
 }
28 28
 \examples{
29
-
30 29
 mat = matrix(rnorm(32), nrow = 4)
31 30
 f = anno_histogram(mat)
32 31
 grid.newpage(); f(1:8)
... ...
@@ -14,13 +14,13 @@ anno_points(x, which = c("column", "row"), gp = gpar(), pch = 16,
14 14
     axis_gp = gpar(fontsize = 8), ...)}
15 15
 \arguments{
16 16
 
17
-  \item{x}{a vector of values.}
17
+  \item{x}{a vector of numeric values.}
18 18
   \item{which}{is the annotation a column annotation or a row annotation?}
19 19
   \item{gp}{graphic parameters.}
20 20
   \item{pch}{point type.}
21 21
   \item{size}{point size.}
22
-  \item{axis}{whether add axis}
23
-  \item{axis_side}{value in "left", "right", "bottom" and "top"}
22
+  \item{axis}{whether add axis.}
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".}
24 24
   \item{axis_gp}{graphic parameters for axis}
25 25
   \item{...}{for future use.}
26 26
 }
... ...
@@ -33,6 +33,5 @@ Zuguang Gu <z.gu@dkfz.de>
33 33
 
34 34
 }
35 35
 \examples{
36
-
37 36
 f = anno_points(rnorm(10))
38 37
 grid.newpage(); f(1:10)}
... ...
@@ -18,7 +18,7 @@ anno_text(x, which = c("column", "row"), gp = gpar(), rot = 0,
18 18
   \item{gp}{graphic parameters.}
19 19
   \item{rot}{rotation of text}
20 20
   \item{just}{justification of text, pass to \code{\link[grid]{grid.text}}}
21
-  \item{offset}{offset relative to start position}
21
+  \item{offset}{if it is a row annotation, \code{offset} corresponds to the x-coordinates of text.and if it is a column annotation, \code{offset} corresponds to the y-coordinates of text.The value should be a \code{\link[grid]{unit}} object.}
22 22
 }
23 23
 \value{
24 24
 A graphic function which can be set in \code{\link{HeatmapAnnotation}} constructor method.
... ...
@@ -29,7 +29,6 @@ Zuguang Gu <z.gu@dkfz.de>
29 29
 
30 30
 }
31 31
 \examples{
32
-
33 32
 mat = matrix(rnorm(100), 10)
34 33
 colnames(mat) = letters[1:10]
35 34
 rownames(mat) = LETTERS[1:10]
... ...
@@ -33,6 +33,5 @@ Zuguang Gu <z.gu@dkfz.de>
33 33
 
34 34
 }
35 35
 \examples{
36
-
37 36
 # no example for this internal method
38 37
 NULL}
... ...
@@ -38,7 +38,6 @@ Zuguang Gu <z.gu@dkfz.de>
38 38
 
39 39
 }
40 40
 \examples{
41
-
42 41
 # discrete color mapping for characters
43 42
 cm = ColorMapping(name = "test",
44 43
     colors = c("blue", "white", "red"),
... ...
@@ -31,6 +31,5 @@ Zuguang Gu <z.gu@dkfz.de>
31 31
 
32 32
 }
33 33
 \examples{
34
-
35 34
 df = data.frame(type = c("a", "a", "a", "b", "b", "b"))
36 35
 ha = rowAnnotation(df = df)}
... ...
@@ -28,5 +28,4 @@ Zuguang Gu <z.gu@dkfz.de>
28 28
 
29 29
 }
30 30
 \examples{
31
-
32 31
 # no example for this internal method}
... ...
@@ -24,5 +24,4 @@ Zuguang Gu <z.gu@dkfz.de>
24 24
 
25 25
 }
26 26
 \examples{
27
-
28 27
 # no example for this internal method}
... ...
@@ -20,7 +20,6 @@ This function is only for internal use.
20 20
 
21 21
 }
22 22
 \section{Detials}{
23
-
24 23
 This function is only for internal use.}
25 24
 \value{
26 25
 A \code{\link[grid]{unit}} object.
... ...
@@ -31,5 +30,4 @@ Zuguang Gu <z.gu@dkfz.de>
31 30
 
32 31
 }
33 32
 \examples{
34
-
35 33
 # no example for this internal method}
... ...
@@ -28,5 +28,4 @@ Zuguang Gu <z.gu@dkfz.de>
28 28
 
29 29
 }
30 30
 \examples{
31
-
32 31
 # no example for this internal method}
... ...
@@ -11,19 +11,19 @@ Use colors to represent density distribution
11 11
 \usage{
12 12
 densityHeatmap(data, col = rev(brewer.pal(11, "Spectral")),
13 13
     anno = NULL, ylab = deparse(substitute(data)),
14
-    title = paste0("density heatmap of ", deparse(substitute(data))))}
14
+    title = paste0("Density heatmap of ", deparse(substitute(data))))}
15 15
 \arguments{
16 16
 
17
-  \item{data}{a matrix or a list. If it is a matrix, density will be calculated by columns}
18
-  \item{col}{a list of colors that density values are mapped to}
19
-  \item{anno}{annotation for matrix columns or list, a vector or a data frame. The order of elements or rows corresponding to the orders of elements of rows of \code{data}}
17
+  \item{data}{a matrix or a list. If it is a matrix, density will be calculated by columns.}
18
+  \item{col}{a list of colors that density values are scaled to.}
19
+  \item{anno}{annotation for matrix columns or list. The value should be a vector or a data frame. It can also be a \code{\link{HeatmapAnnotation-class}} object.}
20 20
   \item{ylab}{label on y-axis in the plot}
21 21
   \item{title}{title of the plot}
22 22
 }
23 23
 \details{
24 24
 To visualize distribution of columns in a matrix or in a list, sometimes we use boxplot or beanplot.
25 25
 Here we use colors to map to the density values and visualize distribution of values
26
-in each column (or each list element) through a heatmap. It is useful if you have huge number of columns in \code{data} to visualize.
26
+in each column (or each element in the list) through a heatmap. It is useful if you have huge number of columns in \code{data} to visualize.
27 27
 
28 28
 }
29 29
 \value{
... ...
@@ -36,6 +36,9 @@ densityHeatmap(matrix)
36 36
 densityHeatmap(matrix, anno = rep(c("A", "B"), each = 5))
37 37
 densityHeatmap(matrix, col = c("white", "red"), anno = rep(c("A", "B"), each = 5))
38 38
 
39
+ha = HeatmapAnnotation(points = anno_points(runif(10)))
40
+densityHeatmap(matrix, anno = ha)
41
+
39 42
 lt = list(rnorm(10), rnorm(10))
40 43
 densityHeatmap(lt)
41 44
 
... ...
@@ -1,11 +1,11 @@
1 1
 \name{dist2}
2 2
 \alias{dist2}
3 3
 \title{
4
-Calculate distance from a matrix
4
+Calculate pairwise distance from a matrix
5 5
 
6 6
 }
7 7
 \description{
8
-Calculate distance from a matrix
8
+Calculate pairwise distance from a matrix
9 9
 
10 10
 }
11 11
 \usage{
... ...
@@ -14,11 +14,11 @@ dist2(mat, pairwise_fun = function(x, y) sqrt(sum((x - y)^2)), ...)}
14 14
 
15 15
   \item{mat}{a matrix. The distance is calculated by rows.}
16 16
   \item{pairwise_fun}{a function which calculates distance between two vectors.}
17
-  \item{...}{pass to \code{\link[stats]{dist}}.}
17
+  \item{...}{pass to \code{\link[stats]{as.dist}}.}
18 18
 }
19 19
 \details{
20 20
 You can construct any type of distance measurements by defining a pair-wise distance function.
21
-The function is implemented by two nested \code{for} loops, thus the efficiency may not be so good.
21
+The function is implemented by two nested \code{for} loops, so the efficiency may not be so good.
22 22
 
23 23
 }
24 24
 \value{
... ...
@@ -30,7 +30,6 @@ Zuguang Gu <z.gu@dkfz.de>
30 30
 
31 31
 }
32 32
 \examples{
33
-
34 33
 mat = matrix(rnorm(40), nr = 4, ncol = 10)
35 34
 rownames(mat) = letters[1:4]
36 35
 colnames(mat) = letters[1:10]
... ...
@@ -31,7 +31,6 @@ Zuguang Gu <z.gu@dkfz.de>
31 31
 
32 32
 }
33 33
 \examples{
34
-
35 34
 mat = matrix(rnorm(80, 2), 8, 10)
36 35
 mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
37 36
 rownames(mat) = letters[1:12]
... ...
@@ -30,7 +30,6 @@ Zuguang Gu <z.gu@dkfz.de>
30 30
 
31 31
 }
32 32
 \examples{
33
-
34 33
 df = data.frame(type = c("a", "a", "a", "b", "b", "b"))
35 34
 ha = HeatmapAnnotation(df = df)
36 35
 grid.newpage(); draw(ha, 1:6)
... ...
@@ -9,7 +9,8 @@ Draw a list of heatmaps
9 9
 
10 10
 }
11 11
 \usage{
12
-\S4method{draw}{HeatmapList}(object, padding = unit(c(2, 2, 2, 2), "mm"), ..., newpage= TRUE)}
12
+\S4method{draw}{HeatmapList}(object, padding = unit(c(2, 2, 2, 2), "mm"), ...,
13
+    newpage= TRUE)}
13 14
 \arguments{
14 15
 
15 16
   \item{object}{a \code{\link{HeatmapList-class}} object}
... ...
@@ -33,7 +34,6 @@ Zuguang Gu <z.gu@dkfz.de>
33 34
 
34 35
 }
35 36
 \examples{
36
-
37 37
 mat = matrix(rnorm(80, 2), 8, 10)
38 38
 mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
39 39
 rownames(mat) = letters[1:12]
... ...
@@ -14,7 +14,7 @@ Draw the single annotation
14 14
 
15 15
   \item{object}{a \code{\link{SingleAnnotation-class}} object.}
16 16
   \item{index}{a vector of orders}
17
-  \item{k}{if row annotation is splitted, the value identifies which row slice.}
17
+  \item{k}{if row annotation is splitted, the value identifies which row slice. It is only used for the naems of the viewportwhich contains the annotation graphics.}
18 18
 }
19 19
 \details{
20 20
 A viewport is created.
... ...
@@ -31,7 +31,6 @@ Zuguang Gu <z.gu@dkfz.de>
31 31
 
32 32
 }
33 33
 \examples{
34
-
35 34
 anno = SingleAnnotation(name = "test", value = c("a", "a", "a", "b", "b", "b"))
36 35
 grid.newpage(); draw(anno, 1:5)
37 36
 grid.newpage(); draw(anno, c(1, 4, 3, 5, 2))
... ...
@@ -34,6 +34,5 @@ Zuguang Gu <z.gu@dkfz.de>
34 34
 
35 35
 }
36 36
 \examples{
37
-
38 37
 # no example for this internal method
39 38
 NULL}
... ...
@@ -32,6 +32,5 @@ Zuguang Gu <z.gu@dkfz.de>
32 32
 
33 33
 }
34 34
 \examples{
35
-
36 35
 # no example for this internal method
37 36
 NULL}
... ...
@@ -35,6 +35,5 @@ Zuguang Gu <z.gu@dkfz.de>
35 35
 
36 36
 }
37 37
 \examples{
38
-
39 38
 # no example for this internal method
40 39
 NULL}
... ...
@@ -42,6 +42,5 @@ Zuguang Gu <z.gu@dkfz.de>
42 42
 
43 43
 }
44 44
 \examples{
45
-
46 45
 # no example for this internal method
47 46
 NULL}
... ...
@@ -36,6 +36,5 @@ Zuguang Gu <z.gu@dkfz.de>
36 36
 
37 37
 }
38 38
 \examples{
39
-
40 39
 # no example for this internal method
41 40
 NULL}
... ...
@@ -32,6 +32,5 @@ Zuguang Gu <z.gu@dkfz.de>
32 32
 
33 33
 }
34 34
 \examples{
35
-
36 35
 # no example for this internal method
37 36
 NULL}
... ...
@@ -30,6 +30,5 @@ Zuguang Gu <z.gu@dkfz.de>
30 30
 
31 31
 }
32 32
 \examples{
33
-
34 33
 # no example for this internal method
35 34
 NULL}
... ...
@@ -33,6 +33,5 @@ Zuguang Gu <z.gu@dkfz.de>
33 33
 
34 34
 }
35 35
 \examples{
36
-
37 36
 # no example for this internal method
38 37
 NULL}
... ...
@@ -31,6 +31,5 @@ Zuguang Gu <z.gu@dkfz.de>
31 31
 
32 32
 }
33 33
 \examples{
34
-
35 34
 # no example for this internal method
36 35
 NULL}
... ...
@@ -30,6 +30,5 @@ Zuguang Gu <z.gu@dkfz.de>
30 30
 
31 31
 }
32 32
 \examples{
33
-
34 33
 # no example for this internal method
35 34
 NULL}
... ...
@@ -34,7 +34,6 @@ Zuguang Gu <z.gu@dkfz.de>
34 34
 
35 35
 }
36 36
 \examples{
37
-
38 37
 hc = hclust(dist(USArrests[1:5, ]))
39 38
 dend = as.dendrogram(hc)
40 39
 
... ...
@@ -30,6 +30,5 @@ Zuguang Gu <z.gu@dkfz.de>
30 30
 
31 31
 }
32 32
 \examples{
33
-
34 33
 # no example for this internal method
35 34
 NULL}
... ...
@@ -30,6 +30,5 @@ Zuguang Gu <z.gu@dkfz.de>
30 30
 
31 31
 }
32 32
 \examples{
33
-
34 33
 # no example for this internal method
35 34
 NULL}
... ...
@@ -33,6 +33,5 @@ Zuguang Gu <z.gu@dkfz.de>
33 33
 
34 34
 }
35 35
 \examples{
36
-
37 36
 # no example for this internal method
38 37
 NULL}
... ...
@@ -59,6 +59,5 @@ Zuguang Gu <z.gu@dkfz.de>
59 59
 
60 60
 }
61 61
 \examples{
62
-
63 62
 # no example for this internal method
64 63
 NULL}
... ...
@@ -32,6 +32,5 @@ Zuguang Gu <z.gu@dkfz.de>
32 32
 
33 33
 }
34 34
 \examples{
35
-
36 35
 # no example for this internal method
37 36
 NULL}
... ...
@@ -29,7 +29,6 @@ Zuguang Gu <z.gu@dkfz.de>
29 29
 
30 30
 }
31 31
 \examples{
32
-
33 32
 # discrete color mapping for characters
34 33
 cm = ColorMapping(name = "test",
35 34
     colors = c("blue", "white", "red"),
... ...
@@ -24,7 +24,3 @@ they can pass parameters directly to \code{\link{draw,HeatmapList-method}}.
24 24
 This function returns no value.
25 25
 
26 26
 }
27
-\examples{
28
-
29
-# no example 
30
-NULL}
... ...
@@ -1,44 +1,45 @@
1 1
 \name{plotDataFrame}
2 2
 \alias{plotDataFrame}
3 3
 \title{
4
-Visualize a data frame
4
+Quickly visualize a data frame
5 5
 
6 6
 }
7 7
 \description{
8
-Visualize a data frame
8
+Quickly visualize a data frame
9 9
 
10 10
 }
11 11
 \usage{
12
-plotDataFrame(df, overlap = 0.25, nlevel = 30, show_row_names = TRUE, show_column_names = TRUE,
13
-    group = NULL, group_names = names(group), main_heatmap = NULL, km = 1, split = NULL,
14
-    cluster_rows = TRUE, cluster_columns = TRUE, ...)}
12
+plotDataFrame(df, overlap = 0.25, nlevel = 30, show_row_names = TRUE,
13
+    show_column_names = TRUE, group = NULL, group_names = names(group),
14
+    main_heatmap = NULL, km = 1, split = NULL, cluster_rows = TRUE,
15
+    cluster_columns = TRUE, ...)}
15 16
 \arguments{
16 17
 
17
-  \item{df}{a data frame}
18
-  \item{overlap}{how to group numeric columns. If the overlapping rate between the ranges in thecurrent column and previous numeric column is larger than this value, the two columnsare thought under same measurement and should be grouped.}
19
-  \item{nlevel}{If the number of levels of a character column is larger than this value, the column willbe excluded.}
18
+  \item{df}{a data frame.}
19
+  \item{overlap}{how to group numeric columns. If the overlapping rate between the ranges in thecurrent column and previous numeric column is larger than this value, the two columnsare treated as under same measurement and should be grouped.}
20
+  \item{nlevel}{If the number of levels of a character column is larger than this value, the column willbe excluded, because it doesn't make any sense to visualize a character vector or matrixthat contains huge number of unique elements through a heatmap.}
20 21
   \item{show_row_names}{whether show row names after the last heatmap if there are row names.}
21
-  \item{show_column_names}{whether show column names for all heatmaps}
22
-  \item{group}{a list of index that defines the groupping}
23
-  \item{group_names}{names for each group}
24
-  \item{main_heatmap}{which group is the main heatmap}
25
-  \item{km}{apply k-means clustering on rows for the main heatmap}
26
-  \item{split}{set a splitting variable on rows for the main heatmap}
27
-  \item{cluster_rows}{whether perform clustering on rows of the first heatmap}
28
-  \item{cluster_columns}{whether perform clustering on columns for all heatmaps}
22
+  \item{show_column_names}{whether show column names for all heatmaps.}
23
+  \item{group}{a list of index that defines the groupping.}
24
+  \item{group_names}{names for each group.}
25
+  \item{main_heatmap}{which group is the main heatmap?}
26
+  \item{km}{a value larger than 1 means applying k-means clustering on rows for the main heatmap.}
27
+  \item{split}{one or multiple variables that split the rows.}
28
+  \item{cluster_rows}{whether perform clustering on rows of the main heatmap.}
29
+  \item{cluster_columns}{whether perform clustering on columns for all heatmaps.}
29 30
   \item{...}{pass to \code{\link{draw,HeatmapList-method}} or \code{\link{make_layout,HeatmapList-method}}}
30 31
 }
31 32
 \details{
32
-The data frame contains information from different aspects and different measurements are applied
33
-on the same element for each row. The \code{\link{plotDataFrame}} function provides a simple and quick way to
33
+The data frame contains heterogeneous information. The \code{\link{plotDataFrame}} function provides a simple and quick way to
34 34
 visualize information that are stored in a data frame.
35 35
 
36
-There are not many advanced settings in this function. Users can customize the style of the heatmaps
37
-by constructing a \code{\link{HeatmapList}} object.
36
+There are only a few advanced settings in this function, so the heamtap generated by this functioin
37
+may look ugly (in most of the time). However, users can customize the style of the heatmaps by manually
38
+constructing a \code{\link{HeatmapList}} object.
38 39
 
39 40
 }
40 41
 \value{
41
-a \code{\link{HeatmapList}} object
42
+a \code{\link{HeatmapList}} object.
42 43
 
43 44
 }
44 45
 \author{
... ...
@@ -46,7 +47,6 @@ Zuguang Gu <z.gu@dkfz.de>
46 47
 
47 48
 }
48 49
 \examples{
49
-
50 50
 df = data.frame(matrix(rnorm(40), nrow = 10, dimnames = list(letters[1:10], letters[1:4])),
51 51
                 large = runif(10)*100,
52 52
                 t1 = sample(letters[1:3], 10, replace = TRUE),
... ...
@@ -37,6 +37,5 @@ Zuguang Gu <z.gu@dkfz.de>
37 37
 
38 38
 }
39 39
 \examples{
40
-
41 40
 # no example for this internal method
42 41
 NULL}
... ...
@@ -24,7 +24,3 @@ they can pass parameters directly to \code{\link{draw,HeatmapList-method}}.
24 24
 This function returns no value.
25 25
 
26 26
 }
27
-\examples{
28
-
29
-# no example 
30
-NULL}
... ...
@@ -31,6 +31,5 @@ Zuguang Gu <z.gu@dkfz.de>
31 31
 
32 32
 }
33 33
 \examples{
34
-
35 34
 df = data.frame(type = c("a", "a", "a", "b", "b", "b"))
36 35
 ha = columnAnnotation(df = df)}
... ...
@@ -30,6 +30,5 @@ Zuguang Gu <z.gu@dkfz.de>
30 30
 
31 31
 }
32 32
 \examples{
33
-
34 33
 # no example for this internal method
35 34
 NULL}
... ...
@@ -28,7 +28,6 @@ Zuguang Gu <z.gu@dkfz.de>
28 28
 
29 29
 }
30 30
 \examples{
31
-
32 31
 mat = matrix(rnorm(80, 2), 8, 10)
33 32
 mat = rbind(mat, matrix(rnorm(40, -2), 4, 10))
34 33
 rownames(mat) = letters[1:12]
... ...
@@ -24,5 +24,4 @@ This function returns no value.
24 24
 
25 25
 }
26 26
 \author{
27
-
28 27
 Zuguang Gu <z.gu@dkfz.de>}
... ...
@@ -156,13 +156,19 @@ Heatmap(mat_with_na, na_col = "orange", clustering_distance_rows = dist_with_na,
156 156
 
157 157
 ### Titles
158 158
 
159
-The name of the heatmap is used as the title of the heatmap legend.
159
+The name of the heatmap is by default used as the title of the heatmap legend.
160 160
 The name also plays as a unique id if you plot more than one heatmaps together (introduced in later sections).
161 161
 
162 162
 ```{r with_matrix_name}
163 163
 Heatmap(mat, name = "foo")
164 164
 ```
165 165
 
166
+The title of the heatmap legend can be modified by `heatmap_legend_title`.
167
+
168
+```{r heatmap_legend_title}
169
+Heatmap(mat, heatmap_legend_title = "legend")
170
+```
171
+
166 172
 You can set heatmap titles either by the rows or by the columns. Note at a same time
167 173
 you can only put e.g. column title either on the top or at the bottom of the heatmap.
168 174
 The graphic parameters can be set by `row_title_gp` and `column_title_gp` respectively.
... ...
@@ -665,28 +671,15 @@ draw(ht1 + ht2, legend_grid_width = unit(6, "mm"),
665 671
     legend_title_gp = gpar(fontsize = 14, fontface = "bold"))
666 672
 ```
667 673
 
668
-If you don't like the default breaks in the heatmap legend, you can construct a new legend by `ColorMapping` class
669
-and pass to `heatmap_legend_list`. Please make sure the color mapping for the matrix and that for the legend
670
-should be the same one.
674
+For continuous matrix, the break values on the legend is calculated automatically. If your color mapping
675
+function is generated by `circlize::colorRamp2()`, and `heatmap_legend_enforce_breaks` is set to `TRUE`, 
676
+the break values specfied in `circlize::colorRamp2()` will be used as the break values in the heatmap legend.
671 677
 
672 678
 ```{r self_define_heatmap_legend, fig.width = 10}
673 679
 col_fun = colorRamp2(c(-3, 0, 3), c("green", "white", "red"))
674
-ht2 = Heatmap(mat, name = "ht2", col = col_fun, column_title = "Heatmap 2", show_heatmap_legend = FALSE)
675
-cm = ColorMapping(col_fun = col_fun, name = "heatmap2", enforce_breaks = TRUE)
676
-draw(ht1 + ht2, heatmap_legend_list = list(color_mapping_legend(cm, plot = FALSE)))
677
-```
678
-
679
-Default legend style for continuous color mapping is created by first calculating break values for continuous values and 
680
-then drawing these discrete break values as discrete legend grids. You can switch to continuous legends both for heatmap legend
681
-and annotation legends.
682
-
683
-```{r self_define_heatmap_continuous_legend, fig.width = 10}
684
-df = data.frame(type = runif(10))
685
-ha = HeatmapAnnotation(df = df, color_bar = "continuous")
686
-ht1 = Heatmap(mat, name = "ht1", column_title = "Heatmap 1", top_annotation = ha)
687 680
 ht2 = Heatmap(mat, name = "ht2", col = col_fun, column_title = "Heatmap 2", 
688
-    heatmap_legend_color_bar = "continuous")
689
-draw(ht1 + ht2)
681
+    heatmap_legend_enforce_breaks = TRUE)
682
+ht1 + ht2
690 683
 ```
691 684
 
692 685
 **ComplexHeatmap** only generates legends for heatmaps and simple annotations. Self-defined legends
... ...
@@ -1110,7 +1103,9 @@ Here the package has a `densityHeatmap()` function, the usage is quite straightf
1110 1103
 
1111 1104
 ```{r, density}
1112 1105
 matrix = matrix(rnorm(100), 10); colnames(matrix) = letters[1:10]
1113
-densityHeatmap(matrix, anno = rep(c("A", "B"), each = 5))
1106
+ha = HeatmapAnnotation(df = data.frame(anno = rep(c("A", "B"), each = 5)),
1107
+    points = anno_points(runif(10)))
1108
+densityHeatmap(matrix, anno = ha)
1114 1109
 ```
1115 1110
 
1116 1111
 The implementation of the function is a little tricky. Empty row annotations are first created in front of