R/heatmaps-sampleAnnotation.R
anno_cat_legend.RdConvenience function for generating a legend for anno_cat annotations.
anno_cat_legend(col, x = NULL, renamer = identity, title = "", ...)vector of colors, named by all levels of data (e.g. x) or not named
optional: vector of data to pair with unnamed col or check against named col
function applied to generate labels: from names(col) or levels of x
title of legend
Arguments passed on to ComplexHeatmap::Legend
labelsLabels corresponding to at. If it is not specified, the values of at are taken as labels.
nrowFor legend which is represented as grids, nrow controls number of rows of the grids if the grids are arranged into multiple rows.
ncolSimilar as nrow, ncol controls number of columns of the grids if the grids are arranged into multiple columns. Note at a same time only one of nrow and ncol can be specified.
by_rowAre the legend grids arranged by rows or by columns?
grid_heightThe height of legend grid. It can also control the height of the continuous legend if it is horizontal.
grid_widthThe width of legend grid. It can also control the width of the continuous legend if it is vertical.
gapIf legend grids are put into multiple rows or columns, this controls the gap between neighbouring rows or columns, measured as a unit object.
labels_gpGraphic parameters for labels.
labels_rotText rotation for labels. It should only be used for horizontal continuous legend.
borderColor of legend grid borders. It also works for the ticks in the continuous legend.
typeType of legends. The value can be one of grid, points, lines and boxplot.
directionDirection of the legend, vertical or horizontal?
title_positionPosition of title relative to the legend. topleft, topcenter, leftcenter-rot and lefttop-rot are only for vertical legend and leftcenter, lefttop are only for horizontal legend.
title_gapGap between title and the legend body.
a ComplexHeatmap Legend class object
grid::grid.newpage()
ComplexHeatmap::draw(
anno_cat_legend(
col = c("ibd" = "blue", "nonibd" = "grey90"),
renamer = toupper, title = "Hi there, I'm a title"
)
)