... | ... |
@@ -1,8 +1,8 @@ |
1 | 1 |
Package: ComplexHeatmap |
2 | 2 |
Type: Package |
3 | 3 |
Title: Make Complex Heatmaps |
4 |
-Version: 1.99.0 |
|
5 |
-Date: 2018-10-23 |
|
4 |
+Version: 1.99.1 |
|
5 |
+Date: 2018-11-23 |
|
6 | 6 |
Author: Zuguang Gu |
7 | 7 |
Maintainer: Zuguang Gu <z.gu@dkfz.de> |
8 | 8 |
Depends: R (>= 3.1.2), methods, grid, graphics, stats, grDevices |
... | ... |
@@ -1,31 +1,31 @@ |
1 |
-setGeneric('map_to_colors', function(object, ...) standardGeneric('map_to_colors')) |
|
2 |
-setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height')) |
|
3 | 1 |
setGeneric('draw_heatmap_body', function(object, ...) standardGeneric('draw_heatmap_body')) |
4 |
-setGeneric('component_height', function(object, ...) standardGeneric('component_height')) |
|
5 |
-setGeneric('re_size', function(object, ...) standardGeneric('re_size')) |
|
6 |
-setGeneric('make_layout', function(object, ...) standardGeneric('make_layout')) |
|
7 |
-setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size')) |
|
8 |
-setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list')) |
|
9 |
-setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend')) |
|
10 |
-setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster')) |
|
11 |
-setGeneric('column_dend', function(object, ...) standardGeneric('column_dend')) |
|
12 |
-setGeneric('row_order', function(object, ...) standardGeneric('row_order')) |
|
13 |
-setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list')) |
|
2 |
+setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height')) |
|
14 | 3 |
setGeneric('row_dend', function(object, ...) standardGeneric('row_dend')) |
4 |
+setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend')) |
|
5 |
+setGeneric('draw_title', function(object, ...) standardGeneric('draw_title')) |
|
6 |
+setGeneric('copy_all', function(object, ...) standardGeneric('copy_all')) |
|
15 | 7 |
setGeneric('add_heatmap', function(object, ...) standardGeneric('add_heatmap')) |
16 |
-setGeneric('set_component_width', function(object, ...) standardGeneric('set_component_width')) |
|
8 |
+setGeneric('row_order', function(object, ...) standardGeneric('row_order')) |
|
9 |
+setGeneric('component_height', function(object, ...) standardGeneric('component_height')) |
|
10 |
+setGeneric('make_layout', function(object, ...) standardGeneric('make_layout')) |
|
17 | 11 |
setGeneric('column_order', function(object, ...) standardGeneric('column_order')) |
18 |
-setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend')) |
|
19 |
-setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend')) |
|
12 |
+setGeneric('set_component_width', function(object, ...) standardGeneric('set_component_width')) |
|
13 |
+setGeneric('component_width', function(object, ...) standardGeneric('component_width')) |
|
14 |
+setGeneric('get_color_mapping_list', function(object, ...) standardGeneric('get_color_mapping_list')) |
|
15 |
+setGeneric('map_to_colors', function(object, ...) standardGeneric('map_to_colors')) |
|
16 |
+setGeneric('adjust_heatmap_list', function(object, ...) standardGeneric('adjust_heatmap_list')) |
|
17 |
+setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster')) |
|
18 |
+setGeneric('draw', function(object, ...) standardGeneric('draw')) |
|
20 | 19 |
setGeneric('annotation_legend_size', function(object, ...) standardGeneric('annotation_legend_size')) |
20 |
+setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list')) |
|
21 | 21 |
setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation')) |
22 | 22 |
setGeneric('prepare', function(object, ...) standardGeneric('prepare')) |
23 | 23 |
setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames')) |
24 |
-setGeneric('draw', function(object, ...) standardGeneric('draw')) |
|
25 |
-setGeneric('draw_title', function(object, ...) standardGeneric('draw_title')) |
|
26 |
-setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster')) |
|
27 |
-setGeneric('component_width', function(object, ...) standardGeneric('component_width')) |
|
28 |
-setGeneric('get_color_mapping_list', function(object, ...) standardGeneric('get_color_mapping_list')) |
|
24 |
+setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list')) |
|
25 |
+setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster')) |
|
26 |
+setGeneric('re_size', function(object, ...) standardGeneric('re_size')) |
|
27 |
+setGeneric('column_dend', function(object, ...) standardGeneric('column_dend')) |
|
28 |
+setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend')) |
|
29 |
+setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size')) |
|
30 |
+setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend')) |
|
29 | 31 |
setGeneric('draw_dend', function(object, ...) standardGeneric('draw_dend')) |
30 |
-setGeneric('adjust_heatmap_list', function(object, ...) standardGeneric('adjust_heatmap_list')) |
|
31 |
-setGeneric('copy_all', function(object, ...) standardGeneric('copy_all')) |
... | ... |
@@ -104,6 +104,7 @@ Heatmap = setClass("Heatmap", |
104 | 104 |
# -cluster_rows If the value is a logical, it controls whether to make cluster on rows. The value can also |
105 | 105 |
# be a `stats::hclust` or a `stats::dendrogram` which already contains clustering. |
106 | 106 |
# Check https://jokergoo.github.io/ComplexHeatmap-reference/book/a-single-heatmap.html#clustering . |
107 |
+# -cluster_row_slices If rows are split into slices, whether perform clustering on the slice means? |
|
107 | 108 |
# -clustering_distance_rows It can be a pre-defined character which is in |
108 | 109 |
# ("euclidean", "maximum", "manhattan", "canberra", "binary", |
109 | 110 |
# "minkowski", "pearson", "spearman", "kendall"). It can also be a function. |
... | ... |
@@ -120,6 +121,7 @@ Heatmap = setClass("Heatmap", |
120 | 121 |
# -row_dend_reorder Apply reordering on row dendrograms. The value can be a logical value or a vector which contains weight |
121 | 122 |
# which is used to reorder rows. The reordering is applied by `stats::reorder.dendrogram`. |
122 | 123 |
# -cluster_columns Whether make cluster on columns? Same settings as ``cluster_rows``. |
124 |
+# -cluster_column_slices If columns are split into slices, whether perform clustering on the slice means? |
|
123 | 125 |
# -clustering_distance_columns Same setting as ``clustering_distance_rows``. |
124 | 126 |
# -clustering_method_columns Method to perform hierarchical clustering, pass to `stats::hclust`. |
125 | 127 |
# -column_dend_side Should the column dendrogram be put on the top or bottom of the heatmap? |
... | ... |
@@ -210,6 +212,7 @@ Heatmap = function(matrix, col, name, |
210 | 212 |
column_title_rot = 0, |
211 | 213 |
|
212 | 214 |
cluster_rows = TRUE, |
215 |
+ cluster_row_slices = TRUE, |
|
213 | 216 |
clustering_distance_rows = "euclidean", |
214 | 217 |
clustering_method_rows = "complete", |
215 | 218 |
row_dend_side = c("left", "right"), |
... | ... |
@@ -218,6 +221,7 @@ Heatmap = function(matrix, col, name, |
218 | 221 |
row_dend_reorder = is.logical(cluster_rows) || is.function(cluster_rows), |
219 | 222 |
row_dend_gp = gpar(), |
220 | 223 |
cluster_columns = TRUE, |
224 |
+ cluster_column_slices = TRUE, |
|
221 | 225 |
clustering_distance_columns = "euclidean", |
222 | 226 |
clustering_method_columns = "complete", |
223 | 227 |
column_dend_side = c("top", "bottom"), |
... | ... |
@@ -600,6 +604,7 @@ Heatmap = function(matrix, col, name, |
600 | 604 |
} |
601 | 605 |
.Object@row_order = row_order |
602 | 606 |
} |
607 |
+ .Object@row_dend_param$cluster_slices = cluster_row_slices |
|
603 | 608 |
|
604 | 609 |
if(missing(cluster_columns) && !missing(column_order)) { |
605 | 610 |
cluster_columns = FALSE |
... | ... |
@@ -644,6 +649,7 @@ Heatmap = function(matrix, col, name, |
644 | 649 |
} |
645 | 650 |
.Object@column_order = column_order |
646 | 651 |
} |
652 |
+ .Object@column_dend_param$cluster_slices = cluster_column_slices |
|
647 | 653 |
|
648 | 654 |
######### annotations ############# |
649 | 655 |
.Object@top_annotation = top_annotation # a `HeatmapAnnotation` object |
... | ... |
@@ -893,6 +899,7 @@ make_cluster = function(object, which = c("row", "column")) { |
893 | 899 |
split = getElement(object@matrix_param, paste0(which, "_split")) |
894 | 900 |
reorder = slot(object, paste0(which, "_dend_param"))$reorder |
895 | 901 |
cluster = slot(object, paste0(which, "_dend_param"))$cluster |
902 |
+ cluster_slices = slot(object, paste0(which, "_dend_param"))$cluster_slices |
|
896 | 903 |
gap = getElement(object@matrix_param, paste0(which, "_gap")) |
897 | 904 |
|
898 | 905 |
dend_param = slot(object, paste0(which, "_dend_param")) |
... | ... |
@@ -1252,7 +1259,7 @@ make_cluster = function(object, which = c("row", "column")) { |
1252 | 1259 |
if(verbose) qqcat("reorder dendrograms in each @{which} slice\n") |
1253 | 1260 |
} |
1254 | 1261 |
|
1255 |
- if(length(order_list) > 1) { |
|
1262 |
+ if(length(order_list) > 1 && cluster_slices) { |
|
1256 | 1263 |
if(which == "row") { |
1257 | 1264 |
slice_mean = sapply(order_list, function(ind) colMeans(mat[ind, , drop = FALSE])) |
1258 | 1265 |
} else { |
... | ... |
@@ -1263,6 +1270,10 @@ make_cluster = function(object, which = c("row", "column")) { |
1263 | 1270 |
} |
1264 | 1271 |
dend_slice = as.dendrogram(hclust(dist(t(slice_mean)))) |
1265 | 1272 |
if(verbose) qqcat("perform clustering on mean of @{which} slices\n") |
1273 |
+ |
|
1274 |
+ slice_od = order.dendrogram(dend_slice) |
|
1275 |
+ order_list = order_list[slice_od] |
|
1276 |
+ dend_list = dend_list[slice_od] |
|
1266 | 1277 |
} |
1267 | 1278 |
} |
1268 | 1279 |
|
... | ... |
@@ -155,6 +155,7 @@ setMethod(f = "make_layout", |
155 | 155 |
row_dend_side = object@row_dend_param$side |
156 | 156 |
row_dend_width = object@row_dend_param$width |
157 | 157 |
row_dend_slice = object@row_dend_slice |
158 |
+ cluster_dend_slices = object@row_dend_param$cluster_slices |
|
158 | 159 |
if(show_row_dend) { |
159 | 160 |
if(row_dend_side == "left") { |
160 | 161 |
object@layout$layout_size$row_dend_left_width = row_dend_width |
... | ... |
@@ -180,7 +181,7 @@ setMethod(f = "make_layout", |
180 | 181 |
max_height = row_dend_max_height) |
181 | 182 |
} |
182 | 183 |
|
183 |
- if(nr_slice > 1) { |
|
184 |
+ if(nr_slice > 1 && cluster_dend_slices) { |
|
184 | 185 |
if(row_dend_side == "left") { |
185 | 186 |
pushViewport(viewport(xscale = c(0, row_dend_max_height))) |
186 | 187 |
} else { |
... | ... |
@@ -229,6 +230,7 @@ setMethod(f = "make_layout", |
229 | 230 |
column_dend_side = object@column_dend_param$side |
230 | 231 |
column_dend_height = object@column_dend_param$height |
231 | 232 |
column_dend_slice = object@column_dend_slice |
233 |
+ cluster_column_slices = object@column_dend_param$cluster_slices |
|
232 | 234 |
if(show_column_dend) { |
233 | 235 |
if(column_dend_side == "top") { |
234 | 236 |
object@layout$layout_size$column_dend_top_height = column_dend_height |
... | ... |
@@ -253,7 +255,7 @@ setMethod(f = "make_layout", |
253 | 255 |
max_height = column_dend_max_height) |
254 | 256 |
} |
255 | 257 |
|
256 |
- if(nc_slice > 1) { |
|
258 |
+ if(nc_slice > 1 && cluster_column_slices) { |
|
257 | 259 |
if(column_dend_side == "top") { |
258 | 260 |
pushViewport(viewport(yscale = c(0, column_dend_max_height))) |
259 | 261 |
} else { |
... | ... |
@@ -25,6 +25,7 @@ Heatmap(matrix, col, name, |
25 | 25 |
column_title_rot = 0, |
26 | 26 |
|
27 | 27 |
cluster_rows = TRUE, |
28 |
+ cluster_row_slices = TRUE, |
|
28 | 29 |
clustering_distance_rows = "euclidean", |
29 | 30 |
clustering_method_rows = "complete", |
30 | 31 |
row_dend_side = c("left", "right"), |
... | ... |
@@ -33,6 +34,7 @@ Heatmap(matrix, col, name, |
33 | 34 |
row_dend_reorder = is.logical(cluster_rows) || is.function(cluster_rows), |
34 | 35 |
row_dend_gp = gpar(), |
35 | 36 |
cluster_columns = TRUE, |
37 |
+ cluster_column_slices = TRUE, |
|
36 | 38 |
clustering_distance_columns = "euclidean", |
37 | 39 |
clustering_method_columns = "complete", |
38 | 40 |
column_dend_side = c("top", "bottom"), |
... | ... |
@@ -85,6 +87,7 @@ Heatmap(matrix, col, name, |
85 | 87 |
raster_device = c("png", "jpeg", "tiff", "CairoPNG", "CairoJPEG", "CairoTIFF"), |
86 | 88 |
raster_quality = 2, |
87 | 89 |
raster_device_param = list(), |
90 |
+ raster_resize = FALSE, |
|
88 | 91 |
|
89 | 92 |
post_fun = NULL) |
90 | 93 |
} |
... | ... |
@@ -108,6 +111,7 @@ Heatmap(matrix, col, name, |
108 | 111 |
\item{column_title_gp}{Graphic parameters for column title.} |
109 | 112 |
\item{column_title_rot}{Rotation of column titles. Only 0, 90, 270 are allowed to set.} |
110 | 113 |
\item{cluster_rows}{If the value is a logical, it controls whether to make cluster on rows. The value can also be a \code{\link[stats]{hclust}} or a \code{\link[stats]{dendrogram}} which already contains clustering. Check \url{https://jokergoo.github.io/ComplexHeatmap-reference/book/a-single-heatmap.html#clustering} .} |
114 |
+ \item{cluster_row_slices}{If rows are split into slices, whether perform clustering on the slice means?} |
|
111 | 115 |
\item{clustering_distance_rows}{It can be a pre-defined character which is in ("euclidean", "maximum", "manhattan", "canberra", "binary", "minkowski", "pearson", "spearman", "kendall"). It can also be a function. If the function has one argument, the input argument should be a matrix and the returned value should be a \code{\link[stats]{dist}} object. If the function has two arguments, the input arguments are two vectors and the function calculates distance between these two vectors.} |
112 | 116 |
\item{clustering_method_rows}{Method to perform hierarchical clustering, pass to \code{\link[stats]{hclust}}.} |
113 | 117 |
\item{row_dend_side}{Should the row dendrogram be put on the left or right of the heatmap?} |
... | ... |
@@ -116,6 +120,7 @@ Heatmap(matrix, col, name, |
116 | 120 |
\item{row_dend_gp}{Graphic parameters for the dendrogram segments. If users already provide a \code{\link[stats]{dendrogram}} object with edges rendered, this argument will be ignored.} |
117 | 121 |
\item{row_dend_reorder}{Apply reordering on row dendrograms. The value can be a logical value or a vector which contains weight which is used to reorder rows. The reordering is applied by \code{\link[stats]{reorder.dendrogram}}.} |
118 | 122 |
\item{cluster_columns}{Whether make cluster on columns? Same settings as \code{cluster_rows}.} |
123 |
+ \item{cluster_column_slices}{If columns are split into slices, whether perform clustering on the slice means?} |
|
119 | 124 |
\item{clustering_distance_columns}{Same setting as \code{clustering_distance_rows}.} |
120 | 125 |
\item{clustering_method_columns}{Method to perform hierarchical clustering, pass to \code{\link[stats]{hclust}}.} |
121 | 126 |
\item{column_dend_side}{Should the column dendrogram be put on the top or bottom of the heatmap?} |
... | ... |
@@ -161,6 +166,7 @@ Heatmap(matrix, col, name, |
161 | 166 |
\item{raster_device}{Graphic device which is used to generate the raster image.} |
162 | 167 |
\item{raster_quality}{A value set to larger than 1 will improve the quality of the raster image.} |
163 | 168 |
\item{raster_device_param}{A list of further parameters for the selected graphic device. For raster image support, please check \url{https://jokergoo.github.io/ComplexHeatmap-reference/book/a-single-heatmap.html#heatmap-as-raster-image} .} |
169 |
+ \item{raster_resize}{Whether resize the matrix to let the dimension of the matrix the same as the dimension of the raster image?} |
|
164 | 170 |
\item{post_fun}{A function which will be executed after the heatmap list is drawn.} |
165 | 171 |
|
166 | 172 |
} |
... | ... |
@@ -10,8 +10,8 @@ Method dispatch page for \code{component_height}. |
10 | 10 |
\code{component_height} can be dispatched on following classes: |
11 | 11 |
|
12 | 12 |
\itemize{ |
13 |
-\item \code{\link{component_height,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
|
14 | 13 |
\item \code{\link{component_height,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
14 |
+\item \code{\link{component_height,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
|
15 | 15 |
} |
16 | 16 |
} |
17 | 17 |
\examples{ |
... | ... |
@@ -10,8 +10,8 @@ Method dispatch page for \code{component_width}. |
10 | 10 |
\code{component_width} can be dispatched on following classes: |
11 | 11 |
|
12 | 12 |
\itemize{ |
13 |
-\item \code{\link{component_width,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
|
14 | 13 |
\item \code{\link{component_width,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
14 |
+\item \code{\link{component_width,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
|
15 | 15 |
} |
16 | 16 |
} |
17 | 17 |
\examples{ |
... | ... |
@@ -10,12 +10,12 @@ Method dispatch page for \code{draw}. |
10 | 10 |
\code{draw} can be dispatched on following classes: |
11 | 11 |
|
12 | 12 |
\itemize{ |
13 |
-\item \code{\link{draw,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method |
|
14 |
-\item \code{\link{draw,Legends-method}}, \code{\link{Legends-class}} class method |
|
15 |
-\item \code{\link{draw,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method |
|
16 | 13 |
\item \code{\link{draw,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method |
17 |
-\item \code{\link{draw,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
|
18 | 14 |
\item \code{\link{draw,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
15 |
+\item \code{\link{draw,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
|
16 |
+\item \code{\link{draw,Legends-method}}, \code{\link{Legends-class}} class method |
|
17 |
+\item \code{\link{draw,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method |
|
18 |
+\item \code{\link{draw,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method |
|
19 | 19 |
} |
20 | 20 |
} |
21 | 21 |
\examples{ |
... | ... |
@@ -10,8 +10,8 @@ Method dispatch page for \code{make_layout}. |
10 | 10 |
\code{make_layout} can be dispatched on following classes: |
11 | 11 |
|
12 | 12 |
\itemize{ |
13 |
-\item \code{\link{make_layout,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
|
14 | 13 |
\item \code{\link{make_layout,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
14 |
+\item \code{\link{make_layout,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
|
15 | 15 |
} |
16 | 16 |
} |
17 | 17 |
\examples{ |
... | ... |
@@ -10,8 +10,8 @@ Method dispatch page for \code{row_order}. |
10 | 10 |
\code{row_order} can be dispatched on following classes: |
11 | 11 |
|
12 | 12 |
\itemize{ |
13 |
-\item \code{\link{row_order,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
|
14 | 13 |
\item \code{\link{row_order,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
14 |
+\item \code{\link{row_order,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
|
15 | 15 |
} |
16 | 16 |
} |
17 | 17 |
\examples{ |
... | ... |
@@ -10,12 +10,12 @@ Method dispatch page for \code{show}. |
10 | 10 |
\code{show} can be dispatched on following classes: |
11 | 11 |
|
12 | 12 |
\itemize{ |
13 |
-\item \code{\link{show,ColorMapping-method}}, \code{\link{ColorMapping-class}} class method |
|
14 |
-\item \code{\link{show,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method |
|
15 |
-\item \code{\link{show,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method |
|
13 |
+\item \code{\link{show,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
|
16 | 14 |
\item \code{\link{show,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method |
17 | 15 |
\item \code{\link{show,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
18 |
-\item \code{\link{show,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
|
16 |
+\item \code{\link{show,ColorMapping-method}}, \code{\link{ColorMapping-class}} class method |
|
17 |
+\item \code{\link{show,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method |
|
18 |
+\item \code{\link{show,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method |
|
19 | 19 |
} |
20 | 20 |
} |
21 | 21 |
\examples{ |