... | ... |
@@ -9,6 +9,9 @@ CHANGES in VERSION 2.1.0 |
9 | 9 |
* `densityHeatmap()`: `col` can be set as a function |
10 | 10 |
* add `cluster_rows`/`cluster_columns` in `oncoPrint()` |
11 | 11 |
* legend labels support symbols |
12 |
+* `Heatmap()`: add `jitter` argument to add tiny random shift to original matrix. |
|
13 |
+ It is mainly to solve the problem of "Error: node stack overflow" |
|
14 |
+ when there are too many identical rows/columns for plotting the dendrograms. |
|
12 | 15 |
|
13 | 16 |
======================== |
14 | 17 |
|
... | ... |
@@ -93,6 +93,10 @@ Heatmap = setClass("Heatmap", |
93 | 93 |
# row index in ``matrix``, coordinate of the cell, |
94 | 94 |
# the width and height of the cell and the filled color. ``x``, ``y``, ``width`` and ``height`` are all `grid::unit` objects. |
95 | 95 |
# -layer_fun Similar as ``cell_fun``, but is vectorized. Check https://jokergoo.github.io/ComplexHeatmap-reference/book/a-single-heatmap.html#customize-the-heatmap-body . |
96 |
+# -jitter Random shifts added to the matrix. The value can be logical or a single numeric value. It it is ``TRUE``, random |
|
97 |
+# values from uniform distribution between 0 and 1e-10 are generated. If it is a numeric value, |
|
98 |
+# the range for the uniform distribution is (0, ``jitter``). It is mainly to solve the problem of "Error: node stack overflow" |
|
99 |
+# when there are too many identical rows/columns for plotting the dendrograms. |
|
96 | 100 |
# -row_title Title on the row. |
97 | 101 |
# -row_title_side Will the title be put on the left or right of the heatmap? |
98 | 102 |
# -row_title_gp Graphic parameters for row title. |
... | ... |
@@ -206,6 +210,7 @@ Heatmap = function(matrix, col, name, |
206 | 210 |
border = NA, |
207 | 211 |
cell_fun = NULL, |
208 | 212 |
layer_fun = NULL, |
213 |
+ jitter = FALSE, |
|
209 | 214 |
|
210 | 215 |
row_title = character(0), |
211 | 216 |
row_title_side = c("left", "right"), |
... | ... |
@@ -437,6 +442,7 @@ Heatmap = function(matrix, col, name, |
437 | 442 |
.Object@matrix_param$column_km = column_km |
438 | 443 |
.Object@matrix_param$column_km_repeats = column_km_repeats |
439 | 444 |
.Object@matrix_param$column_gap = column_gap |
445 |
+ .Object@matrix_param$jitter = jitter |
|
440 | 446 |
|
441 | 447 |
### check row_split and column_split ### |
442 | 448 |
if(!is.null(row_split)) { |
... | ... |
@@ -943,6 +949,17 @@ make_cluster = function(object, which = c("row", "column")) { |
943 | 949 |
} |
944 | 950 |
|
945 | 951 |
mat = object@matrix |
952 |
+ jitter = object@matrix_param$jitter |
|
953 |
+ if(is.numeric(mat)) { |
|
954 |
+ if(is.logical(jitter)) { |
|
955 |
+ if(jitter) { |
|
956 |
+ mat = mat + runif(length(mat), min = 0, max = 1e-10) |
|
957 |
+ } |
|
958 |
+ } else { |
|
959 |
+ mat = mat + runif(length(mat), min = 0, max = jitter + 0) |
|
960 |
+ } |
|
961 |
+ } |
|
962 |
+ |
|
946 | 963 |
distance = slot(object, paste0(which, "_dend_param"))$distance |
947 | 964 |
method = slot(object, paste0(which, "_dend_param"))$method |
948 | 965 |
order = slot(object, paste0(which, "_order")) # pre-defined row order |
... | ... |
@@ -14,6 +14,7 @@ Heatmap(matrix, col, name, |
14 | 14 |
border = NA, |
15 | 15 |
cell_fun = NULL, |
16 | 16 |
layer_fun = NULL, |
17 |
+ jitter = FALSE, |
|
17 | 18 |
|
18 | 19 |
row_title = character(0), |
19 | 20 |
row_title_side = c("left", "right"), |
... | ... |
@@ -106,6 +107,7 @@ Heatmap(matrix, col, name, |
106 | 107 |
\item{border}{Whether draw border. The value can be logical or a string of color.} |
107 | 108 |
\item{cell_fun}{Self-defined function to add graphics on each cell. Seven parameters will be passed into this function: \code{j}, \code{i}, \code{x}, \code{y}, \code{width}, \code{height}, \code{fill} which are column index, row index in \code{matrix}, coordinate of the cell, the width and height of the cell and the filled color. \code{x}, \code{y}, \code{width} and \code{height} are all \code{\link[grid]{unit}} objects.} |
108 | 109 |
\item{layer_fun}{Similar as \code{cell_fun}, but is vectorized. Check \url{https://jokergoo.github.io/ComplexHeatmap-reference/book/a-single-heatmap.html#customize-the-heatmap-body} .} |
110 |
+ \item{jitter}{Random shifts added to the matrix. The value can be logical or a single numeric value. It it is \code{TRUE}, random values from uniform distribution between 0 and 1e-10 are generated. If it is a numeric value, the range for the uniform distribution is (0, \code{jitter}). It is mainly to solve the problem of "Error: node stack overflow" when there are too many identical rows/columns for plotting the dendrograms.} |
|
109 | 111 |
\item{row_title}{Title on the row.} |
110 | 112 |
\item{row_title_side}{Will the title be put on the left or right of the heatmap?} |
111 | 113 |
\item{row_title_gp}{Graphic parameters for row title.} |
... | ... |
@@ -204,4 +206,5 @@ Zuguang Gu <z.gu@dkfz.de> |
204 | 206 |
\examples{ |
205 | 207 |
# There is no example |
206 | 208 |
NULL |
209 |
+ |
|
207 | 210 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{adjust_heatmap_list-HeatmapList-method} |
2 | 2 |
\alias{adjust_heatmap_list,HeatmapList-method} |
3 |
+\alias{adjust_heatmap_list} |
|
3 | 4 |
\title{ |
4 | 5 |
Adjust Heatmap List |
5 | 6 |
} |
... | ... |
@@ -23,8 +24,8 @@ This function is only for internal use. |
23 | 24 |
\author{ |
24 | 25 |
Zuguang Gu <z.gu@dkfz.de> |
25 | 26 |
} |
26 |
-\alias{adjust_heatmap_list} |
|
27 | 27 |
\examples{ |
28 | 28 |
# There is no example |
29 | 29 |
NULL |
30 |
+ |
|
30 | 31 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{annotation_legend_size-HeatmapList-method} |
2 | 2 |
\alias{annotation_legend_size,HeatmapList-method} |
3 |
+\alias{annotation_legend_size} |
|
3 | 4 |
\title{ |
4 | 5 |
Size of the Annotation Legends |
5 | 6 |
} |
... | ... |
@@ -27,8 +28,8 @@ A \code{\link[grid]{unit}} object. |
27 | 28 |
\author{ |
28 | 29 |
Zuguang Gu <z.gu@dkfz.de> |
29 | 30 |
} |
30 |
-\alias{annotation_legend_size} |
|
31 | 31 |
\examples{ |
32 | 32 |
# There is no example |
33 | 33 |
NULL |
34 |
+ |
|
34 | 35 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{color_mapping_legend-ColorMapping-method} |
2 | 2 |
\alias{color_mapping_legend,ColorMapping-method} |
3 |
+\alias{color_mapping_legend} |
|
3 | 4 |
\title{ |
4 | 5 |
Draw Legend Based on Color Mapping |
5 | 6 |
} |
... | ... |
@@ -65,8 +66,8 @@ A \code{\link{Legends-class}} object. |
65 | 66 |
\author{ |
66 | 67 |
Zuguang Gu <z.gu@dkfz.de> |
67 | 68 |
} |
68 |
-\alias{color_mapping_legend} |
|
69 | 69 |
\examples{ |
70 | 70 |
# There is no example |
71 | 71 |
NULL |
72 |
+ |
|
72 | 73 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{draw_annotation-Heatmap-method} |
2 | 2 |
\alias{draw_annotation,Heatmap-method} |
3 |
+\alias{draw_annotation} |
|
3 | 4 |
\title{ |
4 | 5 |
Draw Heatmap Annotations on the Heatmap |
5 | 6 |
} |
... | ... |
@@ -30,8 +31,8 @@ This function returns no value. |
30 | 31 |
\author{ |
31 | 32 |
Zuguang Gu <z.gu@dkfz.de> |
32 | 33 |
} |
33 |
-\alias{draw_annotation} |
|
34 | 34 |
\examples{ |
35 | 35 |
# There is no example |
36 | 36 |
NULL |
37 |
+ |
|
37 | 38 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{draw_annotation_legend-HeatmapList-method} |
2 | 2 |
\alias{draw_annotation_legend,HeatmapList-method} |
3 |
+\alias{draw_annotation_legend} |
|
3 | 4 |
\title{ |
4 | 5 |
Draw legends for All Annotations |
5 | 6 |
} |
... | ... |
@@ -31,8 +32,8 @@ This function returns no value. |
31 | 32 |
\author{ |
32 | 33 |
Zuguang Gu <z.gu@dkfz.de> |
33 | 34 |
} |
34 |
-\alias{draw_annotation_legend} |
|
35 | 35 |
\examples{ |
36 | 36 |
# There is no example |
37 | 37 |
NULL |
38 |
+ |
|
38 | 39 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{draw_dend-Heatmap-method} |
2 | 2 |
\alias{draw_dend,Heatmap-method} |
3 |
+\alias{draw_dend} |
|
3 | 4 |
\title{ |
4 | 5 |
Draw Heatmap Dendrograms |
5 | 6 |
} |
... | ... |
@@ -33,8 +34,8 @@ This function returns no value. |
33 | 34 |
\author{ |
34 | 35 |
Zuguang Gu <z.gu@dkfz.de> |
35 | 36 |
} |
36 |
-\alias{draw_dend} |
|
37 | 37 |
\examples{ |
38 | 38 |
# There is no example |
39 | 39 |
NULL |
40 |
+ |
|
40 | 41 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{draw_dimnames-Heatmap-method} |
2 | 2 |
\alias{draw_dimnames,Heatmap-method} |
3 |
+\alias{draw_dimnames} |
|
3 | 4 |
\title{ |
4 | 5 |
Draw row names or column names |
5 | 6 |
} |
... | ... |
@@ -29,8 +30,8 @@ This function returns no value. |
29 | 30 |
\author{ |
30 | 31 |
Zuguang Gu <z.gu@dkfz.de> |
31 | 32 |
} |
32 |
-\alias{draw_dimnames} |
|
33 | 33 |
\examples{ |
34 | 34 |
# There is no example |
35 | 35 |
NULL |
36 |
+ |
|
36 | 37 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{draw_heatmap_body-Heatmap-method} |
2 | 2 |
\alias{draw_heatmap_body,Heatmap-method} |
3 |
+\alias{draw_heatmap_body} |
|
3 | 4 |
\title{ |
4 | 5 |
Draw Heatmap Body |
5 | 6 |
} |
... | ... |
@@ -28,8 +29,8 @@ This function returns no value. |
28 | 29 |
\author{ |
29 | 30 |
Zuguang Gu <z.gu@dkfz.de> |
30 | 31 |
} |
31 |
-\alias{draw_heatmap_body} |
|
32 | 32 |
\examples{ |
33 | 33 |
# There is no example |
34 | 34 |
NULL |
35 |
+ |
|
35 | 36 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{draw_heatmap_legend-HeatmapList-method} |
2 | 2 |
\alias{draw_heatmap_legend,HeatmapList-method} |
3 |
+\alias{draw_heatmap_legend} |
|
3 | 4 |
\title{ |
4 | 5 |
Draw legends for All Heatmaps |
5 | 6 |
} |
... | ... |
@@ -32,8 +33,8 @@ This function returns no value. |
32 | 33 |
\author{ |
33 | 34 |
Zuguang Gu <z.gu@dkfz.de> |
34 | 35 |
} |
35 |
-\alias{draw_heatmap_legend} |
|
36 | 36 |
\examples{ |
37 | 37 |
# There is no example |
38 | 38 |
NULL |
39 |
+ |
|
39 | 40 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{draw_heatmap_list-HeatmapList-method} |
2 | 2 |
\alias{draw_heatmap_list,HeatmapList-method} |
3 |
+\alias{draw_heatmap_list} |
|
3 | 4 |
\title{ |
4 | 5 |
Draw the List of Heatmaps |
5 | 6 |
} |
... | ... |
@@ -25,8 +26,8 @@ This function returns no value. |
25 | 26 |
\author{ |
26 | 27 |
Zuguang Gu <z.gu@dkfz.de> |
27 | 28 |
} |
28 |
-\alias{draw_heatmap_list} |
|
29 | 29 |
\examples{ |
30 | 30 |
# There is no example |
31 | 31 |
NULL |
32 |
+ |
|
32 | 33 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{get_color_mapping_list-HeatmapAnnotation-method} |
2 | 2 |
\alias{get_color_mapping_list,HeatmapAnnotation-method} |
3 |
+\alias{get_color_mapping_list} |
|
3 | 4 |
\title{ |
4 | 5 |
Get a List of ColorMapping objects |
5 | 6 |
} |
... | ... |
@@ -25,8 +26,8 @@ A list of \code{\link{ColorMapping-class}} objects or an empty list. |
25 | 26 |
\author{ |
26 | 27 |
Zuguang Gu <z.gu@dkfz.de> |
27 | 28 |
} |
28 |
-\alias{get_color_mapping_list} |
|
29 | 29 |
\examples{ |
30 | 30 |
# There is no example |
31 | 31 |
NULL |
32 |
+ |
|
32 | 33 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{get_legend_param_list-HeatmapAnnotation-method} |
2 | 2 |
\alias{get_legend_param_list,HeatmapAnnotation-method} |
3 |
+\alias{get_legend_param_list} |
|
3 | 4 |
\title{ |
4 | 5 |
Get a List of Annotation Legend Parameters |
5 | 6 |
} |
... | ... |
@@ -25,8 +26,8 @@ A list. |
25 | 26 |
\author{ |
26 | 27 |
Zuguang Gu <z.gu@dkfz.de> |
27 | 28 |
} |
28 |
-\alias{get_legend_param_list} |
|
29 | 29 |
\examples{ |
30 | 30 |
# There is no example |
31 | 31 |
NULL |
32 |
+ |
|
32 | 33 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{heatmap_legend_size-HeatmapList-method} |
2 | 2 |
\alias{heatmap_legend_size,HeatmapList-method} |
3 |
+\alias{heatmap_legend_size} |
|
3 | 4 |
\title{ |
4 | 5 |
Size of the Heatmap Legends |
5 | 6 |
} |
... | ... |
@@ -27,8 +28,8 @@ A \code{\link[grid]{unit}} object. |
27 | 28 |
\author{ |
28 | 29 |
Zuguang Gu <z.gu@dkfz.de> |
29 | 30 |
} |
30 |
-\alias{heatmap_legend_size} |
|
31 | 31 |
\examples{ |
32 | 32 |
# There is no example |
33 | 33 |
NULL |
34 |
+ |
|
34 | 35 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{make_column_cluster-Heatmap-method} |
2 | 2 |
\alias{make_column_cluster,Heatmap-method} |
3 |
+\alias{make_column_cluster} |
|
3 | 4 |
\title{ |
4 | 5 |
Make Cluster on Columns |
5 | 6 |
} |
... | ... |
@@ -28,8 +29,8 @@ A \code{\link{Heatmap-class}} object. |
28 | 29 |
\author{ |
29 | 30 |
Zuguang Gu <z.gu@dkfz.de> |
30 | 31 |
} |
31 |
-\alias{make_column_cluster} |
|
32 | 32 |
\examples{ |
33 | 33 |
# There is no example |
34 | 34 |
NULL |
35 |
+ |
|
35 | 36 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{make_row_cluster-Heatmap-method} |
2 | 2 |
\alias{make_row_cluster,Heatmap-method} |
3 |
+\alias{make_row_cluster} |
|
3 | 4 |
\title{ |
4 | 5 |
Make Cluster on Rows |
5 | 6 |
} |
... | ... |
@@ -27,8 +28,8 @@ A \code{\link{Heatmap-class}} object. |
27 | 28 |
\author{ |
28 | 29 |
Zuguang Gu <z.gu@dkfz.de> |
29 | 30 |
} |
30 |
-\alias{make_row_cluster} |
|
31 | 31 |
\examples{ |
32 | 32 |
# There is no example |
33 | 33 |
NULL |
34 |
+ |
|
34 | 35 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{map_to_colors-ColorMapping-method} |
2 | 2 |
\alias{map_to_colors,ColorMapping-method} |
3 |
+\alias{map_to_colors} |
|
3 | 4 |
\title{ |
4 | 5 |
Map Values to Colors |
5 | 6 |
} |
... | ... |
@@ -34,4 +35,3 @@ col_fun = colorRamp2(c(0, 1), c("white", "red")) |
34 | 35 |
cm = ColorMapping(col_fun = col_fun) |
35 | 36 |
map_to_colors(cm, runif(10)) |
36 | 37 |
} |
37 |
-\alias{map_to_colors} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{prepare-Heatmap-method} |
2 | 2 |
\alias{prepare,Heatmap-method} |
3 |
+\alias{prepare} |
|
3 | 4 |
\title{ |
4 | 5 |
Prepare the Heatmap |
5 | 6 |
} |
... | ... |
@@ -33,8 +34,8 @@ The \code{\link{Heatmap-class}} object. |
33 | 34 |
\author{ |
34 | 35 |
Zuguang Gu <z.gu@dkfz.de> |
35 | 36 |
} |
36 |
-\alias{prepare} |
|
37 | 37 |
\examples{ |
38 | 38 |
# There is no example |
39 | 39 |
NULL |
40 |
+ |
|
40 | 41 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{re_size-HeatmapAnnotation-method} |
2 | 2 |
\alias{re_size,HeatmapAnnotation-method} |
3 |
+\alias{re_size} |
|
3 | 4 |
\title{ |
4 | 5 |
Resize the Width or Height of Heatmap Annotations |
5 | 6 |
} |
... | ... |
@@ -41,8 +42,8 @@ The basic rules are (take \code{height} and \code{annotation_height} for example |
41 | 42 |
and \code{simple_anno_size} is disabled. |
42 | 43 |
6. If \code{simple_anno_size_adjust} is \code{FALSE}, the size of the simple annotations will not change. |
43 | 44 |
} |
44 |
-\alias{re_size} |
|
45 | 45 |
\examples{ |
46 | 46 |
# There is no example |
47 | 47 |
NULL |
48 |
+ |
|
48 | 49 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{set_component_height-Heatmap-method} |
2 | 2 |
\alias{set_component_height,Heatmap-method} |
3 |
+\alias{set_component_height} |
|
3 | 4 |
\title{ |
4 | 5 |
Set Height of Heatmap Component |
5 | 6 |
} |
... | ... |
@@ -29,8 +30,8 @@ The \code{\link{Heatmap-class}} object. |
29 | 30 |
\author{ |
30 | 31 |
Zuguang Gu <z.gu@dkfz.de> |
31 | 32 |
} |
32 |
-\alias{set_component_height} |
|
33 | 33 |
\examples{ |
34 | 34 |
# There is no example |
35 | 35 |
NULL |
36 |
+ |
|
36 | 37 |
} |
... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
\name{set_component_width-Heatmap-method} |
2 | 2 |
\alias{set_component_width,Heatmap-method} |
3 |
+\alias{set_component_width} |
|
3 | 4 |
\title{ |
4 | 5 |
Set Width of Heatmap Component |
5 | 6 |
} |
... | ... |
@@ -28,8 +29,8 @@ The \code{\link{Heatmap-class}} object. |
28 | 29 |
\author{ |
29 | 30 |
Zuguang Gu <z.gu@dkfz.de> |
30 | 31 |
} |
31 |
-\alias{set_component_width} |
|
32 | 32 |
\examples{ |
33 | 33 |
# There is no example |
34 | 34 |
NULL |
35 |
+ |
|
35 | 36 |
} |