... | ... |
@@ -1,31 +1,31 @@ |
1 |
-setGeneric('row_order', function(object, ...) standardGeneric('row_order')) |
|
2 |
-setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster')) |
|
3 | 1 |
setGeneric('map_to_colors', function(object, ...) standardGeneric('map_to_colors')) |
2 |
+setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height')) |
|
3 |
+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')) |
|
4 | 6 |
setGeneric('make_layout', function(object, ...) standardGeneric('make_layout')) |
5 |
-setGeneric('row_dend', function(object, ...) standardGeneric('row_dend')) |
|
6 |
-setGeneric('prepare', function(object, ...) standardGeneric('prepare')) |
|
7 |
-setGeneric('component_width', function(object, ...) standardGeneric('component_width')) |
|
8 |
-setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend')) |
|
9 |
-setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list')) |
|
7 |
+setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size')) |
|
8 |
+setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list')) |
|
10 | 9 |
setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend')) |
11 |
-setGeneric('draw_heatmap_body', function(object, ...) standardGeneric('draw_heatmap_body')) |
|
12 |
-setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster')) |
|
13 |
-setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames')) |
|
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')) |
|
14 |
+setGeneric('row_dend', function(object, ...) standardGeneric('row_dend')) |
|
14 | 15 |
setGeneric('add_heatmap', function(object, ...) standardGeneric('add_heatmap')) |
15 |
-setGeneric('draw', function(object, ...) standardGeneric('draw')) |
|
16 | 16 |
setGeneric('set_component_width', function(object, ...) standardGeneric('set_component_width')) |
17 |
-setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height')) |
|
17 |
+setGeneric('column_order', function(object, ...) standardGeneric('column_order')) |
|
18 | 18 |
setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend')) |
19 |
+setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend')) |
|
20 |
+setGeneric('annotation_legend_size', function(object, ...) standardGeneric('annotation_legend_size')) |
|
21 |
+setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation')) |
|
22 |
+setGeneric('prepare', function(object, ...) standardGeneric('prepare')) |
|
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')) |
|
19 | 29 |
setGeneric('draw_dend', function(object, ...) standardGeneric('draw_dend')) |
20 |
-setGeneric('column_dend', function(object, ...) standardGeneric('column_dend')) |
|
21 | 30 |
setGeneric('adjust_heatmap_list', function(object, ...) standardGeneric('adjust_heatmap_list')) |
22 |
-setGeneric('re_size', function(object, ...) standardGeneric('re_size')) |
|
23 |
-setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list')) |
|
24 |
-setGeneric('component_height', function(object, ...) standardGeneric('component_height')) |
|
25 |
-setGeneric('draw_title', function(object, ...) standardGeneric('draw_title')) |
|
26 |
-setGeneric('column_order', function(object, ...) standardGeneric('column_order')) |
|
27 | 31 |
setGeneric('copy_all', function(object, ...) standardGeneric('copy_all')) |
28 |
-setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size')) |
|
29 |
-setGeneric('get_color_mapping_list', function(object, ...) standardGeneric('get_color_mapping_list')) |
|
30 |
-setGeneric('annotation_legend_size', function(object, ...) standardGeneric('annotation_legend_size')) |
|
31 |
-setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation')) |
... | ... |
@@ -555,6 +555,9 @@ anno_image = function(image, which = c("column", "row"), border = TRUE, |
555 | 555 |
# -facing Whether the axis faces to the outside of the annotation region or inside. Sometimes when |
556 | 556 |
# appending more than one heatmaps, the axes of column annotations of one heatmap might |
557 | 557 |
# overlap to the neighbouring heatmap, setting ``facing`` to ``inside`` may invoild it. |
558 |
+# -direction The direction of the axis. Value should be "normal" or "reverse". |
|
559 |
+# |
|
560 |
+# All the parameters are passed to `annotation_axis_grob` to construct an axis grob. |
|
558 | 561 |
# |
559 | 562 |
# == example |
560 | 563 |
# default_axis_param("column") |
... | ... |
@@ -566,7 +569,8 @@ default_axis_param = function(which) { |
566 | 569 |
labels_rot = ifelse(which == "column", 0, 90), |
567 | 570 |
gp = gpar(fontsize = 8), |
568 | 571 |
side = ifelse(which == "column", "left", "bottom"), |
569 |
- facing = "outside" |
|
572 |
+ facing = "outside", |
|
573 |
+ direction = "normal" |
|
570 | 574 |
) |
571 | 575 |
} |
572 | 576 |
|
... | ... |
@@ -600,9 +604,12 @@ construct_axis_grob = function(axis_param, which, data_scale) { |
600 | 604 |
axis_param$at = at |
601 | 605 |
axis_param$labels = at |
602 | 606 |
} |
607 |
+ |
|
603 | 608 |
if(is.null(axis_param$labels)) { |
604 | 609 |
axis_param$labels = axis_param$at |
605 | 610 |
} |
611 |
+ |
|
612 |
+ axis_param$scale = data_scale |
|
606 | 613 |
axis_grob = do.call(annotation_axis_grob, axis_param) |
607 | 614 |
return(axis_grob) |
608 | 615 |
} |
... | ... |
@@ -709,6 +716,10 @@ anno_points = function(x, which = c("column", "row"), border = TRUE, gp = gpar() |
709 | 716 |
|
710 | 717 |
n = length(index) |
711 | 718 |
|
719 |
+ if(axis_param$direction == "reverse") { |
|
720 |
+ value = data_scale[2] - value + data_scale[1] |
|
721 |
+ } |
|
722 |
+ |
|
712 | 723 |
pushViewport(viewport(xscale = data_scale, yscale = c(0.5, n+0.5))) |
713 | 724 |
if(is.matrix(value)) { |
714 | 725 |
for(i in seq_len(ncol(value))) { |
... | ... |
@@ -732,6 +743,10 @@ anno_points = function(x, which = c("column", "row"), border = TRUE, gp = gpar() |
732 | 743 |
column_fun = function(index, k = 1, N = 1) { |
733 | 744 |
|
734 | 745 |
n = length(index) |
746 |
+ |
|
747 |
+ if(axis_param$direction == "reverse") { |
|
748 |
+ value = data_scale[2] - value + data_scale[1] |
|
749 |
+ } |
|
735 | 750 |
|
736 | 751 |
pushViewport(viewport(yscale = data_scale, xscale = c(0.5, n+0.5))) |
737 | 752 |
if(is.matrix(value)) { |
... | ... |
@@ -903,6 +918,10 @@ anno_lines = function(x, which = c("column", "row"), border = TRUE, gp = gpar(), |
903 | 918 |
row_fun = function(index, k = 1, N = 1) { |
904 | 919 |
n = length(index) |
905 | 920 |
|
921 |
+ if(axis_param$direction == "reverse") { |
|
922 |
+ value = data_scale[2] - value + data_scale[1] |
|
923 |
+ } |
|
924 |
+ |
|
906 | 925 |
pushViewport(viewport(xscale = data_scale, yscale = c(0.5, n+0.5))) |
907 | 926 |
if(is.matrix(value)) { |
908 | 927 |
for(i in seq_len(ncol(value))) { |
... | ... |
@@ -950,6 +969,10 @@ anno_lines = function(x, which = c("column", "row"), border = TRUE, gp = gpar(), |
950 | 969 |
column_fun = function(index, k = 1, N = 1) { |
951 | 970 |
n = length(index) |
952 | 971 |
|
972 |
+ if(axis_param$direction == "reverse") { |
|
973 |
+ value = data_scale[2] - value + data_scale[1] |
|
974 |
+ } |
|
975 |
+ |
|
953 | 976 |
pushViewport(viewport(yscale = data_scale, xscale = c(0.5, n+0.5))) |
954 | 977 |
if(is.matrix(value)) { |
955 | 978 |
for(i in seq_len(ncol(value))) { |
... | ... |
@@ -1147,6 +1170,12 @@ anno_barplot = function(x, baseline = 0, which = c("column", "row"), border = TR |
1147 | 1170 |
row_fun = function(index, k = 1, N = 1) { |
1148 | 1171 |
n = length(index) |
1149 | 1172 |
|
1173 |
+ if(axis_param$direction == "reverse") { |
|
1174 |
+ value_origin = value |
|
1175 |
+ value = data_scale[2] - value + data_scale[1] |
|
1176 |
+ baseline = data_scale[2] - baseline + data_scale[1] |
|
1177 |
+ } |
|
1178 |
+ |
|
1150 | 1179 |
pushViewport(viewport(xscale = data_scale, yscale = c(0.5, n+0.5))) |
1151 | 1180 |
if(ncol(value) == 1) { |
1152 | 1181 |
width = value[index] - baseline |
... | ... |
@@ -1154,9 +1183,16 @@ anno_barplot = function(x, baseline = 0, which = c("column", "row"), border = TR |
1154 | 1183 |
grid.rect(x = x_coor, y = n - seq_along(index) + 1, width = abs(width), height = 1*bar_width, default.units = "native", gp = subset_gp(gp, index)) |
1155 | 1184 |
} else { |
1156 | 1185 |
for(i in seq_len(ncol(value))) { |
1157 |
- width = value[index, i] |
|
1158 |
- x_coor = rowSums(value[index, seq_len(i-1), drop = FALSE]) + width/2 |
|
1159 |
- grid.rect(x = x_coor, y = n - seq_along(index) + 1, width = abs(width), height = 1*bar_width, default.units = "native", gp = subset_gp(gp, i)) |
|
1186 |
+ if(axis_param$direction == "normal") { |
|
1187 |
+ width = abs(value[index, i]) |
|
1188 |
+ x_coor = rowSums(value[index, seq_len(i-1), drop = FALSE]) + width/2 |
|
1189 |
+ grid.rect(x = x_coor, y = n - seq_along(index) + 1, width = abs(width), height = 1*bar_width, default.units = "native", gp = subset_gp(gp, i)) |
|
1190 |
+ } else { |
|
1191 |
+ width = value_origin[index, i] # the original width |
|
1192 |
+ x_coor = rowSums(value_origin[index, seq_len(i-1), drop = FALSE]) + width/2 #distance to the right |
|
1193 |
+ x_coor = data_scale[2] - x_coor + data_scale[1] |
|
1194 |
+ grid.rect(x = x_coor, y = n - seq_along(index) + 1, width = abs(width), height = 1*bar_width, default.units = "native", gp = subset_gp(gp, i)) |
|
1195 |
+ } |
|
1160 | 1196 |
} |
1161 | 1197 |
} |
1162 | 1198 |
if(axis_param$side == "top") { |
... | ... |
@@ -1170,7 +1206,13 @@ anno_barplot = function(x, baseline = 0, which = c("column", "row"), border = TR |
1170 | 1206 |
} |
1171 | 1207 |
column_fun = function(index, k = 1, N = 1) { |
1172 | 1208 |
n = length(index) |
1173 |
- |
|
1209 |
+ |
|
1210 |
+ if(axis_param$direction == "reverse") { |
|
1211 |
+ value_origin = value |
|
1212 |
+ value = data_scale[2] - value + data_scale[1] |
|
1213 |
+ baseline = data_scale[2] - baseline + data_scale[1] |
|
1214 |
+ } |
|
1215 |
+ |
|
1174 | 1216 |
pushViewport(viewport(yscale = data_scale, xscale = c(0.5, n+0.5))) |
1175 | 1217 |
if(ncol(value) == 1) { |
1176 | 1218 |
height = value[index] - baseline |
... | ... |
@@ -1178,9 +1220,16 @@ anno_barplot = function(x, baseline = 0, which = c("column", "row"), border = TR |
1178 | 1220 |
grid.rect(y = y_coor, x = seq_along(index), height = abs(height), width = 1*bar_width, default.units = "native", gp = subset_gp(gp, index)) |
1179 | 1221 |
} else { |
1180 | 1222 |
for(i in seq_len(ncol(value))) { |
1181 |
- height = value[index, i] |
|
1182 |
- y_coor = rowSums(value[index, seq_len(i-1), drop = FALSE]) + height/2 |
|
1183 |
- grid.rect(y = y_coor, x = seq_along(index), height = abs(height), width = 1*bar_width, default.units = "native", gp = subset_gp(gp, i)) |
|
1223 |
+ if(axis_param$direction == "normal") { |
|
1224 |
+ height = value[index, i] |
|
1225 |
+ y_coor = rowSums(value[index, seq_len(i-1), drop = FALSE]) + height/2 |
|
1226 |
+ grid.rect(y = y_coor, x = seq_along(index), height = abs(height), width = 1*bar_width, default.units = "native", gp = subset_gp(gp, i)) |
|
1227 |
+ } else { |
|
1228 |
+ height = value_origin[index, i] |
|
1229 |
+ y_coor = rowSums(value_origin[index, seq_len(i-1), drop = FALSE]) + height/2 |
|
1230 |
+ y_coor = data_scale[2] - y_coor + data_scale[1] |
|
1231 |
+ grid.rect(y = y_coor, x = seq_along(index), height = abs(height), width = 1*bar_width, default.units = "native", gp = subset_gp(gp, i)) |
|
1232 |
+ } |
|
1184 | 1233 |
} |
1185 | 1234 |
} |
1186 | 1235 |
if(axis_param$side == "left") { |
... | ... |
@@ -1321,6 +1370,10 @@ anno_boxplot = function(x, which = c("column", "row"), border = TRUE, |
1321 | 1370 |
|
1322 | 1371 |
row_fun = function(index, k = 1, N = 1) { |
1323 | 1372 |
|
1373 |
+ if(axis_param$direction == "reverse") { |
|
1374 |
+ value = lapply(value, function(x) data_scale[2] - x + data_scale[1]) |
|
1375 |
+ } |
|
1376 |
+ |
|
1324 | 1377 |
n_all = length(value) |
1325 | 1378 |
value = value[index] |
1326 | 1379 |
boxplot_stats = boxplot(value, plot = FALSE)$stats |
... | ... |
@@ -1372,6 +1425,11 @@ anno_boxplot = function(x, which = c("column", "row"), border = TRUE, |
1372 | 1425 |
popViewport() |
1373 | 1426 |
} |
1374 | 1427 |
column_fun = function(index, k = 1, N = 1) { |
1428 |
+ |
|
1429 |
+ if(axis_param$direction == "reverse") { |
|
1430 |
+ value = lapply(value, function(x) data_scale[2] - x + data_scale[1]) |
|
1431 |
+ } |
|
1432 |
+ |
|
1375 | 1433 |
value = value[index] |
1376 | 1434 |
boxplot_stats = boxplot(value, plot = FALSE)$stats |
1377 | 1435 |
|
... | ... |
@@ -1524,6 +1582,10 @@ anno_histogram = function(x, which = c("column", "row"), n_breaks = 11, |
1524 | 1582 |
axis_grob = if(axis) construct_axis_grob(axis_param, which, xscale) else NULL |
1525 | 1583 |
|
1526 | 1584 |
row_fun = function(index, k = 1, N = 1) { |
1585 |
+ |
|
1586 |
+ if(axis_param$direction == "reverse") { |
|
1587 |
+ value = lapply(value, function(x) data_scale[2] - x + data_scale[1]) |
|
1588 |
+ } |
|
1527 | 1589 |
|
1528 | 1590 |
n_all = length(value) |
1529 | 1591 |
value = value[index] |
... | ... |
@@ -1550,6 +1612,10 @@ anno_histogram = function(x, which = c("column", "row"), n_breaks = 11, |
1550 | 1612 |
popViewport() |
1551 | 1613 |
} |
1552 | 1614 |
column_fun = function(index, k = 1, N = 1) { |
1615 |
+ |
|
1616 |
+ if(axis_param$direction == "reverse") { |
|
1617 |
+ value = lapply(value, function(x) data_scale[2] - x + data_scale[1]) |
|
1618 |
+ } |
|
1553 | 1619 |
|
1554 | 1620 |
n_all = length(value) |
1555 | 1621 |
value = value[index] |
... | ... |
@@ -1712,6 +1778,10 @@ anno_density = function(x, which = c("column", "row"), |
1712 | 1778 |
axis_grob = if(axis) construct_axis_grob(axis_param, which, xscale) else NULL |
1713 | 1779 |
|
1714 | 1780 |
row_fun = function(index, k = 1, N = 1) { |
1781 |
+ |
|
1782 |
+ if(axis_param$direction == "reverse") { |
|
1783 |
+ value = lapply(value, function(x) data_scale[2] - x + data_scale[1]) |
|
1784 |
+ } |
|
1715 | 1785 |
|
1716 | 1786 |
n = length(index) |
1717 | 1787 |
value = value[index] |
... | ... |
@@ -1766,6 +1836,10 @@ anno_density = function(x, which = c("column", "row"), |
1766 | 1836 |
popViewport() |
1767 | 1837 |
} |
1768 | 1838 |
column_fun = function(index, k = 1, N = 1) { |
1839 |
+ |
|
1840 |
+ if(axis_param$direction == "reverse") { |
|
1841 |
+ value = lapply(value, function(x) data_scale[2] - x + data_scale[1]) |
|
1842 |
+ } |
|
1769 | 1843 |
|
1770 | 1844 |
n_all = length(value) |
1771 | 1845 |
value = value[index] |
... | ... |
@@ -2145,6 +2219,10 @@ anno_joyplot = function(x, which = c("column", "row"), gp = gpar(fill = "#000000 |
2145 | 2219 |
|
2146 | 2220 |
row_fun = function(index, k = 1, N = 1) { |
2147 | 2221 |
|
2222 |
+ if(axis_param$direction == "reverse") { |
|
2223 |
+ value = lapply(value, function(x) data_scale[2] - x + data_scale[1]) |
|
2224 |
+ } |
|
2225 |
+ |
|
2148 | 2226 |
n_all = length(value) |
2149 | 2227 |
value = value[index] |
2150 | 2228 |
|
... | ... |
@@ -2178,6 +2256,10 @@ anno_joyplot = function(x, which = c("column", "row"), gp = gpar(fill = "#000000 |
2178 | 2256 |
} |
2179 | 2257 |
column_fun = function(index, k = 1, N = 1) { |
2180 | 2258 |
|
2259 |
+ if(axis_param$direction == "reverse") { |
|
2260 |
+ value = lapply(value, function(x) data_scale[2] - x + data_scale[1]) |
|
2261 |
+ } |
|
2262 |
+ |
|
2181 | 2263 |
n_all = length(value) |
2182 | 2264 |
value = value[index] |
2183 | 2265 |
|
... | ... |
@@ -2362,6 +2444,10 @@ anno_horizon = function(x, which = c("column", "row"), |
2362 | 2444 |
|
2363 | 2445 |
row_fun = function(index, k = 1, N = 1) { |
2364 | 2446 |
|
2447 |
+ if(axis_param$direction == "reverse") { |
|
2448 |
+ value = lapply(value, function(x) data_scale[2] - x + data_scale[1]) |
|
2449 |
+ } |
|
2450 |
+ |
|
2365 | 2451 |
n_all = length(value) |
2366 | 2452 |
value = value[index] |
2367 | 2453 |
|
... | ... |
@@ -8,7 +8,8 @@ |
8 | 8 |
# -gp Graphic parameters. |
9 | 9 |
# -side side of the axis of the annotation viewport. |
10 | 10 |
# -facing Facing of the axis. |
11 |
-# -direction direction of the axis. Value should be "normal" or "reverse". |
|
11 |
+# -direction Direction of the axis. Value should be "normal" or "reverse". |
|
12 |
+# -scale The data scale. If it is ``NULL``, it is inferred from current viewport. |
|
12 | 13 |
# |
13 | 14 |
# == value |
14 | 15 |
# A `grid::grob` object. |
... | ... |
@@ -129,7 +130,7 @@ |
129 | 130 |
# popViewport() |
130 | 131 |
# |
131 | 132 |
annotation_axis_grob = function(at = NULL, labels = at, labels_rot = 0, gp = gpar(), |
132 |
- side = "left", facing = "outside", direction = "normal") { |
|
133 |
+ side = "left", facing = "outside", direction = "normal", scale = NULL) { |
|
133 | 134 |
|
134 | 135 |
if(!side %in% c("left", "right", "top", "bottom")) { |
135 | 136 |
stop_wrap("`side` can only be in 'left', 'right', 'top' and 'bottom'.") |
... | ... |
@@ -141,10 +142,12 @@ annotation_axis_grob = function(at = NULL, labels = at, labels_rot = 0, gp = gpa |
141 | 142 |
stop_wrap("`direction` can only be in `normal` and `reverse`.") |
142 | 143 |
} |
143 | 144 |
|
144 |
- if(side %in% c("top", "bottom")) { |
|
145 |
- scale = current.viewport()$xscale |
|
146 |
- } else { |
|
147 |
- scale = current.viewport()$yscale |
|
145 |
+ if(is.null(scale)) { |
|
146 |
+ if(side %in% c("top", "bottom")) { |
|
147 |
+ scale = current.viewport()$xscale |
|
148 |
+ } else { |
|
149 |
+ scale = current.viewport()$yscale |
|
150 |
+ } |
|
148 | 151 |
} |
149 | 152 |
if(is.null(at)) { |
150 | 153 |
at = pretty_breaks(scale) |
... | ... |
@@ -10,9 +10,9 @@ Method dispatch page for \code{add_heatmap}. |
10 | 10 |
\code{add_heatmap} can be dispatched on following classes: |
11 | 11 |
|
12 | 12 |
\itemize{ |
13 |
+\item \code{\link{add_heatmap,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method |
|
13 | 14 |
\item \code{\link{add_heatmap,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
14 | 15 |
\item \code{\link{add_heatmap,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
15 |
-\item \code{\link{add_heatmap,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method |
|
16 | 16 |
} |
17 | 17 |
} |
18 | 18 |
\examples{ |
... | ... |
@@ -8,7 +8,7 @@ Grob for Annotation Axis |
8 | 8 |
} |
9 | 9 |
\usage{ |
10 | 10 |
annotation_axis_grob(at = NULL, labels = at, labels_rot = 0, gp = gpar(), |
11 |
- side = "left", facing = "outside") |
|
11 |
+ side = "left", facing = "outside", direction = "normal", scale = NULL) |
|
12 | 12 |
} |
13 | 13 |
\arguments{ |
14 | 14 |
|
... | ... |
@@ -18,6 +18,8 @@ annotation_axis_grob(at = NULL, labels = at, labels_rot = 0, gp = gpar(), |
18 | 18 |
\item{gp}{Graphic parameters.} |
19 | 19 |
\item{side}{side of the axis of the annotation viewport.} |
20 | 20 |
\item{facing}{Facing of the axis.} |
21 |
+ \item{direction}{Direction of the axis. Value should be "normal" or "reverse".} |
|
22 |
+ \item{scale}{The data scale. If it is \code{NULL}, it is inferred from current viewport.} |
|
21 | 23 |
|
22 | 24 |
} |
23 | 25 |
\value{ |
... | ... |
@@ -27,87 +29,114 @@ A \code{\link[grid:grid.grob]{grob}} object. |
27 | 29 |
gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, |
28 | 30 |
side = "left", facing = "outside") |
29 | 31 |
grid.newpage() |
30 |
-pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
32 |
+pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
33 |
+grid.rect() |
|
34 |
+grid.text('side = "left", facing = "outside"') |
|
31 | 35 |
grid.draw(gb) |
32 |
-grid.rect(x = unit(0, "npc"), width = grobWidth(gb), just = "right") |
|
33 | 36 |
popViewport() |
34 | 37 |
|
35 | 38 |
gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, |
36 | 39 |
side = "left", facing = "inside") |
37 | 40 |
grid.newpage() |
38 |
-pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
41 |
+pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
42 |
+grid.rect() |
|
43 |
+grid.text('side = "left", facing = "inside"') |
|
39 | 44 |
grid.draw(gb) |
40 |
-grid.rect(x = unit(0, "npc"), width = grobWidth(gb), just = "left") |
|
41 | 45 |
popViewport() |
42 | 46 |
|
43 | 47 |
gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, |
44 | 48 |
side = "right", facing = "outside") |
45 | 49 |
grid.newpage() |
46 |
-pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
50 |
+pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
51 |
+grid.rect() |
|
52 |
+grid.text('side = "right", facing = "outside"') |
|
47 | 53 |
grid.draw(gb) |
48 |
-grid.rect(x = unit(1, "npc"), width = grobWidth(gb), just = "left") |
|
49 | 54 |
popViewport() |
50 | 55 |
|
51 | 56 |
gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, |
52 | 57 |
side = "right", facing = "inside") |
53 | 58 |
grid.newpage() |
54 |
-pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
59 |
+pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
60 |
+grid.rect() |
|
61 |
+grid.text('side = "right", facing = "inside"') |
|
55 | 62 |
grid.draw(gb) |
56 |
-grid.rect(x = unit(1, "npc"), width = grobWidth(gb), just = "right") |
|
57 | 63 |
popViewport() |
58 | 64 |
|
59 |
-gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, |
|
65 |
+gb = annotation_axis_grob(at = 1:3, labels = month.name[1:3], labels_rot = 0, |
|
60 | 66 |
side = "top", facing = "outside") |
61 | 67 |
grid.newpage() |
62 |
-pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
68 |
+pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
69 |
+grid.rect() |
|
70 |
+grid.text('side = "top", facing = "outside"') |
|
63 | 71 |
grid.draw(gb) |
64 |
-grid.rect(y = unit(1, "npc"), height = grobHeight(gb), just = "bottom") |
|
65 | 72 |
popViewport() |
66 | 73 |
|
67 |
-gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 90, |
|
74 |
+gb = annotation_axis_grob(at = 1:3, labels = month.name[1:3], labels_rot = 90, |
|
68 | 75 |
side = "top", facing = "outside") |
69 | 76 |
grid.newpage() |
70 |
-pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
77 |
+pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
78 |
+grid.rect() |
|
79 |
+grid.text('side = "top", facing = "outside"') |
|
71 | 80 |
grid.draw(gb) |
72 |
-grid.rect(y = unit(1, "npc"), height = grobHeight(gb), just = "bottom") |
|
73 | 81 |
popViewport() |
74 | 82 |
|
75 |
-gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 45, |
|
83 |
+gb = annotation_axis_grob(at = 1:3, labels = month.name[1:3], labels_rot = 45, |
|
76 | 84 |
side = "top", facing = "outside") |
77 | 85 |
grid.newpage() |
78 |
-pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
86 |
+pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
87 |
+grid.rect() |
|
88 |
+grid.text('side = "top", facing = "outside"') |
|
79 | 89 |
grid.draw(gb) |
80 |
-grid.rect(y = unit(1, "npc"), height = grobHeight(gb), just = "bottom") |
|
81 | 90 |
popViewport() |
82 | 91 |
|
83 |
-gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, |
|
92 |
+gb = annotation_axis_grob(at = 1:3, labels = month.name[1:3], labels_rot = 0, |
|
84 | 93 |
side = "top", facing = "inside") |
85 | 94 |
grid.newpage() |
86 |
-pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
95 |
+pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
96 |
+grid.rect() |
|
97 |
+grid.text('side = "top", facing = "inside"') |
|
87 | 98 |
grid.draw(gb) |
88 |
-grid.rect(y = unit(1, "npc"), height = grobHeight(gb), just = "top") |
|
89 | 99 |
popViewport() |
90 | 100 |
|
91 |
-gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, |
|
101 |
+gb = annotation_axis_grob(at = 1:3, labels = month.name[1:3], labels_rot = 0, |
|
92 | 102 |
side = "bottom", facing = "outside") |
93 | 103 |
grid.newpage() |
94 |
-pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
104 |
+pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
105 |
+grid.rect() |
|
106 |
+grid.text('side = "bottom", facing = "outside"') |
|
95 | 107 |
grid.draw(gb) |
96 |
-grid.rect(y = unit(0, "npc"), height = grobHeight(gb), just = "top") |
|
97 | 108 |
popViewport() |
98 | 109 |
|
99 |
-gb = annotation_axis_grob(at = 1:5, labels = month.name[1:5], labels_rot = 0, |
|
110 |
+gb = annotation_axis_grob(at = 1:3, labels = month.name[1:3], labels_rot = 0, |
|
100 | 111 |
side = "bottom", facing = "inside") |
101 | 112 |
grid.newpage() |
102 |
-pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
113 |
+pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
114 |
+grid.rect() |
|
115 |
+grid.text('side = "bottom", facing = "inside"') |
|
103 | 116 |
grid.draw(gb) |
104 |
-grid.rect(y = unit(0, "npc"), height = grobHeight(gb), just = "bottom") |
|
105 | 117 |
popViewport() |
106 | 118 |
|
107 | 119 |
grid.newpage() |
108 |
-pushViewport(viewport(xscale = c(0, 6), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
120 |
+pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
109 | 121 |
gb = annotation_axis_grob(labels_rot = 0, side = "left", facing = "outside") |
122 |
+grid.rect() |
|
123 |
+grid.text('side = "left", facing = "outside"') |
|
124 |
+grid.draw(gb) |
|
125 |
+popViewport() |
|
126 |
+ |
|
127 |
+grid.newpage() |
|
128 |
+pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
129 |
+gb = annotation_axis_grob(side = "left", direction = "reverse") |
|
130 |
+grid.rect() |
|
131 |
+grid.text('side = "left", direction = "reverse') |
|
132 |
+grid.draw(gb) |
|
133 |
+popViewport() |
|
134 |
+ |
|
135 |
+grid.newpage() |
|
136 |
+pushViewport(viewport(xscale = c(0, 4), yscale = c(0, 6), width = 0.6, height = 0.6)) |
|
137 |
+gb = annotation_axis_grob(side = "bottom", direction = "reverse") |
|
138 |
+grid.rect() |
|
139 |
+grid.text('side = "bottom", directio = "reverse"') |
|
110 | 140 |
grid.draw(gb) |
111 |
-grid.rect(x = unit(0, "npc"), width = grobWidth(gb), just = "right") |
|
112 | 141 |
popViewport() |
113 | 142 |
} |
... | ... |
@@ -10,8 +10,8 @@ Method dispatch page for \code{column_dend}. |
10 | 10 |
\code{column_dend} can be dispatched on following classes: |
11 | 11 |
|
12 | 12 |
\itemize{ |
13 |
-\item \code{\link{column_dend,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
|
14 | 13 |
\item \code{\link{column_dend,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
14 |
+\item \code{\link{column_dend,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
|
15 | 15 |
} |
16 | 16 |
} |
17 | 17 |
\examples{ |
... | ... |
@@ -7,11 +7,12 @@ Sizes of the Combination sets |
7 | 7 |
Sizes of the Combination sets |
8 | 8 |
} |
9 | 9 |
\usage{ |
10 |
-comb_size(m) |
|
10 |
+comb_size(m, degree = NULL) |
|
11 | 11 |
} |
12 | 12 |
\arguments{ |
13 | 13 |
|
14 | 14 |
\item{m}{A combination matrix returned by \code{\link{make_comb_mat}}.} |
15 |
+ \item{degree}{degree of the intersection. The value can be a vector.} |
|
15 | 16 |
|
16 | 17 |
} |
17 | 18 |
\value{ |
... | ... |
@@ -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,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
|
14 | 13 |
\item \code{\link{component_width,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
14 |
+\item \code{\link{component_width,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
|
15 | 15 |
} |
16 | 16 |
} |
17 | 17 |
\examples{ |
... | ... |
@@ -24,7 +24,10 @@ There are following parameters for the annotation axis: |
24 | 24 |
\item{gp}{Graphc parameters of axis labels. The value should be a \code{\link[grid]{unit}} object.} |
25 | 25 |
\item{side}{If it is for column annotation, the value should only be one of \code{left} and \code{right}. If it is for row annotation, the value should only be one of \code{top} and \code{bottom}.} |
26 | 26 |
\item{facing}{Whether the axis faces to the outside of the annotation region or inside. Sometimes when appending more than one heatmaps, the axes of column annotations of one heatmap might overlap to the neighbouring heatmap, setting \code{facing} to \code{inside} may invoild it.} |
27 |
+ \item{direction}{The direction of the axis. Value should be "normal" or "reverse".} |
|
27 | 28 |
} |
29 |
+ |
|
30 |
+All the parameters are passed to \code{\link{annotation_axis_grob}} to construct an axis grob. |
|
28 | 31 |
} |
29 | 32 |
\examples{ |
30 | 33 |
default_axis_param("column") |
... | ... |
@@ -11,11 +11,11 @@ Method dispatch page for \code{draw}. |
11 | 11 |
|
12 | 12 |
\itemize{ |
13 | 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 |
|
14 | 15 |
\item \code{\link{draw,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method |
15 |
-\item \code{\link{draw,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
|
16 | 16 |
\item \code{\link{draw,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method |
17 |
-\item \code{\link{draw,Legends-method}}, \code{\link{Legends-class}} class method |
|
18 | 17 |
\item \code{\link{draw,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
18 |
+\item \code{\link{draw,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
|
19 | 19 |
} |
20 | 20 |
} |
21 | 21 |
\examples{ |
... | ... |
@@ -10,8 +10,8 @@ Method dispatch page for \code{draw_title}. |
10 | 10 |
\code{draw_title} can be dispatched on following classes: |
11 | 11 |
|
12 | 12 |
\itemize{ |
13 |
-\item \code{\link{draw_title,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
|
14 | 13 |
\item \code{\link{draw_title,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
14 |
+\item \code{\link{draw_title,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
|
15 | 15 |
} |
16 | 16 |
} |
17 | 17 |
\examples{ |
... | ... |
@@ -8,7 +8,7 @@ Draw Annotation Axis |
8 | 8 |
} |
9 | 9 |
\usage{ |
10 | 10 |
grid.annotation_axis(at = NULL, labels = at, labels_rot = 0, gp = gpar(), |
11 |
- side = "left", facing = "outside") |
|
11 |
+ side = "left", facing = "outside", direction = "normal") |
|
12 | 12 |
} |
13 | 13 |
\arguments{ |
14 | 14 |
|
... | ... |
@@ -18,6 +18,7 @@ grid.annotation_axis(at = NULL, labels = at, labels_rot = 0, gp = gpar(), |
18 | 18 |
\item{gp}{Graphic parameters.} |
19 | 19 |
\item{side}{side of the axis of the annotation viewport.} |
20 | 20 |
\item{facing}{Facing of the axis.} |
21 |
+ \item{direction}{direction of the axis. Value should be "normal" or "reverse".} |
|
21 | 22 |
|
22 | 23 |
} |
23 | 24 |
\details{ |
... | ... |
@@ -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,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
|
14 | 13 |
\item \code{\link{make_layout,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
14 |
+\item \code{\link{make_layout,Heatmap-method}}, \code{\link{Heatmap-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,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
|
14 | 13 |
\item \code{\link{row_order,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
14 |
+\item \code{\link{row_order,Heatmap-method}}, \code{\link{Heatmap-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,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method |
|
14 |
-\item \code{\link{show,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
|
15 | 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 |
|
16 | 15 |
\item \code{\link{show,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method |
16 |
+\item \code{\link{show,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method |
|
17 |
+\item \code{\link{show,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method |
|
17 | 18 |
\item \code{\link{show,Heatmap-method}}, \code{\link{Heatmap-class}} class method |
18 |
-\item \code{\link{show,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method |
|
19 | 19 |
} |
20 | 20 |
} |
21 | 21 |
\examples{ |
... | ... |
@@ -123,6 +123,12 @@ anno = anno_points(c(1:5, NA, 7:10)) |
123 | 123 |
draw(anno, test = "anno_points") |
124 | 124 |
|
125 | 125 |
|
126 |
+anno = anno_points(runif(10), axis_param = list(direction = "reverse"), ylim = c(0, 1)) |
|
127 |
+draw(anno, test = "anno_points") |
|
128 |
+ |
|
129 |
+anno = anno_points(runif(10), axis_param = list(direction = "reverse"), ylim = c(0, 1), which = "row") |
|
130 |
+draw(anno, test = "anno_points") |
|
131 |
+ |
|
126 | 132 |
##### test anno_lines ### |
127 | 133 |
anno = anno_lines(runif(10)) |
128 | 134 |
draw(anno, test = "anno_lines") |
... | ... |
@@ -146,6 +152,8 @@ draw(anno, test = "anno_lines, smooth, matrix, by row") |
146 | 152 |
anno = anno_lines(c(1:5, NA, 7:10)) |
147 | 153 |
draw(anno, test = "anno_lines") |
148 | 154 |
|
155 |
+anno = anno_lines(runif(10), axis_param = list(direction = "reverse")) |
|
156 |
+draw(anno, test = "anno_lines") |
|
149 | 157 |
|
150 | 158 |
###### test anno_text ####### |
151 | 159 |
anno = anno_text(month.name) |
... | ... |
@@ -199,6 +207,16 @@ draw(anno, test = "proportion matrix") |
199 | 207 |
anno = anno_barplot(c(1:5, NA, 7:10)) |
200 | 208 |
draw(anno, test = "a vector") |
201 | 209 |
|
210 |
+anno = anno_barplot(1:10, which = "row", axis_param = list(direction = "reverse")) |
|
211 |
+draw(anno, test = "a vector") |
|
212 |
+ |
|
213 |
+anno = anno_barplot(1:10, baseline = 5, which = "row", axis_param = list(direction = "reverse")) |
|
214 |
+draw(anno, test = "a vector") |
|
215 |
+ |
|
216 |
+anno = anno_barplot(matrix(nc = 2, c(1:10, 10:1)), which = "row", axis_param = list(direction = "reverse")) |
|
217 |
+draw(anno, test = "a vector") |
|
218 |
+ |
|
219 |
+ |
|
202 | 220 |
##### test anno_boxplot ##### |
203 | 221 |
set.seed(123) |
204 | 222 |
m = matrix(rnorm(100), 10) |