geom_cladelab: geom_cladelab

Description Usage Arguments Aesthetics For Specified Geom Examples

View source: R/geom_cladelab.R

Description

annotate a clade with bar and text label or (image)

Usage

1
2
3
4
5
6
7
8
9
geom_cladelab(
  node = NULL,
  label = NULL,
  data = NULL,
  mapping = NULL,
  geom = "text",
  parse = FALSE,
  ...
)

Arguments

node

selected node to annotate, when data and mapping is NULL, it is required.

label

character, character to be showed, when data and mapping is NULL, it is required.

data

data.frame, the data to be displayed in the annotation, default is NULL.

mapping

Set of aesthetic mappings, default is NULL. The detail see the following explanation.

geom

character, one of 'text', 'label', 'shadowtext', 'image' and 'phylopic', default is 'text', and the parameter see the Aesthetics For Specified Geom.

parse

logical, whether parse label to emoji font, default is FALSE.

...

additional parameters, see also following section.

additional parameters can refer the following parameters.

  • offset distance bar and tree, offset of bar and text from the clade, default is 0.

  • offset.text distance bar and text, offset of text from bar, default is 0.

  • align logical, whether align clade lab, default is FALSE.

  • extend numeric, extend the length of bar, default is 0.

  • angle numeric or 'auto', if angle is auto, the angle of text will be calculated automatically, which is useful for the circular etc layout, default is 0.

  • horizontal logical, whether set label to horizontal, default is TRUE.

  • barsize the width of line, default is 0.5.

  • barcolour the colour of line, default is 'black'.

  • fontsize the size of text, default is 3.88.

  • textcolour the colour of text, default is 'black'.

  • imagesize the size of image, default is 0.05.

  • imagecolor the colour of image, default is NULL, when geom="phylopic", it should be required.

The parameters also can be set in mapping, when data is provided. Note: the barsize, barcolour, fontsize, textcolour, imagesize and imagecolor should not be set in mapping (aesthetics). When the color and size are not be set in mapping, user can modify them to adjust the attributes of specified geom.

Aesthetics For Specified Geom

geom_cladelab() understands the following aesthetics for geom="text"(required aesthetics are in bold):

when the colour, size are not be set in mapping, and user want to modify the colour of text, they should use textcolour, fontsize to avoid the confusion with bar layer annotation.

geom_cladelab() understands the following aesthethics for geom="label" (required aesthetics are in bold):

when the colour, size are not be set in mapping, and user want to modify the colour of text, they should use textcolour, fontsize to avoid the confusion with bar layer annotation.

geom_cladelab() understands the following aesthethics for geom="shadowtext" (required aesthetics are in bold):

when the colour, size are not be set in mapping, and user want to modify the colour of text, they should use textcolour, fontsize to avoid the confusion with bar layer annotation.

geom_cladelab() understands the following aesthethics for geom="image" or geom="phylopic" (required aesthetics are in bold):

when the colour, size are not be set in mapping, and user want to modify the colour of image, they should use imagecolour, imagesize to avoid the confusion with bar layer annotation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
set.seed(2015-12-21)
tree <- rtree(30)
data <- data.frame(id=c(34, 56),
                   annote=c("another clade", "long clade names"),
                   image=c("7fb9bea8-e758-4986-afb2-95a2c3bf983d",
                           "0174801d-15a6-4668-bfe0-4c421fbe51e8"),
                   group=c("A", "B"),
                   offset=c(0.1, 0.1),
                   offset.text=c(0.1, 0.2))

p <- ggtree(tree) + xlim(NA, 6)

p + geom_cladelab(node=45, label="test label") +
    geom_cladelab(node=34, label="another clade")
p2 <- p + geom_cladelab(data=data,
                        mapping=aes(
                             node=id, 
                             label=annote, 
                             image=image,
                             color=group, 
                             offset=offset, 
                             offset.text=offset.text),
                        geom="shadowtext",
                        hjust=0.5,
                        align=TRUE,
                        horizontal=FALSE,
                        angle=90
                       ) 
p2

Example output

Registered S3 method overwritten by 'treeio':
  method     from
  root.phylo ape 
ggtree v2.4.1  For help: https://yulab-smu.top/treedata-book/

If you use ggtree in published research, please cite the most appropriate paper(s):

[36m-[39m Guangchuang Yu. Using ggtree to visualize data on tree-like structures. Current Protocols in Bioinformatics, 2020, 69:e96. doi:10.1002/cpbi.96
[36m-[39m Guangchuang Yu, Tommy Tsan-Yuk Lam, Huachen Zhu, Yi Guan. Two methods for mapping and visualizing associated data on phylogeny using ggtree. Molecular Biology and Evolution 2018, 35(12):3041-3043. doi:10.1093/molbev/msy194
[36m-[39m Guangchuang Yu, David Smith, Huachen Zhu, Yi Guan, Tommy Tsan-Yuk Lam. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data. Methods in Ecology and Evolution 2017, 8(1):28-36. doi:10.1111/2041-210X.12628


Loading required package: shadowtext
Warning message:
Removed 2 rows containing missing values (geom_shadow_text). 

ggtree documentation built on Nov. 15, 2020, 2:09 a.m.