如何增加ggtree中的最大分支宽度?

How can I increase the maximum branch width in ggtree?

我在系统发育图的分支中添加了一些特征,并将分支宽度缩放到它们的值:

library(ggtree)
library(tidyverse)

tree <- rtree(3, rooted = T)
trait <- data.frame(node = 1:(length(tree$edge.length)+1),
                    thing = rnorm(n = length(tree$edge.length)+1, mean = 4))

t <- full_join(tree, trait)
ggtree(t, aes(size = thing))

特别是如果特征值的范围很大,分支宽度需要能够反映出来。如何指定分支的最大宽度?

映射size美学时直接调用trait$thing向量。最好确保 traittree$tip.label 排序,尽管 ggtree 可能在内部进行一些匹配。

library(ggtree)

tree <- rtree(3, rooted = T)
trait <- data.frame(node = 1:(length(tree$edge.length)+1),
                    thing = rnorm(n = length(tree$edge.length)+1, mean = 4))

ggtree(tr = tree, aes(size = trait$thing)) + 
  scale_size_continuous(range = c(0.2, 2))

来自?scale_size_continuous

range

a numeric vector of length 2 that specifies the minimum and maximum size of the plotting symbol after transformation.