Skip to content

Commit

Permalink
add fontfamily/fontface to pheatmap()
Browse files Browse the repository at this point in the history
  • Loading branch information
jokergoo committed May 10, 2022
1 parent 230adc7 commit 18765bd
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 37 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('draw_dend', function(object, ...) standardGeneric('draw_dend'))
setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames'))
setGeneric('get_color_mapping_list', function(object, ...) standardGeneric('get_color_mapping_list'))
setGeneric('set_component_width', function(object, ...) standardGeneric('set_component_width'))
setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster'))
setGeneric('re_size', function(object, ...) standardGeneric('re_size'))
setGeneric('row_dend', function(object, ...) standardGeneric('row_dend'))
setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster'))
setGeneric('map_to_colors', function(object, ...) standardGeneric('map_to_colors'))
setGeneric('column_order', function(object, ...) standardGeneric('column_order'))
setGeneric('attach_annotation', function(object, ...) standardGeneric('attach_annotation'))
setGeneric('component_width', function(object, ...) standardGeneric('component_width'))
setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list'))
setGeneric('copy_all', function(object, ...) standardGeneric('copy_all'))
setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend'))
setGeneric('row_order', function(object, ...) standardGeneric('row_order'))
setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend'))
setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height'))
setGeneric('annotation_legend_size', function(object, ...) standardGeneric('annotation_legend_size'))
setGeneric('draw_heatmap_body', function(object, ...) standardGeneric('draw_heatmap_body'))
setGeneric('draw', function(object, ...) standardGeneric('draw'))
setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend'))
setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size'))
setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation'))
setGeneric('prepare', function(object, ...) standardGeneric('prepare'))
setGeneric('row_dend', function(object, ...) standardGeneric('row_dend'))
setGeneric('make_layout', function(object, ...) standardGeneric('make_layout'))
setGeneric('get_color_mapping_list', function(object, ...) standardGeneric('get_color_mapping_list'))
setGeneric('re_size', function(object, ...) standardGeneric('re_size'))
setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend'))
setGeneric('component_height', function(object, ...) standardGeneric('component_height'))
setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster'))
setGeneric('column_order', function(object, ...) standardGeneric('column_order'))
setGeneric('make_layout', function(object, ...) standardGeneric('make_layout'))
setGeneric('attach_annotation', function(object, ...) standardGeneric('attach_annotation'))
setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend'))
setGeneric('add_heatmap', function(object, ...) standardGeneric('add_heatmap'))
setGeneric('column_dend', function(object, ...) standardGeneric('column_dend'))
setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list'))
setGeneric('prepare', function(object, ...) standardGeneric('prepare'))
setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height'))
setGeneric('row_order', function(object, ...) standardGeneric('row_order'))
setGeneric('draw_dend', function(object, ...) standardGeneric('draw_dend'))
setGeneric('adjust_heatmap_list', function(object, ...) standardGeneric('adjust_heatmap_list'))
setGeneric('draw_title', function(object, ...) standardGeneric('draw_title'))
setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster'))
setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation'))
setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list'))
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('column_dend', function(object, ...) standardGeneric('column_dend'))
setGeneric('component_height', function(object, ...) standardGeneric('component_height'))
setGeneric('set_component_width', function(object, ...) standardGeneric('set_component_width'))
setGeneric('draw', function(object, ...) standardGeneric('draw'))
18 changes: 16 additions & 2 deletions R/pheatmap_translate.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
# -silent Not supported.
# -na_col The same as in `pheatmap::pheatmap`.
# -name Name of the heatmap. This argument is passed to `Heatmap`.
# -fontfamily Font family for row and column names.
# -fontfamily_row Font family for row names.
# -fontfamily_col Font family for column names.
# -fontface Font face for row and column names.
# -fontface_row Font face for row names.
# -fontface_col Font face for column names.
# -heatmap_legend_param Pass to `Heatmap`.
# -... Other arguments passed to `Heatmap`.
# -run_draw Whether to run ``draw()`` function to the heatmap object.
Expand Down Expand Up @@ -121,6 +127,14 @@ pheatmap = function(mat,
na_col = "#DDDDDD",
name = NULL,

# other graphic parameters for fonts
fontfamily = "",
fontfamily_row = fontfamily,
fontfamily_col = fontfamily,
fontface = 1,
fontface_row = fontface,
fontface_col = fontface,

# argument specific for Heatmap()
heatmap_legend_param = list(),
...,
Expand Down Expand Up @@ -361,8 +375,8 @@ pheatmap = function(mat,
ht_param$show_row_names = show_rownames
ht_param$show_column_names = show_colnames

ht_param$row_names_gp = gpar(fontsize = fontsize_row)
ht_param$column_names_gp = gpar(fontsize = fontsize_col)
ht_param$row_names_gp = gpar(fontsize = fontsize_row, fontfamily = fontfamily_row, fontface = fontface_row)
ht_param$column_names_gp = gpar(fontsize = fontsize_col, fontfamily = fontfamily_col, fontface = fontface_col)

angle_col = match.arg(angle_col)[1]
angle_col = switch(angle_col,
Expand Down
2 changes: 1 addition & 1 deletion man/HeatmapAnnotation.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ HeatmapAnnotation(...,
\item{gap}{Gap between annotations. It can be a single value or a vector of \code{\link[grid]{unit}} objects.}
\item{show_annotation_name}{Whether show annotation names? For column annotation, annotation names are drawn either on the left or the right, and for row annotations, names are draw either on top or at the bottom. The value can be a vector.}
\item{annotation_label}{Labels for the annotations. By default it is the same as individual annotation names.}
\item{annotation_name_gp}{Graphic parameters for annotation names. Graphic paramters can be vectors.}
\item{annotation_name_gp}{Graphic parameters for anntation names. Graphic paramters can be vectors.}
\item{annotation_name_offset}{Offset to the annotation names, a \code{\link[grid]{unit}} object. The value can be a vector.}
\item{annotation_name_side}{Side of the annotation names.}
\item{annotation_name_rot}{Rotation of the annotation names. The value can be a vector.}
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 @@ -10,9 +10,9 @@ Method dispatch page for \code{add_heatmap}.
\code{add_heatmap} can be dispatched on following classes:

\itemize{
\item \code{\link{add_heatmap,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
\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
}
}
\examples{
Expand Down
2 changes: 1 addition & 1 deletion man/color_mapping_legend-ColorMapping-method.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Draw Legend Based on Color Mapping
\item{border}{Color for legend grid borders. Pass to \code{\link{Legend}}.}
\item{at}{Break values of the legend. By default it is the levels in the \code{\link{ColorMapping-class}} object.}
\item{labels}{Labels corresponding to break values.}
\item{labels_gp}{Graphical parameters for legend labels.}
\item{labels_gp}{Graphcial parameters for legend labels.}
\item{labels_rot}{Rotation of labels.}
\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.}
Expand Down
2 changes: 1 addition & 1 deletion man/column_dend-dispatch.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Method dispatch page for \code{column_dend}.
\code{column_dend} can be dispatched on following classes:

\itemize{
\item \code{\link{column_dend,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
\item \code{\link{column_dend,Heatmap-method}}, \code{\link{Heatmap-class}} class method
\item \code{\link{column_dend,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
}
}
\examples{
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
2 changes: 1 addition & 1 deletion man/default_axis_param.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ There are following parameters for the annotation axis:
\item{at}{The breaks of axis. By default it is automatically inferred.}
\item{labels}{The corresponding axis labels.}
\item{labels_rot}{The rotation of the axis labels.}
\item{gp}{Graphic parameters of axis labels. The value should be a \code{\link[grid]{unit}} object.}
\item{gp}{Graphc parameters of axis labels. The value should be a \code{\link[grid]{unit}} object.}
\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}.}
\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.}
\item{direction}{The direction of the axis. Value should be "normal" or "reverse".}
Expand Down
4 changes: 2 additions & 2 deletions man/draw-dispatch.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Method dispatch page for \code{draw}.
\code{draw} can be dispatched on following classes:

\itemize{
\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,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-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,Heatmap-method}}, \code{\link{Heatmap-class}} class method
}
}
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
14 changes: 14 additions & 0 deletions man/pheatmap.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ pheatmap(mat,
na_col = "#DDDDDD",
name = NULL,

# other graphic parameters for fonts
fontfamily = "",
fontfamily_row = fontfamily,
fontfamily_col = fontfamily,
fontface = 1,
fontface_row = fontface,
fontface_col = fontface,

# argument specific for Heatmap()
heatmap_legend_param = list(),
...,
Expand Down Expand Up @@ -115,6 +123,12 @@ pheatmap(mat,
\item{silent}{Not supported.}
\item{na_col}{The same as in \code{\link[pheatmap]{pheatmap}}.}
\item{name}{Name of the heatmap. This argument is passed to \code{\link{Heatmap}}.}
\item{fontfamily}{Font family for row and column names.}
\item{fontfamily_row}{Font family for row names.}
\item{fontfamily_col}{Font family for column names.}
\item{fontface}{Font face for row and column names.}
\item{fontface_row}{Font face for row names.}
\item{fontface_col}{Font face for column names.}
\item{heatmap_legend_param}{Pass to \code{\link{Heatmap}}.}
\item{...}{Other arguments passed to \code{\link{Heatmap}}.}
\item{run_draw}{Whether to run \code{draw()} function to the heatmap object.}
Expand Down
6 changes: 3 additions & 3 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,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,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
\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,ColorMapping-method}}, \code{\link{ColorMapping-class}} class method
\item \code{\link{show,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
\item \code{\link{show,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
}
}
\examples{
Expand Down

0 comments on commit 18765bd

Please sign in to comment.