R/heatmaps-sampleAnnotation.R
sampleAnnotation.Rd
Helper to specify a HeatmapAnnotation for samples in comp_heatmap
sampleAnnotation(
...,
name,
annotation_legend_param = list(),
show_legend = TRUE,
gp = grid::gpar(col = NA),
border = FALSE,
gap = grid::unit(2, "mm"),
show_annotation_name = TRUE,
annotation_label = NULL,
annotation_name_gp = grid::gpar(),
annotation_name_offset = NULL,
annotation_name_rot = NULL,
annotation_name_align = FALSE,
annotation_name_side = "auto",
.data = NULL,
.samples = NULL,
.side = NULL
)
Name-value pairs where the names correspond to annotation names and values are the output of sample annotation functions such as anno_sample(), or manually specified AnnotationFunction objects
Name of the heatmap annotation, optional.
A list which contains parameters for annotation legends. See color_mapping_legend,ColorMapping-method
for all possible options.
Whether show annotation legends. The value can be one single value or a vector.
Graphic parameters for simple annotations (with fill
parameter ignored).
border of single annotations.
Gap between annotations. It can be a single value or a vector of unit
objects.
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.
Labels for the annotations. By default it is the same as individual annotation names.
Graphic parameters for annotation names. Graphic parameters can be vectors.
Offset to the annotation names, a unit
object. The value can be a vector.
Rotation of the annotation names. The value can be a vector.
Whether to align the annotation names.
Side of the annotation names.
OPTIONAL phyloseq or psExtra, only set this to override use of same data as in heatmap
OPTIONAL selection vector of sample names, only set this if providing .data argument to override default
OPTIONAL string, indicating the side for the variable annotations: only set this to override default
HeatmapAnnotation object
library("ComplexHeatmap")
data("ibd", package = "microViz")
psq <- tax_filter(ibd, min_prevalence = 5)
psq <- tax_mutate(psq, Species = NULL)
psq <- tax_fix(psq)
psq <- tax_agg(psq, rank = "Family")
taxa <- tax_top(psq, n = 15, rank = "Family")
samples <- phyloseq::sample_names(psq)
set.seed(42) # random colours used in first example
# sampleAnnotation returns a function that takes data, samples, and which
fun <- sampleAnnotation(
gap = grid::unit(2.5, "mm"),
Dis1 = anno_sample(var = "DiseaseState"),
IBD = anno_sample_cat(var = "ibd"),
Dis2 = anno_sample_cat(var = "DiseaseState", col = 1:4)
)
# manually specify the sample annotation function by giving it data etc.
heatmapAnnoFunction <- fun(.data = psq, .side = "top", .samples = samples)
# draw the annotation without a heatmap, you will never normally do this!
grid.newpage()
vp <- viewport(width = 0.65, height = 0.75)
pushViewport(vp)
draw(heatmapAnnoFunction)
pushViewport(viewport(x = 0.7, y = 0.6))
draw(attr(heatmapAnnoFunction, "Legends"))