Skip to content

Commit

Permalink
add max_density argument
Browse files Browse the repository at this point in the history
  • Loading branch information
jokergoo committed Jun 15, 2022
1 parent 5cefa67 commit c94e524
Show file tree
Hide file tree
Showing 147 changed files with 212 additions and 58 deletions.
46 changes: 23 additions & 23 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_color_mapping_list', function(object, ...) standardGeneric('get_color_mapping_list'))
setGeneric('component_height', function(object, ...) standardGeneric('component_height'))
setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster'))
setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend'))
setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation'))
setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list'))
setGeneric('draw_title', function(object, ...) standardGeneric('draw_title'))
setGeneric('row_order', function(object, ...) standardGeneric('row_order'))
setGeneric('row_dend', function(object, ...) standardGeneric('row_dend'))
setGeneric('draw_heatmap_body', function(object, ...) standardGeneric('draw_heatmap_body'))
setGeneric('make_layout', function(object, ...) standardGeneric('make_layout'))
setGeneric('get_color_mapping_list', function(object, ...) standardGeneric('get_color_mapping_list'))
setGeneric('draw_dend', function(object, ...) standardGeneric('draw_dend'))
setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend'))
setGeneric('draw', function(object, ...) standardGeneric('draw'))
setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend'))
setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend'))
setGeneric('prepare', function(object, ...) standardGeneric('prepare'))
setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list'))
setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster'))
setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation'))
setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster'))
setGeneric('component_height', function(object, ...) standardGeneric('component_height'))
setGeneric('add_heatmap', function(object, ...) standardGeneric('add_heatmap'))
setGeneric('column_order', function(object, ...) standardGeneric('column_order'))
setGeneric('set_component_width', function(object, ...) standardGeneric('set_component_width'))
setGeneric('component_width', function(object, ...) standardGeneric('component_width'))
setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames'))
setGeneric('column_dend', function(object, ...) standardGeneric('column_dend'))
setGeneric('attach_annotation', function(object, ...) standardGeneric('attach_annotation'))
setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list'))
setGeneric('copy_all', function(object, ...) standardGeneric('copy_all'))
setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height'))
setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size'))
setGeneric('draw_heatmap_body', function(object, ...) standardGeneric('draw_heatmap_body'))
setGeneric('map_to_colors', function(object, ...) standardGeneric('map_to_colors'))
setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster'))
setGeneric('re_size', function(object, ...) standardGeneric('re_size'))
setGeneric('annotation_legend_size', function(object, ...) standardGeneric('annotation_legend_size'))
setGeneric('component_width', function(object, ...) standardGeneric('component_width'))
setGeneric('copy_all', function(object, ...) standardGeneric('copy_all'))
setGeneric('column_order', function(object, ...) standardGeneric('column_order'))
setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list'))
setGeneric('draw_dend', function(object, ...) standardGeneric('draw_dend'))
setGeneric('prepare', function(object, ...) standardGeneric('prepare'))
setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames'))
setGeneric('adjust_heatmap_list', function(object, ...) standardGeneric('adjust_heatmap_list'))
setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height'))
setGeneric('row_order', function(object, ...) standardGeneric('row_order'))
setGeneric('attach_annotation', function(object, ...) standardGeneric('attach_annotation'))
setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend'))
setGeneric('set_component_width', function(object, ...) standardGeneric('set_component_width'))
setGeneric('row_dend', function(object, ...) standardGeneric('row_dend'))
setGeneric('add_heatmap', function(object, ...) standardGeneric('add_heatmap'))
25 changes: 20 additions & 5 deletions R/AnnotationFunction-function.R
Original file line number Diff line number Diff line change
Expand Up @@ -1958,6 +1958,8 @@ anno_histogram = function(x, which = c("column", "row"), n_breaks = 11,
# -type Type of graphics to represent density distribution. "lines" for normal density plot; "violine" for violin plot
# and "heatmap" for heatmap visualization of density distribution.
# -xlim Range on x-axis.
# -max_density Maximal density values in the plot. Normally you don't need to manually set it, but when you have multiple density annotations
# and you want to compare between them, you should manually set this argument to make density distributions are in a same scale.
# -heatmap_colors A vector of colors for interpolating density values.
# -joyplot_scale Relative height of density distribution. A value higher than 1 increases the height of the density
# distribution and the plot will represented as so-called "joyplot".
Expand Down Expand Up @@ -1986,7 +1988,7 @@ anno_histogram = function(x, which = c("column", "row"), n_breaks = 11,
# heatmap_colors = c("white", "orange"))
# draw(anno, test = "heatmap, colors")
anno_density = function(x, which = c("column", "row"),
type = c("lines", "violin", "heatmap"), xlim = NULL,
type = c("lines", "violin", "heatmap"), xlim = NULL, max_density = NULL,
heatmap_colors = rev(brewer.pal(name = "RdYlBu", n = 11)),
joyplot_scale = 1, border = TRUE, gp = gpar(fill = "#CCCCCC"),
axis = TRUE, axis_param = default_axis_param(which),
Expand Down Expand Up @@ -2044,16 +2046,29 @@ anno_density = function(x, which = c("column", "row"),

if(type == "lines") {
xscale = xscale + c(-0.025, 0.025)*(xscale[2] - xscale[1])
yscale = c(0, max(unlist(density_y)))
if(is.null(max_density)) {
yscale = c(0, max(unlist(density_y)))
} else {
yscale = c(0, max_density)
}
yscale[2] = yscale[2]*1.05
} else if(type == "violin") {
xscale = xscale + c(-0.025, 0.025)*(xscale[2] - xscale[1])
yscale = max(unlist(density_y))
if(is.null(max_density)) {
yscale = max(unlist(density_y))
} else {
yscale = max_density
}
yscale = c(-yscale*1.05, yscale*1.05)
} else if(type == "heatmap") {
yscale = c(0, 1)
min_y = min(unlist(density_y))
max_y = max(unlist(density_y))
if(is.null(max_density)) {
min_y = min(unlist(density_y))
max_y = max(unlist(density_y))
} else {
min_y = 0
max_y = max_density
}
col_fun = colorRamp2(seq(min_y, max_y,
length.out = length(heatmap_colors)), heatmap_colors)
}
Expand Down
1 change: 1 addition & 0 deletions man/AdditiveUnit-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ method and the \code{\%v\%v} method so that above three classes can be appended
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/AdditiveUnit.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/AnnotationFunction-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ See \code{\link{AnnotationFunction}} constructor for details.
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/ColorMapping-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/ComplexHeatmap-package.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ The complete reference of ComplexHeatmap package is available at \url{http://jok
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/Extract.gridtext.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ Internally used.
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/Heatmap-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/Heatmap.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/HeatmapAnnotation-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/HeatmapAnnotation.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/HeatmapList-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/HeatmapList.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/Legends.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/SingleAnnotation-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/add.AdditiveUnit.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/add_heatmap-Heatmap-method.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/add_heatmap-HeatmapAnnotation-method.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/add_heatmap-HeatmapList-method.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
3 changes: 2 additions & 1 deletion man/adjust_heatmap_list-HeatmapList-method.Rd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
\name{adjust_heatmap_list-HeatmapList-method}
\alias{adjust_heatmap_list,HeatmapList-method}
\alias{adjust_heatmap_list}
\title{
Adjust Heatmap List
}
Expand All @@ -23,8 +24,8 @@ This function is only for internal use.
\author{
Zuguang Gu <z.gu@dkfz.de>
}
\alias{adjust_heatmap_list}
\examples{
# There is no example
NULL

}
3 changes: 2 additions & 1 deletion man/anno_density.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Density Annotation
}
\usage{
anno_density(x, which = c("column", "row"),
type = c("lines", "violin", "heatmap"), xlim = NULL,
type = c("lines", "violin", "heatmap"), xlim = NULL, max_density = NULL,
heatmap_colors = rev(brewer.pal(name = "RdYlBu", n = 11)),
joyplot_scale = 1, border = TRUE, gp = gpar(fill = "#CCCCCC"),
axis = TRUE, axis_param = default_axis_param(which),
Expand All @@ -20,6 +20,7 @@ anno_density(x, which = c("column", "row"),
\item{which}{Whether it is a column annotation or a row annotation?}
\item{type}{Type of graphics to represent density distribution. "lines" for normal density plot; "violine" for violin plot and "heatmap" for heatmap visualization of density distribution.}
\item{xlim}{Range on x-axis.}
\item{max_density}{Maximal density values in the plot. Normally you don't need to manually set it, but when you have multiple density annotations and you want to compare between them, you should manually set this argument to make density distributions are in a same scale.}
\item{heatmap_colors}{A vector of colors for interpolating density values.}
\item{joyplot_scale}{Relative height of density distribution. A value higher than 1 increases the height of the density distribution and the plot will represented as so-called "joyplot".}
\item{border}{Wether draw borders of the annotation region?}
Expand Down
1 change: 1 addition & 0 deletions man/anno_link.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ This function is the same as \code{\link{anno_zoom}}. It links subsets of rows o
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/anno_oncoprint_barplot.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL
}
2 changes: 1 addition & 1 deletion man/anno_textbox.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ anno_textbox(align_to, text, background_gp = gpar(fill = "#DDDDDD", col = "#AAAA
}
\arguments{

\item{align_to}{It controls how the text boxes are aligned to the heatmap rows. The value can be a categorical vector which have the same length as heatmap rows, or a list of row indices.}
\item{align_to}{It controls how the text boxes are aligned to the heatmap rows. The value can be a categorical vector which have the same length as heatmap rows, or a list of row indices. It does not necessarily include all row indices.}
\item{text}{The corresponding texts. The value should be a list of texts. To control graphics parameters of texts in the boxes, The value of \code{text} can also be set as a list of data frames where the first column contains the text, from the second column contains graphics parameters for each text. The column names should be "col", "fontsize", "fontfamily" and "fontface".}
\item{background_gp}{Graphics for the background.}
\item{which}{Only "row" is allowed.}
Expand Down
3 changes: 2 additions & 1 deletion man/annotation_legend_size-HeatmapList-method.Rd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
\name{annotation_legend_size-HeatmapList-method}
\alias{annotation_legend_size,HeatmapList-method}
\alias{annotation_legend_size}
\title{
Size of the Annotation Legends
}
Expand Down Expand Up @@ -27,8 +28,8 @@ A \code{\link[grid]{unit}} object.
\author{
Zuguang Gu <z.gu@dkfz.de>
}
\alias{annotation_legend_size}
\examples{
# There is no example
NULL

}
2 changes: 1 addition & 1 deletion man/attach_annotation-Heatmap-method.Rd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
\name{attach_annotation-Heatmap-method}
\alias{attach_annotation,Heatmap-method}
\alias{attach_annotation}
\title{
Attach heatmap annotations to the heatmap
}
Expand Down Expand Up @@ -28,4 +29,3 @@ ha2 = HeatmapAnnotation(bar = letters[1:10])
ht = attach_annotation(ht, ha2)
ht
}
\alias{attach_annotation}
1 change: 1 addition & 0 deletions man/bin_genome.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ A \code{\link[GenomicRanges:GRanges-class]{GRanges}} object of the genomic bins.
\examples{
# There is no example
NULL

}
3 changes: 2 additions & 1 deletion man/color_mapping_legend-ColorMapping-method.Rd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
\name{color_mapping_legend-ColorMapping-method}
\alias{color_mapping_legend,ColorMapping-method}
\alias{color_mapping_legend}
\title{
Draw Legend Based on Color Mapping
}
Expand Down Expand Up @@ -69,8 +70,8 @@ A \code{\link{Legends-class}} object.
\author{
Zuguang Gu <z.gu@dkfz.de>
}
\alias{color_mapping_legend}
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/columnAnnotation.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/complement_size.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ If there is no complement set, it returns zero.
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/component_height-Heatmap-method.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/component_height-HeatmapList-method.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/component_width-Heatmap-method.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/component_width-HeatmapList-method.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

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

\itemize{
\item \code{\link{component_width,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
\item \code{\link{component_width,Heatmap-method}}, \code{\link{Heatmap-class}} class method
\item \code{\link{component_width,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
}
}
\examples{
Expand Down
1 change: 1 addition & 0 deletions man/copy_all-AnnotationFunction-method.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ The environment is at \code{object@var_env}.
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/copy_all-SingleAnnotation-method.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ it calls \code{\link{copy_all,AnnotationFunction-method}} to hard copy the varia
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/decorate_column_dend.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/decorate_column_names.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
1 change: 1 addition & 0 deletions man/decorate_column_title.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ Zuguang Gu <[email protected]>
\examples{
# There is no example
NULL

}
Loading

0 comments on commit c94e524

Please sign in to comment.