Skip to content

Commit

Permalink
add show_name in anno_empty()
Browse files Browse the repository at this point in the history
  • Loading branch information
jokergoo committed Feb 3, 2022
1 parent 826b321 commit 8ed806b
Show file tree
Hide file tree
Showing 34 changed files with 1,067 additions and 146 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Date: 2021-11-08
Author: Zuguang Gu
Maintainer: Zuguang Gu <[email protected]>
Depends: R (>= 3.5.0), methods, grid, graphics, stats, grDevices
Imports: circlize (>= 0.4.5), GetoptLong, colorspace, clue,
Imports: circlize (>= 0.4.14), GetoptLong, colorspace, clue,
RColorBrewer, GlobalOptions (>= 0.1.0), png,
digest, IRanges, matrixStats, foreach, doParallel
Suggests: testthat (>= 1.0.0), knitr, markdown, dendsort,
Expand Down
8 changes: 8 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ S3method("heightDetails", "legend_body")
export("heightDetails.legend_body")
S3method("heightDetails", "packed_legends")
export("heightDetails.packed_legends")
S3method("heightDetails", "text_box")
export("heightDetails.text_box")
S3method("length", "HeatmapAnnotation")
export("length.HeatmapAnnotation")
S3method("length", "HeatmapList")
Expand Down Expand Up @@ -122,6 +124,8 @@ S3method("widthDetails", "legend_body")
export("widthDetails.legend_body")
S3method("widthDetails", "packed_legends")
export("widthDetails.packed_legends")
S3method("widthDetails", "text_box")
export("widthDetails.text_box")
export("%v%")
export("AdditiveUnit")
export("AnnotationFunction")
Expand Down Expand Up @@ -149,11 +153,13 @@ export("anno_joyplot")
export("anno_lines")
export("anno_link")
export("anno_mark")
export("anno_numeric")
export("anno_oncoprint_barplot")
export("anno_points")
export("anno_simple")
export("anno_summary")
export("anno_text")
export("anno_text_box")
export("anno_zoom")
export("annotation_axis_grob")
export("bar3D")
Expand Down Expand Up @@ -193,6 +199,7 @@ export("getXY_in_parent_vp")
export("grid.annotation_axis")
export("grid.boxplot")
export("grid.dendrogram")
export("grid.text_box")
export("gt_render")
export("ht_global_opt")
export("ht_opt")
Expand Down Expand Up @@ -228,6 +235,7 @@ export("subset_matrix_by_row")
export("subset_no")
export("subset_vector")
export("test_alter_fun")
export("text_box_grob")
export("unify_mat_list")
export("upset_left_annotation")
export("upset_right_annotation")
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ CHANGES in VERSION 2.11.1
* add a global option `ht_opt$COLOR` to control colors for continuous color mapping.
* `annotation_label` can be an `expression` object.
* `recycle_gp()`: now consider when n = 0.
* `anno_block()`: add `align_to` argument.
* add `anno_text_box()` and `grid.text_box()`.
* add `show_name` argument in `anno_empty()`.

=========================

Expand Down
48 changes: 24 additions & 24 deletions R/00_S4_generic_methods.R
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
setGeneric('set_component_width', function(object, ...) standardGeneric('set_component_width'))
setGeneric('annotation_legend_size', function(object, ...) standardGeneric('annotation_legend_size'))
setGeneric('re_size', function(object, ...) standardGeneric('re_size'))
setGeneric('component_height', function(object, ...) standardGeneric('component_height'))
setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list'))
setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster'))
setGeneric('draw', function(object, ...) standardGeneric('draw'))
setGeneric('component_width', function(object, ...) standardGeneric('component_width'))
setGeneric('column_dend', function(object, ...) standardGeneric('column_dend'))
setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames'))
setGeneric('draw_title', function(object, ...) standardGeneric('draw_title'))
setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation'))
setGeneric('attach_annotation', function(object, ...) standardGeneric('attach_annotation'))
setGeneric('add_heatmap', function(object, ...) standardGeneric('add_heatmap'))
setGeneric('row_order', function(object, ...) standardGeneric('row_order'))
setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend'))
setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster'))
setGeneric('column_dend', function(object, ...) standardGeneric('column_dend'))
setGeneric('get_color_mapping_list', function(object, ...) standardGeneric('get_color_mapping_list'))
setGeneric('draw_heatmap_body', function(object, ...) standardGeneric('draw_heatmap_body'))
setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list'))
setGeneric('map_to_colors', function(object, ...) standardGeneric('map_to_colors'))
setGeneric('draw_dend', function(object, ...) standardGeneric('draw_dend'))
setGeneric('make_layout', function(object, ...) standardGeneric('make_layout'))
setGeneric('attach_annotation', function(object, ...) standardGeneric('attach_annotation'))
setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend'))
setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list'))
setGeneric('component_height', function(object, ...) standardGeneric('component_height'))
setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height'))
setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend'))
setGeneric('row_dend', function(object, ...) standardGeneric('row_dend'))
setGeneric('draw_dend', function(object, ...) standardGeneric('draw_dend'))
setGeneric('set_component_width', function(object, ...) standardGeneric('set_component_width'))
setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation'))
setGeneric('annotation_legend_size', function(object, ...) standardGeneric('annotation_legend_size'))
setGeneric('column_order', function(object, ...) standardGeneric('column_order'))
setGeneric('map_to_colors', function(object, ...) standardGeneric('map_to_colors'))
setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster'))
setGeneric('draw_heatmap_body', function(object, ...) standardGeneric('draw_heatmap_body'))
setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size'))
setGeneric('re_size', function(object, ...) standardGeneric('re_size'))
setGeneric('adjust_heatmap_list', function(object, ...) standardGeneric('adjust_heatmap_list'))
setGeneric('component_width', function(object, ...) standardGeneric('component_width'))
setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster'))
setGeneric('draw_title', function(object, ...) standardGeneric('draw_title'))
setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend'))
setGeneric('prepare', function(object, ...) standardGeneric('prepare'))
setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height'))
setGeneric('column_order', function(object, ...) standardGeneric('column_order'))
setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames'))
setGeneric('copy_all', function(object, ...) standardGeneric('copy_all'))
setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list'))
setGeneric('row_order', function(object, ...) standardGeneric('row_order'))
setGeneric('adjust_heatmap_list', function(object, ...) standardGeneric('adjust_heatmap_list'))
setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend'))
setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend'))
32 changes: 16 additions & 16 deletions R/AnnotationFunction-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ AnnotationFunction = setClass("AnnotationFunction",
var_env = "environment",
fun = "function",
subset_rule = "list",
subsetable = "logical",
subsettable = "logical",
data_scale = "numeric",
extended = "ANY",
show_name = "logical"
Expand All @@ -34,7 +34,7 @@ AnnotationFunction = setClass("AnnotationFunction",
width = unit(1, "npc"),
height = unit(1, "npc"),
subset_rule = list(),
subsetable = FALSE,
subsettable = FALSE,
data_scale = c(0, 1),
n = NA_integer_,
extended = unit(c(0, 0, 0, 0), "mm"),
Expand Down Expand Up @@ -92,8 +92,8 @@ anno_width_and_height = function(which, width = NULL, height = NULL,
# -data_scale The data scale on the data axis (y-axis for column annotation and x-axis for row annotation). It is only used
# when `decorate_annotation` is used with "native" unit coordinates.
# -subset_rule The rule of subsetting variables in ``var_import``. It should be set when users want the final object to
# be subsetable. See **Details** section.
# -subsetable Whether the object is subsetable?
# be subsettable. See **Details** section.
# -subsettable Whether the object is subsettable?
# -show_name It is used to turn off the drawing of annotation names in `HeatmapAnnotation`. Annotations always have names
# associated and normally they will be drawn beside the annotation graphics to tell what the annotation is about.
# e.g. the annotation names put beside the points annotation graphics. However, for some of the annotations, the names
Expand Down Expand Up @@ -133,15 +133,15 @@ anno_width_and_height = function(which, width = NULL, height = NULL,
# },
# var_import = list(x = x),
# n = 10,
# subsetable = TRUE,
# subsettable = TRUE,
# height = unit(2, "cm")
# )
# m = rbind(1:10, 11:20)
# Heatmap(m, top_annotation = HeatmapAnnotation(foo = anno1))
# Heatmap(m, top_annotation = HeatmapAnnotation(foo = anno1), column_km = 2)
AnnotationFunction = function(fun, fun_name = "", which = c("column", "row"), cell_fun = NULL,
var_import = list(), n = NA, data_scale = c(0, 1), subset_rule = list(),
subsetable = length(subset_rule) > 0, show_name = TRUE, width = NULL, height = NULL) {
subsettable = length(subset_rule) > 0, show_name = TRUE, width = NULL, height = NULL) {

which = match.arg(which)[1]

Expand Down Expand Up @@ -183,7 +183,7 @@ AnnotationFunction = function(fun, fun_name = "", which = c("column", "row"), ce
}
}
}
subsetable = TRUE
subsettable = TRUE
}

if(length(var_import)) {
Expand Down Expand Up @@ -232,13 +232,13 @@ AnnotationFunction = function(fun, fun_name = "", which = c("column", "row"), ce
}
}

if(missing(subsetable)) {
if(missing(subsettable)) {
# is user defined subset rule
if(length(anno@subset_rule)) {
anno@subsetable = TRUE
anno@subsettable = TRUE
}
} else {
anno@subsetable = subsetable
anno@subsettable = subsettable
}

return(anno)
Expand All @@ -263,8 +263,8 @@ AnnotationFunction = function(fun, fun_name = "", which = c("column", "row"), ce
if(nargs() == 1) {
return(x)
} else {
if(!x@subsetable) {
stop_wrap("This object is not subsetable.")
if(!x@subsettable) {
stop_wrap("This object is not subsettable.")
}
x = copy_all(x)
if(x@fun_name == "anno_mark") {
Expand Down Expand Up @@ -425,12 +425,12 @@ setMethod(f = "show",
var_imported = names(object@var_env)
if(length(var_imported)) {
cat(" imported variable:", paste(var_imported, collapse = ", "), "\n")
var_subsetable = names(object@subset_rule)
if(length(var_subsetable)) {
cat(" subsetable variable:", paste(var_subsetable, collapse = ", "), "\n")
var_subsettable = names(object@subset_rule)
if(length(var_subsettable)) {
cat(" subsettable variable:", paste(var_subsettable, collapse = ", "), "\n")
}
}
cat(" this object is ", ifelse(object@subsetable, "", "not "), "subsetable\n", sep = "")
cat(" this object is ", ifelse(object@subsettable, "", "not "), "subsettable\n", sep = "")
dirt = c("bottom", "left", "top", "right")
for(i in 1:4) {
if(!identical(unit(0, "mm"), object@extended[i])) {
Expand Down
Loading

0 comments on commit 8ed806b

Please sign in to comment.