Skip to content

Commit

Permalink
add stat argument in frequencyHeatmap()
Browse files Browse the repository at this point in the history
  • Loading branch information
jokergoo committed Mar 24, 2021
1 parent c6a77a8 commit 49e4fa6
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 36 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ComplexHeatmap
Type: Package
Title: Make Complex Heatmaps
Version: 2.7.9.1003
Version: 2.7.9.1004
Date: 2021-3-24
Author: Zuguang Gu
Maintainer: Zuguang Gu <[email protected]>
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('re_size', function(object, ...) standardGeneric('re_size'))
setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list'))
setGeneric('column_order', function(object, ...) standardGeneric('column_order'))
setGeneric('annotation_legend_size', function(object, ...) standardGeneric('annotation_legend_size'))
setGeneric('make_layout', function(object, ...) standardGeneric('make_layout'))
setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation'))
setGeneric('get_color_mapping_list', function(object, ...) standardGeneric('get_color_mapping_list'))
setGeneric('prepare', function(object, ...) standardGeneric('prepare'))
setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend'))
setGeneric('re_size', function(object, ...) standardGeneric('re_size'))
setGeneric('draw', function(object, ...) standardGeneric('draw'))
setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list'))
setGeneric('draw_title', function(object, ...) standardGeneric('draw_title'))
setGeneric('add_heatmap', function(object, ...) standardGeneric('add_heatmap'))
setGeneric('make_layout', function(object, ...) standardGeneric('make_layout'))
setGeneric('map_to_colors', function(object, ...) standardGeneric('map_to_colors'))
setGeneric('component_width', function(object, ...) standardGeneric('component_width'))
setGeneric('column_order', function(object, ...) standardGeneric('column_order'))
setGeneric('adjust_heatmap_list', function(object, ...) standardGeneric('adjust_heatmap_list'))
setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster'))
setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend'))
setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend'))
setGeneric('draw_dend', function(object, ...) standardGeneric('draw_dend'))
setGeneric('row_dend', function(object, ...) standardGeneric('row_dend'))
setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size'))
setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list'))
setGeneric('row_order', function(object, ...) standardGeneric('row_order'))
setGeneric('component_height', function(object, ...) standardGeneric('component_height'))
setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames'))
setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster'))
setGeneric('row_dend', function(object, ...) standardGeneric('row_dend'))
setGeneric('column_dend', function(object, ...) standardGeneric('column_dend'))
setGeneric('set_component_width', function(object, ...) standardGeneric('set_component_width'))
setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height'))
setGeneric('attach_annotation', function(object, ...) standardGeneric('attach_annotation'))
setGeneric('annotation_legend_size', function(object, ...) standardGeneric('annotation_legend_size'))
setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation'))
setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster'))
setGeneric('draw_title', function(object, ...) standardGeneric('draw_title'))
setGeneric('draw_heatmap_body', function(object, ...) standardGeneric('draw_heatmap_body'))
setGeneric('set_component_width', function(object, ...) standardGeneric('set_component_width'))
setGeneric('column_dend', function(object, ...) standardGeneric('column_dend'))
setGeneric('copy_all', function(object, ...) standardGeneric('copy_all'))
setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster'))
setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend'))
setGeneric('adjust_heatmap_list', function(object, ...) standardGeneric('adjust_heatmap_list'))
setGeneric('component_width', function(object, ...) standardGeneric('component_width'))
setGeneric('component_height', function(object, ...) standardGeneric('component_height'))
setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list'))
setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size'))
setGeneric('draw_dend', function(object, ...) standardGeneric('draw_dend'))
setGeneric('attach_annotation', function(object, ...) standardGeneric('attach_annotation'))
setGeneric('map_to_colors', function(object, ...) standardGeneric('map_to_colors'))
setGeneric('add_heatmap', function(object, ...) standardGeneric('add_heatmap'))
setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend'))
setGeneric('prepare', function(object, ...) standardGeneric('prepare'))
10 changes: 6 additions & 4 deletions R/densityHeatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ ks_dist_1 = function(data) {
#
# == param
# -data A matrix or a list. If it is a matrix, density is calculated by columns.
# -breaks Pass to `graphics::hist`.
# -breaks Pass to `graphics::hist`. Please only set equal bin size.
# -stat Statistic to use.
# -col A vector of colors that density values are mapped to.
# -color_space The color space in which colors are interpolated. Pass to `circlize::colorRamp2`.
# -ylab Label on y-axis.
Expand Down Expand Up @@ -470,7 +471,7 @@ frequencyHeatmap = function(data,


if(use_3d) {
ht = Heatmap3D(mat, col = col, name = "frequency",
ht = Heatmap3D(mat, col = col, name = stat,
column_title = title,
column_title_gp = title_gp,
cluster_rows = FALSE,
Expand All @@ -487,7 +488,7 @@ frequencyHeatmap = function(data,
...
)
} else {
ht = Heatmap(mat, col = col, name = "frequency",
ht = Heatmap(mat, col = col, name = stat,
column_title = title,
column_title_gp = title_gp,
cluster_rows = FALSE,
Expand Down Expand Up @@ -520,8 +521,9 @@ frequencyHeatmap = function(data,
grid.text(ylab, x = grobHeight(textGrob(ylab, gp = ylab_gp)), rot = 90)
}, slice = 1)

decorate_heatmap_body(paste0("frequency_", random_str), {
decorate_heatmap_body(paste0(stat, "_", random_str), {
pushViewport(viewport(yscale = c(min_x, max_x), clip = FALSE))
grid.segments(0, 0, 0, 1)
grid.yaxis(gp = tick_label_gp)
upViewport()
}, column_slice = 1)
Expand Down
2 changes: 2 additions & 0 deletions man/Heatmap3D.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Heatmap3D(matrix,
bar_max_length = unit(1, "cm"),
bar_angle = 60,

row_names_side = "left",
show_row_dend = FALSE,
show_column_dend = FALSE)
}
Expand All @@ -26,6 +27,7 @@ Heatmap3D(matrix,
\item{bar_rel_height}{A factor between 0 and 1.}
\item{bar_max_length}{Maximal length of bars. Value should be in absolute unit.}
\item{bar_angle}{Angle for the projection.}
\item{row_names_side}{Row names are by default put on the left side of the heatmap.}
\item{show_row_dend}{By default the dendrogram is not drawn.}
\item{show_column_dend}{By default the dendrogram is not drawn.}

Expand Down
2 changes: 1 addition & 1 deletion man/copy_all-dispatch.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Method dispatch page for \code{copy_all}.
\code{copy_all} can be dispatched on following classes:

\itemize{
\item \code{\link{copy_all,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method
\item \code{\link{copy_all,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method
\item \code{\link{copy_all,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method
}
}
\examples{
Expand Down
4 changes: 2 additions & 2 deletions man/draw-dispatch.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Method dispatch page for \code{draw}.

\itemize{
\item \code{\link{draw,Heatmap-method}}, \code{\link{Heatmap-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,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
\item \code{\link{draw,Legends-method}}, \code{\link{Legends-class}} class method
\item \code{\link{draw,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method
\item \code{\link{draw,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method
\item \code{\link{draw,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
}
}
Expand Down
4 changes: 3 additions & 1 deletion man/frequencyHeatmap.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Visualize Frequency Distribution by Heatmap
\usage{
frequencyHeatmap(data,
breaks = "Sturges",
stat = c("count", "density", "proportion"),

col = brewer.pal(9, "Blues"),
color_space = "LAB",
Expand Down Expand Up @@ -36,7 +37,8 @@ frequencyHeatmap(data,
\arguments{

\item{data}{A matrix or a list. If it is a matrix, density is calculated by columns.}
\item{breaks}{Pass to \code{\link[graphics]{hist}}.}
\item{breaks}{Pass to \code{\link[graphics]{hist}}. Please only set equal bin size.}
\item{stat}{Statistic to use.}
\item{col}{A vector of colors that density values are mapped to.}
\item{color_space}{The color space in which colors are interpolated. Pass to \code{\link[circlize]{colorRamp2}}.}
\item{ylab}{Label on y-axis.}
Expand Down
2 changes: 1 addition & 1 deletion man/row_dend-dispatch.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Method dispatch page for \code{row_dend}.
\code{row_dend} can be dispatched on following classes:

\itemize{
\item \code{\link{row_dend,Heatmap-method}}, \code{\link{Heatmap-class}} class method
\item \code{\link{row_dend,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
\item \code{\link{row_dend,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 @@ -11,11 +11,11 @@ Method dispatch page for \code{show}.

\itemize{
\item \code{\link{show,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method
\item \code{\link{show,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method
\item \code{\link{show,Heatmap-method}}, \code{\link{Heatmap-class}} class method
\item \code{\link{show,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
\item \code{\link{show,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-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,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method
}
}
\examples{
Expand Down

0 comments on commit 49e4fa6

Please sign in to comment.