Image Annotation

anno_image(image, which = c("column", "row"), border = TRUE,
    gp = gpar(fill = NA, col = NA), space = unit(1, "mm"),
    width = NULL, height = NULL)

Arguments

image

A vector of file paths of images. The format of the image is inferred from the suffix name of the image file. NA values or empty strings in the vector means no image to drawn.

which

Whether it is a column annotation or a row annotation?

border

Wether draw borders of the annotation region?

gp

Graphic parameters for annotation grids. If the image has transparent background, the fill parameter can be used to control the background color in the annotation grids.

space

The space around the image to the annotation grid borders. The value should be a unit object.

width

Width of the annotation. The value should be an absolute unit. Width is not allowed to be set for column annotation.

height

Height of the annotation. The value should be an absolute unit. Height is not allowed to be set for row annotation.

Details

This function supports image formats in png, svg, pdf, eps, jpeg/jpg, tiff. png, jpeg/jpg and tiff images are imported by readPNG, readJPEG and readTIFF, and drawn by grid.raster. svg images are firstly reformatted by rsvg::rsvg_svg and then imported by readPicture and drawn by grid.picture. pdf and eps images are imported by PostScriptTrace and readPicture, later drawn by grid.picture.

Different image formats can be mixed in the image vector.

Value

An annotation function which can be used in HeatmapAnnotation.

See also

Examples

# download the free icons from https://github.com/Keyamoon/IcoMoon-Free # \dontrun{ image = sample(dir("~/Downloads/IcoMoon-Free-master/PNG/64px", full.names = TRUE), 10)
#> Error in sample.int(length(x), size, replace, prob): invalid first argument
anno = anno_image(image)
#> Warning: is.na() applied to non-(list or vector) of type 'closure'
#> Error in image[is.na(image)] <- "": object of type 'closure' is not subsettable
draw(anno, test = "png")
#> Error in draw(anno, test = "png"): object 'anno' not found
image[1:5] = ""
#> Error in image[1:5] = "": object of type 'closure' is not subsettable
anno = anno_image(image)
#> Warning: is.na() applied to non-(list or vector) of type 'closure'
#> Error in image[is.na(image)] <- "": object of type 'closure' is not subsettable
draw(anno, test = "some of png")
#> Error in draw(anno, test = "some of png"): object 'anno' not found
# }