%\VignetteIndexEntry{Most probably asked questions}

Most Probably Asked Questions

**Author**: Zuguang Gu ( z.gu@dkfz.de )

**Date**: `r Sys.Date()`

**Package version**: `r installed.packages()["ComplexHeatmap", "Version"]`


<style type="text/css">
h1, h2, h3, h4, h5 {
    line-height: 120%;

```{r, message = FALSE, echo = FALSE}

### There is no plot comming out after running Heatmap() function.

In this case, you need to use `draw()` function explicitly. See https://jokergoo.github.io/ComplexHeatmap-reference/book/a-single-heatmap.html#plot-the-heatmap and https://jokergoo.github.io/ComplexHeatmap-reference/book/a-list-of-heatmaps.html#plot-the-heamtap-list.

### Retrieve orders and dendrograms.

For retrieving orders and dendrograms from a single heatmap. See https://jokergoo.github.io/ComplexHeatmap-reference/book/a-single-heatmap.html#get-orders-and-dendrograms-from-heatmap.

For retrieving orders and dendrograms from a list of heatmaps. See https://jokergoo.github.io/ComplexHeatmap-reference/book/a-list-of-heatmaps.html#get-orders-and-dendrograms-from-a-list-of-heatmaps.

### How should I control the height or width of the heatmap annotations?

For complex annotations generated by `anno_*()` functions, width or height should be set inside 
the `anno_*()` function, such as `anno_points(..., height = ...)`. The size of simple annotations
is controlled by `anno_simple_size`. The `width`/`height` and `annotation_width`/`annotation_height`
are used to adjust the size for multiple annotations which are put in one `HeatmapAnnotation` object.
See https://jokergoo.github.io/ComplexHeatmap-reference/book/heatmap-annotations.html#multiple-annotations

### How should I control the axes of the annotations?

In the annotation functions `anno_*()`, the argument `axis_param` can be used to set the axes. The value
should be a list and the default settings for axis can be get by:

```{r, eval = FALSE}

### How to control the style of legends?

The style of legends can be controlled by `heatmap_legend_param` in `Heatmap()`, or
`annotation_legend_param` in `HeatmapAnnotation()`. The parameters for controlling legends are those
arguments in `Legend()` function. See

### Some text are cut by the plotting region.

The layout of the **ComplexHeatmap** is not perfect that it is still possible some of the text are
drawn out of the plotting region. In this case, you can set the `padding` argument in `draw()` function
to increase the blank areas around the final plot. See https://jokergoo.github.io/ComplexHeatmap-reference/book/a-list-of-heatmaps.html#manually-increase-space-around-the-plot.

### Can the heatmaps be added vertically?

Yes, use `%v%` instead of `+`. See https://jokergoo.github.io/ComplexHeatmap-reference/book/a-list-of-heatmaps.html#vertical-concatenation.

### Does Heatmap title supports mathematical expression?

Yes, all the text-related elements (e.g. titles, row names, legend titles, legend labels, ...) allow
methematical expression.

### I have many heatmaps and I want to put them into different panels for a big figure for my paper.

You can set `newpage = FALSE` in `draw()` function and use `grid.layout()` to manage the layout of
your panels. 

```{r, eval = FALSE}
pushViewport(viewport(layout = grid.layout(...)))
pushViewport(viewport(layout.pos.row = ..., layout.pos.col = ...))
draw(ht, newpage = FALSE) # or draw(ht_list, newpage = FALSE)

But I more suggest to use `grid.grabExpr()` to directly capture the output of the
heatmap and later draw the whole plot as a single graphic element by `grid.draw()`.

```{r, eval = FALSE}
ht_grob = grid.grabExpr(draw(ht, ...))

pushViewport(viewport(layout = grid.layout(...)))
pushViewport(viewport(layout.pos.row = ..., layout.pos.col = ...))

### I have a matrix with too many rows and I want to simplify the row dendrogram.

You can first group your rows into several groups and make a group-level dendrogram on it. See following example:

m = matrix(rnorm(1000*10), nr = 1000)
hc = hclust(dist(m))
group = cutree(hc, k = 6)
Heatmap(m, cluster_rows = cluster_within_group(t(m), group), 
	row_split = 6, border = TRUE) # it would be better if also set row_split

### I have a matrix with huge nunmber of rows or columns, what is the efficient way to visualize it?

Heatmap is used to visualize the global patterns of your matrix while not
every single row or column. I suggest to random sample rows or columns
into a reasonable small number, and the final heatmap should be the same as if
you still insist to use the full matrix.

### How to add axes for dendrograms?

You need to use `decorate_row_dend()` or `decorate_column_dend()` to manually add the axes. See following examples:

m = matrix(rnorm(100), 10)

ht = Heatmap(m, name = "foo", 
	row_dend_width = unit(4, "cm"),
	column_dend_height = unit(4, "cm")
draw(ht, padding = unit(c(15, 2, 2, 2), "mm"))
decorate_column_dend("foo", {
decorate_row_dend("foo", {
	vp = current.viewport()
	xscale = vp$xscale
	grid.xaxis(at = xscale[2] - 0:5, label = 0:5)

Note for the left row dendrogram, the x-axis is from right to left, you need to self-define `at`
and `label` in `grid.xaxis()` function.

You can also check `annotation_axis_grob()` function (later use `grid.draw()` to draw the axes) to draw a nicer axis.