git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ComplexHeatmap@110567 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -2,6 +2,8 @@ CHANGES in VERSION 1.7.1 |
2 | 2 |
|
3 | 3 |
* `x` and `y` are `unit` object now in `cell_fun` |
4 | 4 |
* add an example to visualize GO game |
5 |
+* transparency is kept when making discreate color mappings |
|
6 |
+* `oncoPrint()`: barplots on top now are controlled by `top_annotation` argument |
|
5 | 7 |
|
6 | 8 |
================================ |
7 | 9 |
|
... | ... |
@@ -25,10 +25,10 @@ setGeneric('prepare', function(object, ...) standardGeneric('prepare')) |
25 | 25 |
|
26 | 26 |
setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation')) |
27 | 27 |
|
28 |
-setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames')) |
|
29 |
- |
|
30 | 28 |
setGeneric('get_color_mapping_param_list', function(object, ...) standardGeneric('get_color_mapping_param_list')) |
31 | 29 |
|
30 |
+setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames')) |
|
31 |
+ |
|
32 | 32 |
setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend')) |
33 | 33 |
|
34 | 34 |
setGeneric('draw', function(object, ...) standardGeneric('draw')) |
... | ... |
@@ -74,7 +74,8 @@ ColorMapping = function(name, colors = NULL, levels = NULL, |
74 | 74 |
if(length(colors) != length(levels)) { |
75 | 75 |
stop("length of colors and length of levels should be the same.\n") |
76 | 76 |
} |
77 |
- colors = rgb(t(col2rgb(colors)), maxColorValue = 255) |
|
77 |
+ colors = t(col2rgb(colors, alpha = TRUE)) |
|
78 |
+ colors = rgb(colors[, 1:3, drop = FALSE], alpha = colors[, 4], maxColorValue = 255) |
|
78 | 79 |
.Object@colors = colors |
79 | 80 |
if(is.numeric(levels)) { |
80 | 81 |
.Object@levels = as.character(levels) |
... | ... |
@@ -14,17 +14,17 @@ |
14 | 14 |
# -row_order order of genes. By default it is sorted by frequency of alterations decreasingly. |
15 | 15 |
# Set it to ``NULL`` if you don't want to set the order |
16 | 16 |
# -column_order order of samples. By default the order is calculated by the 'memo sort' method which can visualize |
17 |
-# the mutual exclusivity across genes. |
|
17 |
+# the mutual exclusivity across genes. Set it to ``NULL`` if you don't want to set the order |
|
18 | 18 |
# -show_column_names whether show column names |
19 | 19 |
# -pct_gp graphic paramters for percent row annotation |
20 | 20 |
# -axis_gp graphic paramters for axes |
21 | 21 |
# -show_row_barplot whether show barplot annotation on rows |
22 | 22 |
# -row_barplot_width width of barplot annotation on rows. It should be a `grid::unit` object |
23 |
-# -show_column_barplot whether show barplot annotation on columns |
|
24 |
-# -column_barplot_height height of barplot annotatioin on columns. it should be a `grid::unit` object. |
|
25 | 23 |
# -remove_empty_columns if there is no alteration in that sample, whether remove it on the heatmap |
26 | 24 |
# -heatmap_legend_param pass to `Heatmap` |
27 |
-# -... pass to `Heatmap` |
|
25 |
+# -top_annotation by default the top annotation contains barplots representing frequency of mutations in every sample. |
|
26 |
+# -top_annotation_height height of the top annotation, should be a `grid::unit` object. |
|
27 |
+# -... pass to `Heatmap`, so can set ``bottom_annotation`` here. |
|
28 | 28 |
# |
29 | 29 |
# == details |
30 | 30 |
# The function returns a normal heatmap list and you can add more heatmaps/row annotations to it. |
... | ... |
@@ -47,16 +47,22 @@ oncoPrint = function(mat, get_type = function(x) x, |
47 | 47 |
alter_fun_list, col, |
48 | 48 |
row_order = oncoprint_row_order(), |
49 | 49 |
column_order = oncoprint_column_order(), |
50 |
- show_column_names = FALSE, |
|
50 |
+ show_column_names = FALSE, |
|
51 | 51 |
pct_gp = gpar(), |
52 | 52 |
axis_gp = gpar(fontsize = 8), |
53 | 53 |
show_row_barplot = TRUE, |
54 | 54 |
row_barplot_width = unit(2, "cm"), |
55 |
- show_column_barplot = TRUE, |
|
56 |
- column_barplot_height = unit(2, "cm"), |
|
57 | 55 |
remove_empty_columns = FALSE, |
58 | 56 |
heatmap_legend_param = list(title = "Alterations"), |
57 |
+ top_annotation = HeatmapAnnotation(column_bar = anno_column_bar), |
|
58 |
+ top_annotation_height = unit(2, "cm"), |
|
59 | 59 |
...) { |
60 |
+ |
|
61 |
+ if(length(names(list(...))) > 0) { |
|
62 |
+ if(names(list(...)) %in% c("show_column_barplot", "column_barplot_height")) { |
|
63 |
+ stop("`show_column_barplot` and `column_barplot_height` is deprecated, please configure `top_annotation` directly.") |
|
64 |
+ } |
|
65 |
+ } |
|
60 | 66 |
|
61 | 67 |
# convert mat to mat_list |
62 | 68 |
if(inherits(mat, "matrix")) { |
... | ... |
@@ -127,12 +133,13 @@ oncoPrint = function(mat, get_type = function(x) x, |
127 | 133 |
} |
128 | 134 |
return(score) |
129 | 135 |
} |
130 |
- scores = apply(count_matrix[row_order, ], 2, scoreCol) |
|
136 |
+ scores = apply(count_matrix[row_order, ,drop = FALSE], 2, scoreCol) |
|
131 | 137 |
order(scores, decreasing=TRUE) |
132 | 138 |
} |
133 | 139 |
|
134 | 140 |
count_matrix = apply(arr, c(1, 2), sum) |
135 | 141 |
if(is.null(row_order)) row_order = seq_len(nrow(count_matrix)) |
142 |
+ if(is.null(column_order)) column_order = seq_len(ncol(count_matrix)) |
|
136 | 143 |
row_order = row_order |
137 | 144 |
if(is.character(column_order)) { |
138 | 145 |
column_order = structure(seq_len(dim(arr)[2]), names = dimnames(arr)[[2]])[column_order] |
... | ... |
@@ -220,37 +227,25 @@ oncoPrint = function(mat, get_type = function(x) x, |
220 | 227 |
upViewport() |
221 | 228 |
} |
222 | 229 |
|
223 |
- ha_column_bar = HeatmapAnnotation(column_bar = anno_column_bar, which = "column", height = column_barplot_height) |
|
230 |
+ top_annotation = top_annotation |
|
224 | 231 |
|
225 | 232 |
##################################################################### |
226 | 233 |
# the main matrix |
227 | 234 |
pheudo = c(all_type, rep(NA, nrow(arr)*ncol(arr) - length(all_type))) |
228 |
- dim(pheudo) = dim(arr[, , 1]) |
|
229 |
- dimnames(pheudo) = dimnames(arr[, , 1]) |
|
235 |
+ dim(pheudo) = dim(arr)[1:2] |
|
236 |
+ dimnames(pheudo) = dimnames(arr)[1:2] |
|
230 | 237 |
|
231 |
- if(show_column_barplot) { |
|
232 |
- ht = Heatmap(pheudo, col = col, rect_gp = gpar(type = "none"), |
|
233 |
- cluster_rows = FALSE, cluster_columns = FALSE, row_order = row_order, column_order = column_order, |
|
234 |
- cell_fun = function(j, i, x, y, width, height, fill) { |
|
235 |
- z = arr[i, j, ] |
|
236 |
- add_oncoprint("background", x, y, width, height) |
|
237 |
- for(type in all_type[z]) { |
|
238 |
- add_oncoprint(type, x, y, width, height) |
|
239 |
- } |
|
240 |
- }, show_column_names = show_column_names, |
|
241 |
- top_annotation = ha_column_bar, |
|
242 |
- heatmap_legend_param = heatmap_legend_param, ...) |
|
243 |
- } else { |
|
244 |
- ht = Heatmap(pheudo, rect_gp = gpar(type = "none"), |
|
245 |
- cluster_rows = FALSE, cluster_columns = FALSE, row_order = row_order, column_order = column_order, |
|
246 |
- cell_fun = function(j, i, x, y, width, height, fill) { |
|
247 |
- z = arr[i, j, ] |
|
248 |
- add_oncoprint("background", x, y, width, height) |
|
249 |
- for(type in all_type[z]) { |
|
250 |
- add_oncoprint(type, x, y, width, height) |
|
251 |
- } |
|
252 |
- }, show_column_names = show_column_names, ...) |
|
253 |
- } |
|
238 |
+ ht = Heatmap(pheudo, col = col, rect_gp = gpar(type = "none"), |
|
239 |
+ cluster_rows = FALSE, cluster_columns = FALSE, row_order = row_order, column_order = column_order, |
|
240 |
+ cell_fun = function(j, i, x, y, width, height, fill) { |
|
241 |
+ z = arr[i, j, ] |
|
242 |
+ add_oncoprint("background", x, y, width, height) |
|
243 |
+ for(type in all_type[z]) { |
|
244 |
+ add_oncoprint(type, x, y, width, height) |
|
245 |
+ } |
|
246 |
+ }, show_column_names = show_column_names, |
|
247 |
+ top_annotation = top_annotation, |
|
248 |
+ heatmap_legend_param = heatmap_legend_param, ...) |
|
254 | 249 |
|
255 | 250 |
if(show_row_barplot) { |
256 | 251 |
ht_list = ha_pct + ht + ha_row_bar |
... | ... |
@@ -19,6 +19,7 @@ |
19 | 19 |
# -split one or multiple variables that split the rows. |
20 | 20 |
# -cluster_rows whether perform clustering on rows of the main heatmap. |
21 | 21 |
# -cluster_columns whether perform clustering on columns for all heatmaps. |
22 |
+# -row_order order of rows, remember to turn off ``cluster_rows`` |
|
22 | 23 |
# -... pass to `draw,HeatmapList-method` or `make_layout,HeatmapList-method` |
23 | 24 |
# |
24 | 25 |
# == details |
... | ... |
@@ -38,10 +39,10 @@ |
38 | 39 |
plotDataFrame = function(df, overlap = 0.25, nlevel = 30, show_row_names = TRUE, |
39 | 40 |
show_column_names = TRUE, group = NULL, group_names = names(group), |
40 | 41 |
main_heatmap = NULL, km = 1, split = NULL, cluster_rows = TRUE, |
41 |
- cluster_columns = TRUE, ...) { |
|
42 |
+ cluster_columns = TRUE, row_order = NULL, ...) { |
|
42 | 43 |
|
43 | 44 |
if(is.matrix(df)) { |
44 |
- ht_list = Heatmap(df, show_row_names = show_row_names, show_column_names = show_column_names) |
|
45 |
+ ht_list = Heatmap(df, show_row_names = show_row_names, show_column_names = show_column_names, row_order = row_order) |
|
45 | 46 |
} else if(is.data.frame(df)) { |
46 | 47 |
|
47 | 48 |
nc = ncol(df) |
... | ... |
@@ -129,15 +130,15 @@ plotDataFrame = function(df, overlap = 0.25, nlevel = 30, show_row_names = TRUE, |
129 | 130 |
|
130 | 131 |
if(i == 1) { |
131 | 132 |
if(i == i_max) { |
132 |
- ht_list = Heatmap(df[, ci, drop = FALSE], name = group_names[i], column_title = column_title, cluster_rows = cluster_rows, cluster_columns = cluster_columns, show_row_names = show_row_names, show_column_names = show_column_names, km = km2, split = split2) |
|
133 |
+ ht_list = Heatmap(df[, ci, drop = FALSE], name = group_names[i], column_title = column_title, cluster_rows = cluster_rows, cluster_columns = cluster_columns, show_row_names = show_row_names, show_column_names = show_column_names, km = km2, split = split2, row_order = row_order) |
|
133 | 134 |
} else { |
134 |
- ht_list = Heatmap(df[, ci, drop = FALSE], name = group_names[i], column_title = column_title, cluster_rows = cluster_rows, cluster_columns = cluster_columns, show_row_names = FALSE, show_column_names = show_column_names, km = km2, split = split2) |
|
135 |
+ ht_list = Heatmap(df[, ci, drop = FALSE], name = group_names[i], column_title = column_title, cluster_rows = cluster_rows, cluster_columns = cluster_columns, show_row_names = FALSE, show_column_names = show_column_names, km = km2, split = split2, row_order = row_order) |
|
135 | 136 |
} |
136 | 137 |
} else { |
137 | 138 |
if(i == i_max) { |
138 |
- ht_list = ht_list + Heatmap(df[, ci, drop = FALSE], name = group_names[i], column_title = column_title, cluster_rows = cluster_rows, cluster_columns = cluster_columns, show_row_names = show_row_names, show_column_names = show_column_names, km = km2, split = split2) |
|
139 |
+ ht_list = ht_list + Heatmap(df[, ci, drop = FALSE], name = group_names[i], column_title = column_title, cluster_rows = cluster_rows, cluster_columns = cluster_columns, show_row_names = show_row_names, show_column_names = show_column_names, km = km2, split = split2, row_order = row_order) |
|
139 | 140 |
} else { |
140 |
- ht_list = ht_list + Heatmap(df[, ci, drop = FALSE], name = group_names[i], column_title = column_title, cluster_rows = cluster_rows, cluster_columns = cluster_columns, show_row_names = FALSE, show_column_names = show_column_names, km = km2, split = split2) |
|
141 |
+ ht_list = ht_list + Heatmap(df[, ci, drop = FALSE], name = group_names[i], column_title = column_title, cluster_rows = cluster_rows, cluster_columns = cluster_columns, show_row_names = FALSE, show_column_names = show_column_names, km = km2, split = split2, row_order = row_order) |
|
141 | 142 |
} |
142 | 143 |
} |
143 | 144 |
|
... | ... |
@@ -6,9 +6,9 @@ cm = ColorMapping(name = "test", |
6 | 6 |
|
7 | 7 |
test_that("color mapping is discrete", { |
8 | 8 |
expect_that(show(cm), prints_text("Discrete color mapping")) |
9 |
- expect_that(map_to_colors(cm, "a"), is_identical_to("#0000FF")) |
|
9 |
+ expect_that(map_to_colors(cm, "a"), is_identical_to("#0000FFFF")) |
|
10 | 10 |
expect_that(map_to_colors(cm, "d"), throws_error("cannot map some of the levels")) |
11 |
- expect_that(map_to_colors(cm, c("a", "a", "b", "c")), is_identical_to(c("#0000FF", "#0000FF", "#FFFFFF", "#FF0000"))) |
|
11 |
+ expect_that(map_to_colors(cm, c("a", "a", "b", "c")), is_identical_to(c("#0000FFFF", "#0000FFFF", "#FFFFFFFF", "#FF0000FF"))) |
|
12 | 12 |
}) |
13 | 13 |
|
14 | 14 |
cm = ColorMapping(name = "test", |
... | ... |
@@ -27,10 +27,10 @@ cm = ColorMapping(name = "test", |
27 | 27 |
|
28 | 28 |
test_that("color mapping is discrete but with numeric levels", { |
29 | 29 |
expect_that(show(cm), prints_text("Discrete color mapping")) |
30 |
- expect_that(map_to_colors(cm, 1), is_identical_to("#0000FF")) |
|
31 |
- expect_that(map_to_colors(cm, "1"), is_identical_to("#0000FF")) |
|
30 |
+ expect_that(map_to_colors(cm, 1), is_identical_to("#0000FFFF")) |
|
31 |
+ expect_that(map_to_colors(cm, "1"), is_identical_to("#0000FFFF")) |
|
32 | 32 |
expect_that(map_to_colors(cm, 5), throws_error("cannot map some of the levels")) |
33 |
- expect_that(map_to_colors(cm, c(1, 1, 2, 2)), is_identical_to(c("#0000FF", "#0000FF", "#FFFFFF", "#FFFFFF"))) |
|
33 |
+ expect_that(map_to_colors(cm, c(1, 1, 2, 2)), is_identical_to(c("#0000FFFF", "#0000FFFF", "#FFFFFFFF", "#FFFFFFFF"))) |
|
34 | 34 |
}) |
35 | 35 |
|
36 | 36 |
|
... | ... |
@@ -14,9 +14,9 @@ ColorMapping(name, colors = NULL, levels = NULL, |
14 | 14 |
|
15 | 15 |
\item{name}{name for this color mapping. The name is automatically generated if it is not specified.} |
16 | 16 |
\item{colors}{discrete colors.} |
17 |
- \item{levels}{levels that correspond to \code{colors}. If \code{colors} is name indexed, \code{levels} can be ignored.} |
|
17 |
+ \item{levels}{levels that correspond to \code{colors}. If \code{colors} is name indexed, \code{levels} can be ignored.} |
|
18 | 18 |
\item{col_fun}{color mapping function that maps continuous values to colors.} |
19 |
- \item{breaks}{breaks for the continuous color mapping. If \code{col_fun} isgenerated by \code{\link[circlize]{colorRamp2}}, \code{breaks} can be ignored.} |
|
19 |
+ \item{breaks}{breaks for the continuous color mapping. If \code{col_fun} is generated by \code{\link[circlize]{colorRamp2}}, \code{breaks} can be ignored.} |
|
20 | 20 |
\item{na_col}{colors for \code{NA} values.} |
21 | 21 |
|
22 | 22 |
} |
... | ... |
@@ -70,13 +70,13 @@ Heatmap(matrix, col, name, |
70 | 70 |
} |
71 | 71 |
\arguments{ |
72 | 72 |
|
73 |
- \item{matrix}{a matrix. Either numeric or character. If it is a simple vector, it will beconverted to a one-column matrix.} |
|
74 |
- \item{col}{a vector of colors if the color mapping is discrete or a color mapping function if the matrix is continuous numbers (should be generated by \code{\link[circlize]{colorRamp2}}. If the matrix is continuous,the value can also be a vector of colors so that colors will be interpolated. Pass to \code{\link{ColorMapping}}.} |
|
73 |
+ \item{matrix}{a matrix. Either numeric or character. If it is a simple vector, it will be converted to a one-column matrix.} |
|
74 |
+ \item{col}{a vector of colors if the color mapping is discrete or a color mapping function if the matrix is continuous numbers (should be generated by \code{\link[circlize]{colorRamp2}}. If the matrix is continuous, the value can also be a vector of colors so that colors will be interpolated. Pass to \code{\link{ColorMapping}}.} |
|
75 | 75 |
\item{name}{name of the heatmap. The name is used as the title of the heatmap legend.} |
76 | 76 |
\item{na_col}{color for \code{NA} values.} |
77 | 77 |
\item{rect_gp}{graphic parameters for drawing rectangles (for heatmap body).} |
78 |
- \item{color_space}{the color space in which colors are interpolated. Only used if \code{matrix} is numeric and \code{col} is a vector of colors. Pass to \code{\link[circlize]{colorRamp2}}.} |
|
79 |
- \item{cell_fun}{self-defined function to add graphics on each cell. Seven parameters will be passed into this function: \code{i}, \code{j}, \code{x}, \code{y}, \code{width}, \code{height}, \code{fill} which are row index,column index in \code{matrix}, coordinate of the middle points in the heatmap body viewport,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.} |
|
78 |
+ \item{color_space}{the color space in which colors are interpolated. Only used if \code{matrix} is numeric and \code{col} is a vector of colors. Pass to \code{\link[circlize]{colorRamp2}}.} |
|
79 |
+ \item{cell_fun}{self-defined function to add graphics on each cell. Seven parameters will be passed into this function: \code{i}, \code{j}, \code{x}, \code{y}, \code{width}, \code{height}, \code{fill} which are row index, column index in \code{matrix}, coordinate of the middle points in the heatmap body viewport, 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.} |
|
80 | 80 |
\item{row_title}{title on row.} |
81 | 81 |
\item{row_title_side}{will the title be put on the left or right of the heatmap?} |
82 | 82 |
\item{row_title_gp}{graphic parameters for drawing text.} |
... | ... |
@@ -85,14 +85,14 @@ Heatmap(matrix, col, name, |
85 | 85 |
\item{column_title_side}{will the title be put on the top or bottom of the heatmap?} |
86 | 86 |
\item{column_title_gp}{graphic parameters for drawing text.} |
87 | 87 |
\item{column_title_rot}{rotation of column titles. Only 0, 90, 270 are allowed to set.} |
88 |
- \item{cluster_rows}{If the value is a logical, it means whether make cluster on rows. The value can alsobe a \code{\link[stats]{hclust}} or a \code{\link[stats]{dendrogram}} that already contains clustering information.This means you can use any type of clustering methods and render the \code{\link[stats]{dendrogram}}object with self-defined graphic settings.} |
|
89 |
- \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 thesetwo vectors.} |
|
88 |
+ \item{cluster_rows}{If the value is a logical, it means whether make cluster on rows. The value can also be a \code{\link[stats]{hclust}} or a \code{\link[stats]{dendrogram}} that already contains clustering information. This means you can use any type of clustering methods and render the \code{\link[stats]{dendrogram}} object with self-defined graphic settings.} |
|
89 |
+ \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.} |
|
90 | 90 |
\item{clustering_method_rows}{method to make cluster, pass to \code{\link[stats]{hclust}}.} |
91 | 91 |
\item{row_dend_side}{should the row cluster be put on the left or right of the heatmap?} |
92 | 92 |
\item{row_dend_width}{width of the row cluster, should be a \code{\link[grid]{unit}} object.} |
93 | 93 |
\item{show_row_dend}{whether show row clusters. } |
94 |
- \item{row_dend_gp}{graphics parameters for drawing lines. If users already provide a \code{\link[stats]{dendrogram}}object with edges rendered, this argument will be ignored.} |
|
95 |
- \item{row_dend_reorder}{apply reordering on rows. The value can be a logical value or a vector which contains weight which is used to reorder rows} |
|
94 |
+ \item{row_dend_gp}{graphics parameters for drawing lines. If users already provide a \code{\link[stats]{dendrogram}} object with edges rendered, this argument will be ignored.} |
|
95 |
+ \item{row_dend_reorder}{apply reordering on rows. The value can be a logical value or a vector which contains weight which is used to reorder rows} |
|
96 | 96 |
\item{row_hclust_side}{deprecated, use \code{row_dend_side} instead} |
97 | 97 |
\item{row_hclust_width}{deprecated, use \code{row_dend_width} instead} |
98 | 98 |
\item{show_row_hclust}{deprecated, use \code{show_row_dend} instead} |
... | ... |
@@ -105,17 +105,17 @@ Heatmap(matrix, col, name, |
105 | 105 |
\item{column_dend_height}{height of the column cluster, should be a \code{\link[grid]{unit}} object.} |
106 | 106 |
\item{show_column_dend}{whether show column clusters.} |
107 | 107 |
\item{column_dend_gp}{graphic parameters for drawling lines. Same settings as \code{row_dend_gp}.} |
108 |
- \item{column_dend_reorder}{apply reordering on columns. The value can be a logical value or a vector which contains weight which is used to reorder columns} |
|
108 |
+ \item{column_dend_reorder}{apply reordering on columns. The value can be a logical value or a vector which contains weight which is used to reorder columns} |
|
109 | 109 |
\item{column_hclust_side}{deprecated, use \code{column_dend_side} instead} |
110 | 110 |
\item{column_hclust_height}{deprecated, use \code{column_dend_height} instead} |
111 | 111 |
\item{show_column_hclust}{deprecated, use \code{show_column_dend} instead} |
112 | 112 |
\item{column_hclust_gp}{deprecated, use \code{column_dend_gp} instead} |
113 | 113 |
\item{column_hclust_reorder}{deprecated, use \code{column_dend_reorder} instead} |
114 |
- \item{row_order}{order of rows. It makes it easy to adjust row order for a list of heatmaps if this heatmap is selected as the main heatmap. Manually setting row order should turn off clustering} |
|
114 |
+ \item{row_order}{order of rows. It makes it easy to adjust row order for a list of heatmaps if this heatmap is selected as the main heatmap. Manually setting row order should turn off clustering} |
|
115 | 115 |
\item{column_order}{order of column. It makes it easy to adjust column order for both matrix and column annotations.} |
116 | 116 |
\item{row_names_side}{should the row names be put on the left or right of the heatmap?} |
117 | 117 |
\item{show_row_names}{whether show row names.} |
118 |
- \item{row_names_max_width}{maximum width of row names viewport. Because some times row names can be very long, it is not reasonableto show them all.} |
|
118 |
+ \item{row_names_max_width}{maximum width of row names viewport. Because some times row names can be very long, it is not reasonable to show them all.} |
|
119 | 119 |
\item{row_names_gp}{graphic parameters for drawing text.} |
120 | 120 |
\item{column_names_side}{should the column names be put on the top or bottom of the heatmap?} |
121 | 121 |
\item{column_names_max_height}{maximum height of column names viewport.} |
... | ... |
@@ -125,11 +125,11 @@ Heatmap(matrix, col, name, |
125 | 125 |
\item{top_annotation_height}{total height of the column annotations on the top.} |
126 | 126 |
\item{bottom_annotation}{a \code{\link{HeatmapAnnotation}} object.} |
127 | 127 |
\item{bottom_annotation_height}{total height of the column annotations on the bottom.} |
128 |
- \item{km}{do k-means clustering on rows. If the value is larger than 1, the heatmap will be split by rows according to the k-means clustering.For each row-clusters, hierarchical clustering is still applied with parameters above.} |
|
129 |
- \item{split}{a vector or a data frame by which the rows are split. But if \code{cluster_rows} is a clustering object, \code{split} can be a single numberindicating rows are to be split according to the split on the tree.} |
|
128 |
+ \item{km}{do k-means clustering on rows. If the value is larger than 1, the heatmap will be split by rows according to the k-means clustering. For each row-clusters, hierarchical clustering is still applied with parameters above.} |
|
129 |
+ \item{split}{a vector or a data frame by which the rows are split. But if \code{cluster_rows} is a clustering object, \code{split} can be a single number indicating rows are to be split according to the split on the tree.} |
|
130 | 130 |
\item{gap}{gap between row-slices if the heatmap is split by rows, should be \code{\link[grid]{unit}} object.} |
131 |
- \item{combined_name_fun}{if the heatmap is split by rows, how to make a combined row title for each slice?The input parameter for this function is a vector which contains level names under each column in \code{split}.} |
|
132 |
- \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.} |
|
131 |
+ \item{combined_name_fun}{if the heatmap is split by rows, how to make a combined row title for each slice? The input parameter for this function is a vector which contains level names under each column in \code{split}.} |
|
132 |
+ \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 heatmap is appended to a list of heatmaps.} |
|
133 | 133 |
\item{show_heatmap_legend}{whether show heatmap legend?} |
134 | 134 |
\item{heatmap_legend_param}{a list contains parameters for the heatmap legend. See \code{\link{color_mapping_legend,ColorMapping-method}} for all available parameters.} |
135 | 135 |
|
... | ... |
@@ -17,8 +17,8 @@ SingleAnnotation(name, value, col, fun, |
17 | 17 |
|
18 | 18 |
\item{name}{name for this annotation. If it is not specified, an internal name is assigned to it.} |
19 | 19 |
\item{value}{A vector of discrete or continuous annotation.} |
20 |
- \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. } |
|
21 |
- \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 |
+ \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. } |
|
21 |
+ \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.} |
|
22 | 22 |
\item{which}{is the annotation a row annotation or a column annotation?} |
23 | 23 |
\item{show_legend}{if it is a simple annotation, whether show legend when making the complete heatmap.} |
24 | 24 |
\item{gp}{Since simple annotation is represented as a row of grids. This argument controls graphic parameters for the simple annotation.} |
... | ... |
@@ -21,7 +21,7 @@ anno_barplot(x, baseline = "min", which = c("column", "row"), border = TRUE, bar |
21 | 21 |
\item{gp}{graphic parameters.} |
22 | 22 |
\item{lim}{data ranges.} |
23 | 23 |
\item{axis}{whether add axis} |
24 |
- \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 |
+ \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".} |
|
25 | 25 |
\item{axis_gp}{graphic parameters for axis} |
26 | 26 |
\item{axis_direction}{if the annotation is row annotation, should the axis be from left to right (default) or follow the reversed direction?} |
27 | 27 |
\item{...}{for future use.} |
... | ... |
@@ -14,7 +14,7 @@ anno_boxplot(x, which = c("column", "row"), border = TRUE, |
14 | 14 |
} |
15 | 15 |
\arguments{ |
16 | 16 |
|
17 |
- \item{x}{a matrix or a list. If \code{x} is a matrix and if \code{which} is \code{column}, statistics for boxplotis calculated by columns, if \code{which} is \code{row}, the calculation is by rows.} |
|
17 |
+ \item{x}{a matrix or a list. If \code{x} is a matrix and if \code{which} is \code{column}, statistics for boxplot is calculated by columns, if \code{which} is \code{row}, the calculation is by rows.} |
|
18 | 18 |
\item{which}{is the annotation a column annotation or a row annotation?} |
19 | 19 |
\item{border}{whether show border of the annotation compoment} |
20 | 20 |
\item{gp}{graphic parameters} |
... | ... |
@@ -22,7 +22,7 @@ anno_boxplot(x, which = c("column", "row"), border = TRUE, |
22 | 22 |
\item{pch}{point type} |
23 | 23 |
\item{size}{point size} |
24 | 24 |
\item{axis}{whether add axis} |
25 |
- \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".} |
|
25 |
+ \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".} |
|
26 | 26 |
\item{axis_gp}{graphic parameters for axis} |
27 | 27 |
\item{axis_direction}{if the annotation is row annotation, should the axis be from left to right (default) or follow the reversed direction?} |
28 | 28 |
|
... | ... |
@@ -12,7 +12,7 @@ anno_density(x, which = c("column", "row"), gp = gpar(fill = "#CCCCCC"), |
12 | 12 |
} |
13 | 13 |
\arguments{ |
14 | 14 |
|
15 |
- \item{x}{a matrix or a list. If \code{x} is a matrix and if \code{which} is \code{column}, statistics for densityis calculated by columns, if \code{which} is \code{row}, the calculation is by rows.} |
|
15 |
+ \item{x}{a matrix or a list. If \code{x} is a matrix and if \code{which} is \code{column}, statistics for density is calculated by columns, if \code{which} is \code{row}, the calculation is by rows.} |
|
16 | 16 |
\item{which}{is the annotation a column annotation or a row annotation?} |
17 | 17 |
\item{gp}{graphic parameters. Note it is ignored if \code{type} equals to \code{heatmap}.} |
18 | 18 |
\item{type}{which type of graphics is used to represent density distribution.} |
... | ... |
@@ -11,7 +11,7 @@ anno_histogram(x, which = c("column", "row"), gp = gpar(fill = "#CCCCCC"), ...) |
11 | 11 |
} |
12 | 12 |
\arguments{ |
13 | 13 |
|
14 |
- \item{x}{a matrix or a list. If \code{x} is a matrix and if \code{which} is \code{column}, statistics for histogramis calculated by columns, if \code{which} is \code{row}, the calculation is by rows.} |
|
14 |
+ \item{x}{a matrix or a list. If \code{x} is a matrix and if \code{which} is \code{column}, statistics for histogram is calculated by columns, if \code{which} is \code{row}, the calculation is by rows.} |
|
15 | 15 |
\item{which}{is the annotation a column annotation or a row annotation?} |
16 | 16 |
\item{gp}{graphic parameters} |
17 | 17 |
\item{...}{pass to \code{\link[graphics]{hist}}} |
... | ... |
@@ -21,7 +21,7 @@ anno_points(x, which = c("column", "row"), border = TRUE, gp = gpar(), pch = 16, |
21 | 21 |
\item{size}{point size.} |
22 | 22 |
\item{lim}{data ranges.} |
23 | 23 |
\item{axis}{whether add axis.} |
24 |
- \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 |
+ \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".} |
|
25 | 25 |
\item{axis_gp}{graphic parameters for axis} |
26 | 26 |
\item{axis_direction}{if the annotation is row annotation, should the axis be from left to right (default) or follow the reversed direction?} |
27 | 27 |
\item{...}{for future use.} |
... | ... |
@@ -17,7 +17,7 @@ anno_text(x, which = c("column", "row"), gp = gpar(), rot = 0, |
17 | 17 |
\item{gp}{graphic parameters.} |
18 | 18 |
\item{rot}{rotation of text} |
19 | 19 |
\item{just}{justification of text, pass to \code{\link[grid]{grid.text}}} |
20 |
- \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.} |
|
20 |
+ \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.} |
|
21 | 21 |
|
22 | 22 |
} |
23 | 23 |
\value{ |
... | ... |
@@ -19,7 +19,7 @@ densityHeatmap(data, |
19 | 19 |
\item{data}{a matrix or a list. If it is a matrix, density will be calculated by columns.} |
20 | 20 |
\item{col}{a list of colors that density values are scaled to.} |
21 | 21 |
\item{color_space}{the color space in which colors are interpolated. Pass to \code{\link[circlize]{colorRamp2}}.} |
22 |
- \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.} |
|
22 |
+ \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.} |
|
23 | 23 |
\item{ylab}{label on y-axis in the plot} |
24 | 24 |
\item{title}{title of the plot} |
25 | 25 |
|
... | ... |
@@ -13,7 +13,7 @@ Draw the single annotation |
13 | 13 |
|
14 | 14 |
\item{object}{a \code{\link{SingleAnnotation-class}} object.} |
15 | 15 |
\item{index}{a vector of orders} |
16 |
- \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.} |
|
16 |
+ \item{k}{if row annotation is splitted, the value identifies which row slice. It is only used for the naems of the viewport which contains the annotation graphics.} |
|
17 | 17 |
\item{n}{total number of row slices} |
18 | 18 |
|
19 | 19 |
} |
... | ... |
@@ -15,7 +15,7 @@ enhanced_basicplot(data, ..., ylim = NULL, |
15 | 15 |
} |
16 | 16 |
\arguments{ |
17 | 17 |
|
18 |
- \item{data}{a matrix, a list or a simple numeric vector. If your data is a data frameplease convert it to a matrix in the first place.} |
|
18 |
+ \item{data}{a matrix, a list or a simple numeric vector. If your data is a data frame please convert it to a matrix in the first place.} |
|
19 | 19 |
\item{...}{pass to \code{\link{Heatmap}}} |
20 | 20 |
\item{ylim}{ranges on y axis} |
21 | 21 |
\item{ylab}{label on y axis} |
... | ... |
@@ -14,7 +14,7 @@ grid.dendrogram(dend, facing = c("bottom", "top", "left", "right"), |
14 | 14 |
|
15 | 15 |
\item{dend}{a \code{\link[stats]{dendrogram}} object.} |
16 | 16 |
\item{facing}{facing of the dendrogram.} |
17 |
- \item{max_height}{maximum height of the dendrogram. It is useful to make dendrograms comparableif you want to plot more than one dendrograms.} |
|
17 |
+ \item{max_height}{maximum height of the dendrogram. It is useful to make dendrograms comparable if you want to plot more than one dendrograms.} |
|
18 | 18 |
\item{order}{should leaves of dendrogram be put in the normal order (1, ..., n) or reverse order (n, ..., 1)?} |
19 | 19 |
\item{...}{pass to \code{\link[grid]{viewport}} which contains the dendrogram.} |
20 | 20 |
|
... | ... |
@@ -13,7 +13,7 @@ ht_global_opt(..., RESET = FALSE, READ.ONLY = NULL) |
13 | 13 |
|
14 | 14 |
\item{...}{options, see 'details' section} |
15 | 15 |
\item{RESET}{reset all the option values} |
16 |
- \item{READ.ONLY}{\code{TRUE} means only to return read-only values, \code{FALSE} means only to return non-read-onlyvalues, \code{NULL} means to return both.} |
|
16 |
+ \item{READ.ONLY}{\code{TRUE} means only to return read-only values, \code{FALSE} means only to return non-read-only values, \code{NULL} means to return both.} |
|
17 | 17 |
|
18 | 18 |
} |
19 | 19 |
\details{ |
... | ... |
@@ -16,30 +16,30 @@ oncoPrint(mat, get_type = function(x) x, |
16 | 16 |
axis_gp = gpar(fontsize = 8), |
17 | 17 |
show_row_barplot = TRUE, |
18 | 18 |
row_barplot_width = unit(2, "cm"), |
19 |
- show_column_barplot = TRUE, |
|
20 |
- column_barplot_height = unit(2, "cm"), |
|
21 | 19 |
remove_empty_columns = FALSE, |
22 | 20 |
heatmap_legend_param = list(title = "Alterations"), |
21 |
+ top_annotation = HeatmapAnnotation(column_bar = anno_column_bar), |
|
22 |
+ top_annotation_height = unit(2, "cm"), |
|
23 | 23 |
...) |
24 | 24 |
} |
25 | 25 |
\arguments{ |
26 | 26 |
|
27 |
- \item{mat}{a character matrix which encodes mulitple alterations or a list of matrix for which every matrix contains binaryvalue representing the alteration is present or absent. When it is a list, the names represent alteration types.You can use \code{\link{unify_mat_list}} to make all matrix having same row names and column names.} |
|
28 |
- \item{get_type}{If different alterations are encoded in the matrix, this self-defined functiondetermines how to extract them. Only work when \code{mat} is a matrix.} |
|
29 |
- \item{alter_fun_list}{a list of functions which define how to add graphics for different alterations.The names of the list should cover all alteration types.} |
|
27 |
+ \item{mat}{a character matrix which encodes mulitple alterations or a list of matrix for which every matrix contains binary value representing the alteration is present or absent. When it is a list, the names represent alteration types. You can use \code{\link{unify_mat_list}} to make all matrix having same row names and column names.} |
|
28 |
+ \item{get_type}{If different alterations are encoded in the matrix, this self-defined function determines how to extract them. Only work when \code{mat} is a matrix.} |
|
29 |
+ \item{alter_fun_list}{a list of functions which define how to add graphics for different alterations. The names of the list should cover all alteration types.} |
|
30 | 30 |
\item{col}{a vector of color for which names correspond to alteration types.} |
31 |
- \item{row_order}{order of genes. By default it is sorted by frequency of alterations decreasingly.Set it to \code{NULL} if you don't want to set the order} |
|
32 |
- \item{column_order}{order of samples. By default the order is calculated by the 'memo sort' method which can visualizethe mutual exclusivity across genes.} |
|
31 |
+ \item{row_order}{order of genes. By default it is sorted by frequency of alterations decreasingly. Set it to \code{NULL} if you don't want to set the order} |
|
32 |
+ \item{column_order}{order of samples. By default the order is calculated by the 'memo sort' method which can visualize the mutual exclusivity across genes. Set it to \code{NULL} if you don't want to set the order} |
|
33 | 33 |
\item{show_column_names}{whether show column names} |
34 | 34 |
\item{pct_gp}{graphic paramters for percent row annotation} |
35 | 35 |
\item{axis_gp}{graphic paramters for axes} |
36 | 36 |
\item{show_row_barplot}{whether show barplot annotation on rows} |
37 | 37 |
\item{row_barplot_width}{width of barplot annotation on rows. It should be a \code{\link[grid]{unit}} object} |
38 |
- \item{show_column_barplot}{whether show barplot annotation on columns} |
|
39 |
- \item{column_barplot_height}{height of barplot annotatioin on columns. it should be a \code{\link[grid]{unit}} object.} |
|
40 | 38 |
\item{remove_empty_columns}{if there is no alteration in that sample, whether remove it on the heatmap} |
41 | 39 |
\item{heatmap_legend_param}{pass to \code{\link{Heatmap}}} |
42 |
- \item{...}{pass to \code{\link{Heatmap}}} |
|
40 |
+ \item{top_annotation}{by default the top annotation contains barplots representing frequency of mutations in every sample.} |
|
41 |
+ \item{top_annotation_height}{height of the top annotation, should be a \code{\link[grid]{unit}} object.} |
|
42 |
+ \item{...}{pass to \code{\link{Heatmap}}, so can set \code{bottom_annotation} here.} |
|
43 | 43 |
|
44 | 44 |
} |
45 | 45 |
\details{ |
... | ... |
@@ -10,13 +10,13 @@ Quickly visualize a data frame |
10 | 10 |
plotDataFrame(df, overlap = 0.25, nlevel = 30, show_row_names = TRUE, |
11 | 11 |
show_column_names = TRUE, group = NULL, group_names = names(group), |
12 | 12 |
main_heatmap = NULL, km = 1, split = NULL, cluster_rows = TRUE, |
13 |
- cluster_columns = TRUE, ...) |
|
13 |
+ cluster_columns = TRUE, row_order = NULL, ...) |
|
14 | 14 |
} |
15 | 15 |
\arguments{ |
16 | 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 treated as 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, because it doesn't make any sense to visualize a character vector or matrixthat contains huge number of unique elements through a heatmap.} |
|
18 |
+ \item{overlap}{how to group numeric columns. If the overlapping rate between the ranges in the current column and previous numeric column is larger than this value, the two columns are treated as 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 will be excluded, because it doesn't make any sense to visualize a character vector or matrix that contains huge number of unique elements through a heatmap.} |
|
20 | 20 |
\item{show_row_names}{whether show row names after the last heatmap if there are row names.} |
21 | 21 |
\item{show_column_names}{whether show column names for all heatmaps.} |
22 | 22 |
\item{group}{a list of index that defines the groupping.} |
... | ... |
@@ -26,6 +26,7 @@ plotDataFrame(df, overlap = 0.25, nlevel = 30, show_row_names = TRUE, |
26 | 26 |
\item{split}{one or multiple variables that split the rows.} |
27 | 27 |
\item{cluster_rows}{whether perform clustering on rows of the main heatmap.} |
28 | 28 |
\item{cluster_columns}{whether perform clustering on columns for all heatmaps.} |
29 |
+ \item{row_order}{order of rows, remember to turn off \code{cluster_rows}} |
|
29 | 30 |
\item{...}{pass to \code{\link{draw,HeatmapList-method}} or \code{\link{make_layout,HeatmapList-method}}} |
30 | 31 |
|
31 | 32 |
} |
... | ... |
@@ -232,7 +232,7 @@ ht_list = oncoPrint(mat, get_type = function(x) strsplit(x, ";")[[1]], |
232 | 232 |
heatmap_legend_param = list(title = "Alternations", at = c("AMP", "HOMDEL", "MUT"), |
233 | 233 |
labels = c("Amplification", "Deep deletion", "Mutation")), |
234 | 234 |
split = sample(letters[1:2], nrow(mat), replace = TRUE)) + |
235 |
-Heatmap(matrix(rnorm(nrow(mat)*10), ncol = 10), width = unit(4, "cm")) |
|
235 |
+Heatmap(matrix(rnorm(nrow(mat)*10), ncol = 10), name = "expr", width = unit(4, "cm")) |
|
236 | 236 |
draw(ht_list, row_sub_title_side = "left") |
237 | 237 |
``` |
238 | 238 |
|