SingleAnnotation {ComplexHeatmap} | R Documentation |
Constructor method for SingleAnnotation class
SingleAnnotation(name, value, col, fun, na_col = "grey", which = c("column", "row"), show_legend = TRUE, gp = gpar(col = NA), legend_param = list(), show_name = FALSE, name_gp = gpar(fontsize = 12), name_offset = unit(2, "mm"), name_side = ifelse(which == "column", "right", "bottom"), name_rot = ifelse(which == "column", 0, 90))
name |
name for this annotation. If it is not specified, an internal name is assigned. |
value |
A vector of discrete or continuous annotation. |
col |
colors corresponding to |
fun |
a self-defined function to add annotation graphics. The argument of this function should only be a vector of index that corresponds to rows or columns. |
na_col |
color for |
which |
is the annotation a row annotation or a column annotation? |
show_legend |
if it is a simple annotation, whether show legend when making the complete heatmap. |
gp |
Since simple annotation is represented as a row of grids. This argument controls graphic parameters for the simple annotation. |
legend_param |
parameters for the legend. See |
show_name |
whether show annotation name |
name_gp |
graphic parameters for annotation name |
name_offset |
offset to the annotation, a |
name_side |
'right' and 'left' for column annotations and 'top' and 'bottom' for row annotations |
name_rot |
rotation of the annotation name, can only take values in |
The most simple annotation is one row or one column grids in which different colors
represent different classes of the data. Here the function use ColorMapping-class
to process such simple annotation. value
and col
arguments controls values and colors
of the simple annotation and a ColorMapping-class
object will be constructed based on value
and col
.
fun
is used to construct a more complex annotation. Users can add any type of annotation graphics
by implementing a function. The only input argument of fun
is a index
of rows or columns which is already adjusted by the clustering. In the package, there are already
several annotation graphic function generators: anno_points
, anno_histogram
and anno_boxplot
.
In the case that row annotations are splitted by rows, index
corresponding to row orders in each row-slice
and fun
will be applied on each of the row slices.
One thing that users should be careful is the difference of coordinates when the annotation is a row annotation or a column annotation.
A SingleAnnotation-class
object.
Zuguang Gu <z.gu@dkfz.de>
There are following built-in annotation functions that can be used to generate complex annotations:
anno_points
, anno_barplot
, anno_histogram
, anno_boxplot
, anno_density
, anno_text
and anno_link
.
# discrete character SingleAnnotation(name = "test", value = c("a", "a", "a", "b", "b", "b")) SingleAnnotation(name = "test", value = c("a", "a", "a", "b", "b", "b"), which = "row") # with defined colors SingleAnnotation(value = c("a", "a", "a", "b", "b", "b"), col = c("a" = "red", "b" = "blue")) # continuous numbers require(circlize) SingleAnnotation(value = 1:10) SingleAnnotation(value = 1:10, col = colorRamp2(c(1, 10), c("blue", "red"))) # self-defined graphic function SingleAnnotation(fun = anno_points(1:10))