View source: R/func__visualisation__heatMapPAM.R
heatMapPAM | R Documentation |
To append a heatmap of a presence-absence matrix (PAM) to the right side of a phylogenetic tree. This function is modified from the function gheatmap in the R package ggtree (github.com/GuangchuangYu/ggtree) through replacing scale_fill_gradient with scale_fill_discrete. As a result, columns in the heat map can be coloured by group information. This function is useful when users need draw a heat map of gene or allele contents across strains.
For each entry in the PAM, this function assumes that the absence status is coded as zero and the presence status is coded as one.
heatMapPAM( p, data, col_colours = "black", null_colour = "grey90", presence_label = "Presence", absence_label = "Absence", border_colour = "white", cluster_cols = FALSE, cluster_method = "single", cluster_distance = "binary", rev_cols = FALSE, colnames = TRUE, colnames_position = "bottom", colnames_angle = 0, colnames_level = NULL, set_label_colours = FALSE, colnames_offset_x = 0, colnames_offset_y = 0, font.size = 4, hjust = 0.5, offset = 0, width = 1, show_legend = FALSE )
p |
A tree view from the function ggtree in the package ggtree |
data |
A binary presence-absence matrix (PAM) |
col_colours |
Either a vector of colour codes named by column names of the PAM, or a single colour code (for example, "red") for presence status in all columns. |
null_colour |
The colour for absence status. |
presence_label |
The label for presence status in the legend. Default: Presence. This parameter only works when col_colours equals a single colour code. |
absence_label |
The label for absence status in the legend. Default: Absence. This parameter also only works when col_colours equals a single colour code. |
border_colour |
Colour of heatmap cell border |
cluster_cols |
A logical argument determining if columns of PAM will be clustered or not. Default: FALSE. Clustering will not run when there are less than three columns in the PAM. |
cluster_method |
Method for clustering. Default: binary. |
cluster_distance |
The distance used for clustering columns. Default: binary. |
rev_cols |
A logical argument specifying whether to reverse the column order when it is necessary for a better visualisation. |
colnames |
Logical, add matrix colnames or not |
colnames_position |
One of 'bottom' or 'top' |
colnames_angle |
Angle of column names |
colnames_level |
Levels of colnames |
set_label_colours |
Whether colour column names in the same way as painting columns. By default, this option is turned off, which result in all column names to be printed in black. |
colnames_offset_x |
x offset for column names |
colnames_offset_y |
y offset for column names |
font.size |
Font size of matrix colnames |
hjust |
hjust for column names (0: align left, 0.5: align center, 1: align righ) |
offset |
Offset of heatmap to tree |
width |
Total width of heatmap, compare to width of tree |
show_legend |
A logical argument determining whether to show the legend. |
A list of three elements: p, a tree view that can be plotted directly; mapping: a data frame mapping allele names to colours; data, a data frame of weighted presence-absence status.
Guangchuang Yu, Yu Wan (wanyuac@126.com)
htmap <- heatMapPAM(...) plot(htmap$p)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.