Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
jokergoo committed Mar 31, 2023
1 parent 8975772 commit 772822f
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 36 deletions.
6 changes: 6 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
CHANGES in VERSION 2.15.3

* `Legend()`: `legend_gp` also controls line color, width and style.

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

CHANGES in VERSION 2.15.1

* `Legend()`: allows `NA` in `pch`.
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('row_dend', function(object, ...) standardGeneric('row_dend'))
setGeneric('column_dend', function(object, ...) standardGeneric('column_dend'))
setGeneric('re_size', function(object, ...) standardGeneric('re_size'))
setGeneric('draw_heatmap_body', function(object, ...) standardGeneric('draw_heatmap_body'))
setGeneric('add_heatmap', function(object, ...) standardGeneric('add_heatmap'))
setGeneric('draw', function(object, ...) standardGeneric('draw'))
setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation'))
setGeneric('column_dend', function(object, ...) standardGeneric('column_dend'))
setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster'))
setGeneric('component_width', function(object, ...) standardGeneric('component_width'))
setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list'))
setGeneric('attach_annotation', function(object, ...) standardGeneric('attach_annotation'))
setGeneric('prepare', function(object, ...) standardGeneric('prepare'))
setGeneric('map_to_colors', function(object, ...) standardGeneric('map_to_colors'))
setGeneric('adjust_heatmap_list', function(object, ...) standardGeneric('adjust_heatmap_list'))
setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames'))
setGeneric('draw_title', function(object, ...) standardGeneric('draw_title'))
setGeneric('row_dend', function(object, ...) standardGeneric('row_dend'))
setGeneric('make_layout', function(object, ...) standardGeneric('make_layout'))
setGeneric('draw_heatmap_body', function(object, ...) standardGeneric('draw_heatmap_body'))
setGeneric('component_height', function(object, ...) standardGeneric('component_height'))
setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster'))
setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height'))
setGeneric('make_layout', function(object, ...) standardGeneric('make_layout'))
setGeneric('attach_annotation', function(object, ...) standardGeneric('attach_annotation'))
setGeneric('add_heatmap', function(object, ...) standardGeneric('add_heatmap'))
setGeneric('column_order', function(object, ...) standardGeneric('column_order'))
setGeneric('copy_all', function(object, ...) standardGeneric('copy_all'))
setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend'))
setGeneric('draw_dend', function(object, ...) standardGeneric('draw_dend'))
setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation'))
setGeneric('draw_title', function(object, ...) standardGeneric('draw_title'))
setGeneric('prepare', function(object, ...) standardGeneric('prepare'))
setGeneric('get_color_mapping_list', function(object, ...) standardGeneric('get_color_mapping_list'))
setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend'))
setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list'))
setGeneric('map_to_colors', function(object, ...) standardGeneric('map_to_colors'))
setGeneric('column_order', function(object, ...) standardGeneric('column_order'))
setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size'))
setGeneric('row_order', function(object, ...) standardGeneric('row_order'))
setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend'))
setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list'))
setGeneric('get_color_mapping_list', function(object, ...) standardGeneric('get_color_mapping_list'))
setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames'))
setGeneric('re_size', function(object, ...) standardGeneric('re_size'))
setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list'))
setGeneric('draw_dend', function(object, ...) standardGeneric('draw_dend'))
setGeneric('annotation_legend_size', function(object, ...) standardGeneric('annotation_legend_size'))
setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster'))
setGeneric('row_order', function(object, ...) standardGeneric('row_order'))
setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size'))
setGeneric('component_width', function(object, ...) standardGeneric('component_width'))
setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend'))
setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height'))
setGeneric('set_component_width', function(object, ...) standardGeneric('set_component_width'))
10 changes: 7 additions & 3 deletions R/ColorMapping-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ setMethod(f = "map_to_colors",
# -nrow Pass to `Legend`. It controls the layout of legend grids if they are arranged in multiple rows or columns.
# -ncol Pass to `Legend`. It controls the layout of legend grids if they are arranged in multiple rows or columns.
# -by_row Pass to `Legend`. It controls the order of legend grids if they are arranged in multiple rows or columns.
# -legend_gp Graphic parameters for legend.
# -legend_height Height of the legend body. It only works when ``color_bar`` is ``continuous`` and ``direction`` is ``vertical``. Pass to `Legend`.
# -legend_width Width of the legend body. It only works when ``color_bar`` is ``continuous`` and ``direction`` is ``horizontal``. Pass to `Legend`.
# -legend_direction When ``color_bar`` is ``continuous``, whether the legend is vertical or horizontal? Pass to `Legend`.
Expand Down Expand Up @@ -300,6 +301,7 @@ setMethod(f = "color_mapping_legend",
nrow = NULL,
ncol = 1,
by_row = FALSE,
legend_gp = gpar(),
legend_height = NULL,
legend_width = NULL,
legend_direction = c("vertical", "horizontal"),
Expand Down Expand Up @@ -356,19 +358,21 @@ setMethod(f = "color_mapping_legend",
labels = rev(labels)
}
if(length(at) == 0) {
legend_gp$fill = object@na_col
gf = Legend(at = "NA", labels = "NA", name = object@name, title = title, title_gp = title_gp, grid_height = grid_height,
grid_width = grid_width, tick_length = tick_length, border = border, labels_gp = labels_gp, direction = legend_direction, nrow = nrow, ncol = ncol,
legend_gp = gpar(fill = object@na_col), title_position = title_position, by_row = by_row, graphics = graphics, break_dist = break_dist)
legend_gp = legend_gp, title_position = title_position, by_row = by_row, graphics = graphics, break_dist = break_dist)
} else {
legend_gp$fill = map_to_colors(object, at)
gf = Legend(at = at, labels = labels, name = object@name, title = title, title_gp = title_gp, grid_height = grid_height,
grid_width = grid_width, tick_length = tick_length, border = border, labels_gp = labels_gp, direction = legend_direction, nrow = nrow, ncol = ncol,
legend_gp = gpar(fill = map_to_colors(object, at)), title_position = title_position, by_row = by_row, graphics = graphics, break_dist = break_dist)
legend_gp = legend_gp, title_position = title_position, by_row = by_row, graphics = graphics, break_dist = break_dist)
}

} else {
gf = Legend(at = at, labels = labels, name = object@name, col_fun = object@col_fun, title = title, title_gp = title_gp, grid_height = grid_height,
grid_width = grid_width, tick_length = tick_length, border = border, labels_gp = labels_gp, labels_rot = labels_rot, direction = legend_direction,
legend_width = legend_width, legend_height = legend_height, title_position = title_position, by_row = by_row, break_dist = break_dist)
legend_gp = legend_gp, legend_width = legend_width, legend_height = legend_height, title_position = title_position, by_row = by_row, break_dist = break_dist)

}

Expand Down
3 changes: 3 additions & 0 deletions R/grid.Legend.R
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,9 @@ discrete_legend_body = function(at, labels = at, nrow = NULL, ncol = 1, by_row =
} else {
sgd2$fill = background
}
if(identical(legend_gp$col, "asis")) {
border = "asis"
}
if(identical(border, "asis")) {
sgd2$col = sgd2$fill
} else {
Expand Down
2 changes: 1 addition & 1 deletion man/add_heatmap-dispatch.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Method dispatch page for \code{add_heatmap}.

\itemize{
\item \code{\link{add_heatmap,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
\item \code{\link{add_heatmap,Heatmap-method}}, \code{\link{Heatmap-class}} class method
\item \code{\link{add_heatmap,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
\item \code{\link{add_heatmap,Heatmap-method}}, \code{\link{Heatmap-class}} class method
}
}
\examples{
Expand Down
2 changes: 2 additions & 0 deletions man/color_mapping_legend-ColorMapping-method.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Draw Legend Based on Color Mapping
nrow = NULL,
ncol = 1,
by_row = FALSE,
legend_gp = gpar(),
legend_height = NULL,
legend_width = NULL,
legend_direction = c("vertical", "horizontal"),
Expand Down Expand Up @@ -55,6 +56,7 @@ Draw Legend Based on Color Mapping
\item{nrow}{Pass to \code{\link{Legend}}. It controls the layout of legend grids if they are arranged in multiple rows or columns.}
\item{ncol}{Pass to \code{\link{Legend}}. It controls the layout of legend grids if they are arranged in multiple rows or columns.}
\item{by_row}{Pass to \code{\link{Legend}}. It controls the order of legend grids if they are arranged in multiple rows or columns.}
\item{legend_gp}{Graphic parameters for legend.}
\item{legend_height}{Height of the legend body. It only works when \code{color_bar} is \code{continuous} and \code{direction} is \code{vertical}. Pass to \code{\link{Legend}}.}
\item{legend_width}{Width of the legend body. It only works when \code{color_bar} is \code{continuous} and \code{direction} is \code{horizontal}. Pass to \code{\link{Legend}}.}
\item{legend_direction}{When \code{color_bar} is \code{continuous}, whether the legend is vertical or horizontal? Pass to \code{\link{Legend}}.}
Expand Down
2 changes: 1 addition & 1 deletion man/column_order-dispatch.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Method dispatch page for \code{column_order}.
\code{column_order} can be dispatched on following classes:

\itemize{
\item \code{\link{column_order,Heatmap-method}}, \code{\link{Heatmap-class}} class method
\item \code{\link{column_order,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
\item \code{\link{column_order,Heatmap-method}}, \code{\link{Heatmap-class}} class method
}
}
\examples{
Expand Down
6 changes: 3 additions & 3 deletions man/draw-dispatch.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Method dispatch page for \code{draw}.
\code{draw} can be dispatched on following classes:

\itemize{
\item \code{\link{draw,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method
\item \code{\link{draw,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
\item \code{\link{draw,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
\item \code{\link{draw,Legends-method}}, \code{\link{Legends-class}} class method
\item \code{\link{draw,Heatmap-method}}, \code{\link{Heatmap-class}} class method
\item \code{\link{draw,Legends-method}}, \code{\link{Legends-class}} class method
\item \code{\link{draw,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method
\item \code{\link{draw,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method
\item \code{\link{draw,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
}
}
\examples{
Expand Down
2 changes: 1 addition & 1 deletion man/draw_title-dispatch.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Method dispatch page for \code{draw_title}.
\code{draw_title} can be dispatched on following classes:

\itemize{
\item \code{\link{draw_title,Heatmap-method}}, \code{\link{Heatmap-class}} class method
\item \code{\link{draw_title,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
\item \code{\link{draw_title,Heatmap-method}}, \code{\link{Heatmap-class}} class method
}
}
\examples{
Expand Down
2 changes: 1 addition & 1 deletion man/make_layout-dispatch.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Method dispatch page for \code{make_layout}.
\code{make_layout} can be dispatched on following classes:

\itemize{
\item \code{\link{make_layout,Heatmap-method}}, \code{\link{Heatmap-class}} class method
\item \code{\link{make_layout,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
\item \code{\link{make_layout,Heatmap-method}}, \code{\link{Heatmap-class}} class method
}
}
\examples{
Expand Down
4 changes: 2 additions & 2 deletions man/show-dispatch.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Method dispatch page for \code{show}.
\code{show} can be dispatched on following classes:

\itemize{
\item \code{\link{show,ColorMapping-method}}, \code{\link{ColorMapping-class}} class method
\item \code{\link{show,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method
\item \code{\link{show,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
\item \code{\link{show,Heatmap-method}}, \code{\link{Heatmap-class}} class method
\item \code{\link{show,ColorMapping-method}}, \code{\link{ColorMapping-class}} class method
\item \code{\link{show,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
\item \code{\link{show,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method
\item \code{\link{show,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
}
}
\examples{
Expand Down

0 comments on commit 772822f

Please sign in to comment.