Browse code

revised documentations

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

z.gu authored on 19/03/2016 17:59:18
Showing 22 changed files

... ...
@@ -2,7 +2,7 @@ Package: ComplexHeatmap
2 2
 Type: Package
3 3
 Title: Making Complex Heatmaps
4 4
 Version: 1.9.3
5
-Date: 2016-1-7
5
+Date: 2016-3-6
6 6
 Author: Zuguang Gu
7 7
 Maintainer: Zuguang Gu <z.gu@dkfz.de>
8 8
 Depends: R (>= 3.1.2), grid, graphics, stats, grDevices
... ...
@@ -18,6 +18,6 @@ Description: Complex heatmaps are efficient to visualize associations
18 18
 biocViews: Software, Visualization, Sequencing
19 19
 URL: https://github.com/jokergoo/ComplexHeatmap
20 20
 License: GPL (>= 2)
21
-Packaged: 2016-1-7 00:00:00 UTC; Administrator
21
+Packaged: 2016-3-6 00:00:00 UTC; Administrator
22 22
 Repository: Bioconductor
23
-Date/Publication: 2016-1-7 00:00:00
23
+Date/Publication: 2016-3-6 00:00:00
... ...
@@ -1,21 +1,21 @@
1
-CHANEGS in VERSION 1.9.3
1
+CHANGES in VERSION 1.9.3
2 2
 
3 3
 * graphic parameters are correctly recycled in row annotations
4 4
 * if there is only one row after splitting, there will be no dendrogram
5 5
 * add `range` option in `densityHeatmap()`
6 6
 * when `gap` is set for the main heatmap, other heatmps also adjust their `gap` values to it
7 7
 * fixed a bug that when rownames/colnames are not complete, dendrograms are corrupted
8
-* `alter_fun` now support adding graphics grid by grid
8
+* `alter_fun` now supports adding graphics grid by grid
9 9
 
10 10
 ==============================
11 11
 
12
-CHANEGS in VERSION 1.9.2
12
+CHANGES in VERSION 1.9.2
13 13
 
14 14
 * imporved example of `anno_link()`
15 15
 
16 16
 ==============================
17 17
 
18
-CHANEGS in VERSION 1.9.1
18
+CHANGES in VERSION 1.9.1
19 19
 
20 20
 * width of the heatmap body are calculated correctly if it is set as a fixed unit
21 21
 * there is no dendrogram is nrows in a row-slice is 1
... ...
@@ -56,6 +56,10 @@
56 56
 # - `Heatmap`: constructor method.
57 57
 # - `draw,Heatmap-method`: draw a single heatmap.
58 58
 # - `add_heatmap,Heatmap-method` append heatmaps and row annotations to a list of heatmaps.
59
+# - `row_order,HeatmapList-method`: get order of rows
60
+# - `column_order,HeatmapList-method`: get order of columns
61
+# - `row_dend,HeatmapList-method`: get row dendrograms
62
+# - `column_dend,HeatmapList-method`: get column dendrograms
59 63
 #
60 64
 # == author
61 65
 # Zuguang Gu <z.gu@dkfz.de>
... ...
@@ -44,7 +44,7 @@ HeatmapAnnotation = setClass("HeatmapAnnotation",
44 44
 # -na_col color for ``NA`` values in simple annotations.
45 45
 # -annotation_legend_param a list which contains parameters for annotation legends
46 46
 # -show_legend whether show legend for each column in ``df``.
47
-# -... functions which define complex annotations. Values should be named arguments.
47
+# -... functions which define complex annotations or vectors of simple annotation. Values should be named arguments.
48 48
 # -which are the annotations row annotations or column annotations?
49 49
 # -annotation_height height of each annotation if annotations are column annotations.
50 50
 # -annotation_width width of each annotation if annotations are row annotations.
... ...
@@ -44,7 +44,11 @@
44 44
 # The `HeatmapList-class` provides following methods:
45 45
 #
46 46
 # - `draw,HeatmapList-method`: draw the list of heatmaps and row annotations.
47
-# - `add_heatmap,HeatmapList-method` add heatmaps to the list of heatmaps.
47
+# - `add_heatmap,HeatmapList-method`: add heatmaps to the list of heatmaps.
48
+# - `row_order,HeatmapList-method`: get order of rows
49
+# - `column_order,HeatmapList-method`: get order of columns
50
+# - `row_dend,HeatmapList-method`: get row dendrograms
51
+# - `column_dend,HeatmapList-method`: get column dendrograms
48 52
 #
49 53
 # == author
50 54
 # Zuguang Gu <z.gu@dkfz.de>
... ...
@@ -12,7 +12,7 @@
12 12
 # goes to the viewport by `grid::seekViewport` and applies code
13 13
 # to that viewport.
14 14
 #
15
-# Since you know the number of rows and columns for that row slice, it is
15
+# If you know the number of rows and columns for that row slice, it is
16 16
 # simple to calculate the position of every small grid in the row slice.
17 17
 # E.g., the position for the grid in i^th row and j^th column is:
18 18
 #
... ...
@@ -73,7 +73,7 @@ decorate_heatmap_body = function(heatmap, code, slice = 1) {
73 73
 # goes to the viewport by `grid::seekViewport` and applies code
74 74
 # to that viewport.
75 75
 #
76
-# Since you know the number of leaves in the dendrogram, it is
76
+# If you know the number of leaves in the dendrogram, it is
77 77
 # simple to calculate the position of every leave in the dendrogram.
78 78
 # E.g., for the column dendrogram, the i^th leave is located at:
79 79
 #
... ...
@@ -179,7 +179,7 @@ decorate_row_dend = function(...) {
179 179
 # goes to the viewport by `grid::seekViewport` and applies code
180 180
 # to that viewport.
181 181
 #
182
-# Since you know the dimensions of the matrix, it is
182
+# If you know the dimensions of the matrix, it is
183 183
 # simple to calculate the position of every row name or column name in the heatmap.
184 184
 # E.g., for the column column, the i^th name is located at:
185 185
 #
... ...
@@ -4,14 +4,14 @@
4 4
 #
5 5
 # == param
6 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.
7
+# -col a list of colors that density values are mapped to.
8 8
 # -color_space the color space in which colors are interpolated. Pass to `circlize::colorRamp2`.
9
-# -anno annotation for the matrix columns or the list. The value should be a vector or a data frame. 
10
-#       It can also be a `HeatmapAnnotation-class` object.
9
+# -anno annotation for the matrix columns or the list. The value should be a vector or a data frame 
10
+#       and colors for annotations are randomly assigned. If you want to customize the annotation colors,
11
+#       use a `HeatmapAnnotation-class` object directly.
11 12
 # -ylab label on y-axis in the plot
12 13
 # -title title of the plot
13
-# -range ranges on the y-axis. The lower bound is the maximul value between ``range[[1]]`` and minimal value
14
-#        in the data and the upper bound is the minimal value between ``range[[2]]`` and maximul value in the data.
14
+# -range ranges on the y-axis. By default the range is between 1th quantile and 99th quantile of the data.
15 15
 # -... pass to `draw,HeatmapList-method`
16 16
 #
17 17
 # == details
... ...
@@ -32,7 +32,8 @@
32 32
 # densityHeatmap(matrix, anno = rep(c("A", "B"), each = 5))
33 33
 # densityHeatmap(matrix, col = c("white", "red"), anno = rep(c("A", "B"), each = 5))
34 34
 #
35
-# ha = HeatmapAnnotation(points = anno_points(runif(10)))
35
+# ha = HeatmapAnnotation(points = anno_points(runif(10)),
36
+#     anno = rep(c("A", "B"), each = 5), col = list(anno = c("A" = "red", "B" = "blue")))
36 37
 # densityHeatmap(matrix, anno = ha)
37 38
 #
38 39
 # lt = list(rnorm(10), rnorm(10))
... ...
@@ -60,8 +61,8 @@ densityHeatmap = function(data,
60 61
 	n = length(density_list)
61 62
 	nm = names(density_list)
62 63
 
63
-	max_x = max(unlist(lapply(density_list, function(x) x$x)))
64
-	min_x = min(unlist(lapply(density_list, function(x) x$x)))
64
+	max_x = quantile(unlist(lapply(density_list, function(x) x$x)), 0.99)
65
+	min_x = quantile(unlist(lapply(density_list, function(x) x$x)), 0.01)
65 66
 
66 67
 	max_x = min(max_x, range[2])
67 68
 	min_x = max(min_x, range[1])
... ...
@@ -258,7 +258,7 @@ oncoPrint = function(mat, get_type = function(x) x,
258 258
 	dimnames(pheudo) = dimnames(arr)[1:2]
259 259
 	
260 260
 	if(length(list(...))) {
261
-		if(names(list(...)) %in% c("rect_gp", "cluster_rows", "cluster_columns", "cell_fun")) {
261
+		if(any(names(list(...)) %in% c("rect_gp", "cluster_rows", "cluster_columns", "cell_fun"))) {
262 262
 			stop("'rect_gp', 'cluster_rows', 'cluster_columns', 'cell_fun' are not allowed to use in `oncoPrint()`.")
263 263
 		}
264 264
 	}
... ...
@@ -9,7 +9,7 @@
9 9
 # Users can use mouse to click two positions on the heatmap, the function
10 10
 # will return the row index and column index for the selected region in the selected matrix.
11 11
 #
12
-# Of cource this function only works under interactive graphical environment.
12
+# This function only works under interactive graphical environment.
13 13
 #
14 14
 # == value
15 15
 # A list containing row index and column index corresponding to the selected region.
... ...
@@ -90,7 +90,7 @@ to specific target regions.
90 90
 There are several vignettes in the package. Each vignette focuses on a specific topic. Following
91 91
 lists the general topics discussed in these vignettes:
92 92
 
93
-  1. [**Making a Single Heatmap**](http://http://www.bioconductor.org/packages/devel/bioc/vignettes/ComplexHeatmap/inst/doc/s2.single_heatmap.html)
93
+  1. [**Making a Single Heatmap**](http://www.bioconductor.org/packages/devel/bioc/vignettes/ComplexHeatmap/inst/doc/s2.single_heatmap.html)
94 94
 
95 95
     This vignette introduces the basic configuration for making a single heatmap. Similar as other
96 96
     R functions/packages, the basic usage is quite similar, but there are several unique features
... ...
@@ -112,36 +112,36 @@ lists the general topics discussed in these vignettes:
112 112
       different levels that split the heatmap.
113 113
     - The heatmap body itself can be completely self-defined.
114 114
 
115
-  2. [**Making a List of Heatmaps**](http://http://www.bioconductor.org/packages/devel/bioc/vignettes/ComplexHeatmap/inst/doc/s3.a_list_of_heatmaps.html)
115
+  2. [**Making a List of Heatmaps**](http://www.bioconductor.org/packages/devel/bioc/vignettes/ComplexHeatmap/inst/doc/s3.a_list_of_heatmaps.html)
116 116
 
117 117
     This vignette introduces how to concatenate a list of heatmaps and how adjustment is applied to keep
118 118
     the correspondence of the heatmaps.
119 119
 
120
-  3. [**Heatmap Annotations**](http://http://www.bioconductor.org/packages/devel/bioc/vignettes/ComplexHeatmap/inst/doc/s4.heatmap_annotation.html)
120
+  3. [**Heatmap Annotations**](http://www.bioconductor.org/packages/devel/bioc/vignettes/ComplexHeatmap/inst/doc/s4.heatmap_annotation.html)
121 121
 
122 122
     This vignette introduces the concept of the heatmap annotation and demonstrate how to make simple annotations
123 123
     as well as complex annotations. Also, the vignette explains the difference between column annotations
124 124
     and row annotations.
125 125
 
126
-  4. [**Heatmap and Annotation Legends**](http://http://www.bioconductor.org/packages/devel/bioc/vignettes/ComplexHeatmap/inst/doc/s5.legend.html)
126
+  4. [**Heatmap and Annotation Legends**](http://www.bioconductor.org/packages/devel/bioc/vignettes/ComplexHeatmap/inst/doc/s5.legend.html)
127 127
 
128 128
     This vignette introduces how to configurate the heatmap legend and annotation legend, also
129 129
     how to add self-defined legends.
130 130
 
131
-  5. [**Heatmap Decoration**](http://http://www.bioconductor.org/packages/devel/bioc/vignettes/ComplexHeatmap/inst/doc/s6.heatmap_decoration.html)
131
+  5. [**Heatmap Decoration**](http://www.bioconductor.org/packages/devel/bioc/vignettes/ComplexHeatmap/inst/doc/s6.heatmap_decoration.html)
132 132
 
133 133
     This vignette introduces methods to add more self-defined graphics to the heatmaps after the heatmaps
134 134
     are generated.
135 135
 
136
-  6. [**Interactive with Heatmaps**](http://http://www.bioconductor.org/packages/devel/bioc/vignettes/ComplexHeatmap/inst/doc/s7.interactive.html)
136
+  6. [**Interactive with Heatmaps**](http://www.bioconductor.org/packages/devel/bioc/vignettes/ComplexHeatmap/inst/doc/s7.interactive.html)
137 137
 
138 138
     How to select a region in the heatmap to retrieve the sub-matrix.
139 139
   
140
-  7. [**OncoPrint**](http://http://www.bioconductor.org/packages/devel/bioc/vignettes/ComplexHeatmap/inst/doc/s8.oncoprint.html)
140
+  7. [**OncoPrint**](http://www.bioconductor.org/packages/devel/bioc/vignettes/ComplexHeatmap/inst/doc/s8.oncoprint.html)
141 141
 
142 142
     How to make an oncoPrint.
143 143
 
144
-  8. [**Examples**](http://http://www.bioconductor.org/packages/devel/bioc/vignettes/ComplexHeatmap/inst/doc/s9.examples.html)
144
+  8. [**Examples**](http://www.bioconductor.org/packages/devel/bioc/vignettes/ComplexHeatmap/inst/doc/s9.examples.html)
145 145
 
146 146
     More simulated and real-world examples are shown in this vignette.
147 147
     
148 148
new file mode 100644
... ...
@@ -60,6 +60,10 @@ The \code{\link{Heatmap-class}} provides following methods:
60 60
   \item \code{\link{Heatmap}}: constructor method.
61 61
   \item \code{\link{draw,Heatmap-method}}: draw a single heatmap.
62 62
   \item \code{\link{add_heatmap,Heatmap-method}} append heatmaps and row annotations to a list of heatmaps.
63
+  \item \code{\link{row_order,HeatmapList-method}}: get order of rows
64
+  \item \code{\link{column_order,HeatmapList-method}}: get order of columns
65
+  \item \code{\link{row_dend,HeatmapList-method}}: get row dendrograms
66
+  \item \code{\link{column_dend,HeatmapList-method}}: get column dendrograms
63 67
 }}
64 68
 \author{
65 69
 Zuguang Gu <z.gu@dkfz.de>
... ...
@@ -27,7 +27,7 @@ HeatmapAnnotation(df, name, col, na_col = "grey",
27 27
   \item{na_col}{color for \code{NA} values in simple annotations.}
28 28
   \item{annotation_legend_param}{a list which contains parameters for annotation legends}
29 29
   \item{show_legend}{whether show legend for each column in \code{df}.}
30
-  \item{...}{functions which define complex annotations. Values should be named arguments.}
30
+  \item{...}{functions which define complex annotations or vectors of simple annotation. Values should be named arguments.}
31 31
   \item{which}{are the annotations row annotations or column annotations?}
32 32
   \item{annotation_height}{height of each annotation if annotations are column annotations.}
33 33
   \item{annotation_width}{width of each annotation if annotations are row annotations.}
... ...
@@ -55,6 +55,8 @@ df = data.frame(type = c("a", "a", "a", "b", "b", "b"))
55 55
 ha = HeatmapAnnotation(df = df)
56 56
 
57 57
 ha = HeatmapAnnotation(df = df, col = list(type = c("a" =  "red", "b" = "blue")))
58
+ha = HeatmapAnnotation(type = c("a", "a", "a", "b", "b", "b"), 
59
+    col = list(type = c("a" =  "red", "b" = "blue")))
58 60
 
59 61
 ha = HeatmapAnnotation(df = df, col = list(type = c("a" =  "red", "b" = "blue")), 
60 62
     which = "row")
... ...
@@ -55,7 +55,11 @@ The \code{\link{HeatmapList-class}} provides following methods:
55 55
 
56 56
 \itemize{
57 57
   \item \code{\link{draw,HeatmapList-method}}: draw the list of heatmaps and row annotations.
58
-  \item \code{\link{add_heatmap,HeatmapList-method}} add heatmaps to the list of heatmaps.
58
+  \item \code{\link{add_heatmap,HeatmapList-method}}: add heatmaps to the list of heatmaps.
59
+  \item \code{\link{row_order,HeatmapList-method}}: get order of rows
60
+  \item \code{\link{column_order,HeatmapList-method}}: get order of columns
61
+  \item \code{\link{row_dend,HeatmapList-method}}: get row dendrograms
62
+  \item \code{\link{column_dend,HeatmapList-method}}: get column dendrograms
59 63
 }}
60 64
 \author{
61 65
 Zuguang Gu <z.gu@dkfz.de>
... ...
@@ -34,7 +34,10 @@ A graphic function which can be set in \code{\link{HeatmapAnnotation}} construct
34 34
 Zuguang Gu <z.gu@dkfz.de>
35 35
 }
36 36
 \examples{
37
-# There is no example
38
-NULL
37
+mat = matrix(rnorm(10000), nr = 1000)
38
+labels = sample(letters, 20, replace = TRUE)
39
+Heatmap(mat, show_row_dend = FALSE, show_column_dend = FALSE) + 
40
+rowAnnotation(link = row_anno_link(at = sample(1000, 20), labels = labels),
41
+    width = unit(1, "cm") + max_text_width(labels))
39 42
 
40 43
 }
... ...
@@ -23,7 +23,7 @@ This function contructs the name of the viewport,
23 23
 goes to the viewport by \code{\link[grid]{seekViewport}} and applies code
24 24
 to that viewport.
25 25
 
26
-Since you know the number of leaves in the dendrogram, it is
26
+If you know the number of leaves in the dendrogram, it is
27 27
 simple to calculate the position of every leave in the dendrogram.
28 28
 E.g., for the column dendrogram, the i^th leave is located at:
29 29
 
... ...
@@ -23,7 +23,7 @@ This function contructs the name of the viewport,
23 23
 goes to the viewport by \code{\link[grid]{seekViewport}} and applies code
24 24
 to that viewport.
25 25
 
26
-Since you know the dimensions of the matrix, it is
26
+If you know the dimensions of the matrix, it is
27 27
 simple to calculate the position of every row name or column name in the heatmap.
28 28
 E.g., for the column column, the i^th name is located at:
29 29
 
... ...
@@ -22,7 +22,7 @@ This function contructs the name of the viewport,
22 22
 goes to the viewport by \code{\link[grid]{seekViewport}} and applies code
23 23
 to that viewport.
24 24
 
25
-Since you know the number of rows and columns for that row slice, it is
25
+If you know the number of rows and columns for that row slice, it is
26 26
 simple to calculate the position of every small grid in the row slice.
27 27
 E.g., the position for the grid in i^th row and j^th column is:
28 28
 
... ...
@@ -19,12 +19,12 @@ densityHeatmap(data,
19 19
 \arguments{
20 20
 
21 21
   \item{data}{a matrix or a list. If it is a matrix, density will be calculated by columns.}
22
-  \item{col}{a list of colors that density values are scaled to.}
22
+  \item{col}{a list of colors that density values are mapped to.}
23 23
   \item{color_space}{the color space in which colors are interpolated. Pass to \code{\link[circlize]{colorRamp2}}.}
24
-  \item{anno}{annotation for the matrix columns or the list. The value should be a vector or a data frame.  It can also be a \code{\link{HeatmapAnnotation-class}} object.}
24
+  \item{anno}{annotation for the matrix columns or the list. The value should be a vector or a data frame  and colors for annotations are randomly assigned. If you want to customize the annotation colors, use a \code{\link{HeatmapAnnotation-class}} object directly.}
25 25
   \item{ylab}{label on y-axis in the plot}
26 26
   \item{title}{title of the plot}
27
-  \item{range}{ranges on the y-axis. The lower bound is the maximul value between \code{range[[1]]} and minimal value in the data and the upper bound is the minimal value between \code{range[[2]]} and maximul value in the data.}
27
+  \item{range}{ranges on the y-axis. By default the range is between 1th quantile and 99th quantile of the data.}
28 28
   \item{...}{pass to \code{\link{draw,HeatmapList-method}}}
29 29
 
30 30
 }
... ...
@@ -46,7 +46,8 @@ densityHeatmap(matrix)
46 46
 densityHeatmap(matrix, anno = rep(c("A", "B"), each = 5))
47 47
 densityHeatmap(matrix, col = c("white", "red"), anno = rep(c("A", "B"), each = 5))
48 48
 
49
-ha = HeatmapAnnotation(points = anno_points(runif(10)))
49
+ha = HeatmapAnnotation(points = anno_points(runif(10)),
50
+    anno = rep(c("A", "B"), each = 5), col = list(anno = c("A" = "red", "B" = "blue")))
50 51
 densityHeatmap(matrix, anno = ha)
51 52
 
52 53
 lt = list(rnorm(10), rnorm(10))
... ...
@@ -18,7 +18,7 @@ selectArea(mark = TRUE)
18 18
 Users can use mouse to click two positions on the heatmap, the function
19 19
 will return the row index and column index for the selected region in the selected matrix.
20 20
 
21
-Of cource this function only works under interactive graphical environment.
21
+This function only works under interactive graphical environment.
22 22
 }
23 23
 \value{
24 24
 A list containing row index and column index corresponding to the selected region.
... ...
@@ -33,4 +33,4 @@ to select a sub-area in the heatmap and retrieve index for rows and columns in t
33 33
 Since heatmaps are always used to visualize patterns that are clustered together, 
34 34
 this feature can greatly give convinience to extract the sub-matrix that users are interested in.
35 35
 
36
-<p><img src="select_region.gif" /></p>
36
+<p><img src="select_region.gif" width="600" /></p>
... ...
@@ -100,7 +100,7 @@ mat_list = unify_mat_list(mat_list)
100 100
 mat_list
101 101
 ```
102 102
 
103
-Same as the first example, but here we also define `background` in `alter_fun_list` argument. This function defines
103
+Same as the first example, but here we also define `background` in `alter_fun` argument. This function defines
104 104
 how to add graphics when there is no alteration and it is always put as the first in the list.
105 105
 
106 106
 ```{r}
... ...
@@ -133,7 +133,7 @@ oncoPrint(mat_list,
133 133
 ```
134 134
 
135 135
 If `alter_fun` is set as a single function, customization can be more flexible. In following example,
136
-rectangles always fill the whole grid.
136
+rectangles always fill the whole grid evenly.
137 137
 
138 138
 ```{r}
139 139
 oncoPrint(mat_list,
... ...
@@ -274,6 +274,10 @@ oncoPrint(mat, get_type = function(x) strsplit(x, ";")[[1]],
274 274
 	barplot_ignore = "AMP")
275 275
 ```
276 276
 
277
+If you make the plot in an interactive device (e.g. `X11` or Rstudio IDE), the generation of the plot
278
+may be very slow. In this case, we suggest users to directly save the plot to a separate file 
279
+(e.g. using `png()` or `pdf()`) and then visualize the plot afterwards.
280
+
277 281
 
278 282
 ## Session info
279 283