【问题标题】:Adding symbols and information to Phylogenetic tree向系统发育树添加符号和信息
【发布时间】:2016-10-15 19:52:23
【问题描述】:

我正在绘制系统发育树,我想在已灭绝物种的尖端添加类似“死亡符号̈́̈́”(例如头骨)的东西。

我还想在用点标记的分支时间(例如 $\Delta t_i$ 或数字)中添加一个带有乳胶符号的 x 轴条。

到目前为止,我拥有的是这棵树。在这种情况下,我想在绿色虚线之后添加死符号。

library(ape)
rec1 = '((B:1,A:1):1,(F:1,C:1.5):0.5);'
rec1 = read.tree(text = rec1)
plot(rec1,show.tip.label = F,edge.color = c("black","black","black","black","darkgreen","black"),edge.width = 2,edge.lty = c(rep(1,4),4,1))

【问题讨论】:

  • 这个帖子好像没人看。我怎样才能让它更显眼?

标签: r phylogeny ape


【解决方案1】:

一种可能性是使用 ggtree。如: https://guangchuangyu.github.io/2018/03/annotating-phylogenetic-tree-with-images-using-ggtree-and-ggimage/

#source("https://bioconductor.org/biocLite.R")
#biocLite("BiocUpgrade") # you may need this
#biocLite("ggtree")
library(ggtree)

tree<-rtree(10)
pg<-ggtree(tree)
d <- data.frame(node = as.character(10:15),
                images = c("https://i.imgur.com/8VA9cYw.png",
                           "https://i.imgur.com/XYM1T2x.png",
                           "https://i.imgur.com/EQs5ZZe.png",
                           "https://i.imgur.com/2xin0UK.png",
                           "https://i.imgur.com/hbftayl.png",
                           "https://i.imgur.com/3wDHW8n.png"))
pg %<+% d + geom_nodelab(aes(image=images), geom="image")

有亲缘关系

#install.packages('rphylopic')
library(rphylopic)
string<-name_search(text = "Homo sapiens")
selectstr<-string[2,]
string2<-name_images(uuid = selectstr)$same[[1]]$uid
tree<-rtree(10)
phylopic_info <- data.frame(node = c(12,13),
                            phylopic = string2)
nt<-ggtree(tree) 
nt %<+% phylopic_info + 
  geom_nodelab(aes(image=phylopic), geom="phylopic", alpha=.5, color='steelblue')

【讨论】:

    【解决方案2】:

    我可以看到两个选项如何在树梢上显示“灭绝”符号。

    1. 使用 Unicode 符号和可以按照this blog 显示的适当字体。
    2. 将光栅图像添加到树状图上。

    以下代码将在树的绿色边缘旁边显示一个extinction symbol。它利用here 找到的信息。

    library(jpeg)
    logo <- readJPEG("Downloads/Symbol1.jpg")
    logo2 <- as.raster(logo)
    r <- nrow(logo2)/ncol(logo2) # aspect ratio
    s <- 0.4 # symbol size
    
    # display plot to obtain its size
    plot(rec1, edge.color = c("black","black","black","black","darkgreen","black"),
        edge.width = 2, edge.lty = c(rep(1,4),4,1))
    lims <- par("usr") # plot area size
    file_r <- (lims[2]-lims[1]) / (lims[4]-lims[3]) # aspect ratio for the file
    file_s <- 480   # file size
    
    # save tree with added symbol
    png("tree_logo.png", height=file_s, width=file_s*file_r)
    plot(rec1, show.tip.label = F, 
        edge.color = c("black","black","black","black","darkgreen","black"), 
        edge.width = 2, edge.lty = c(rep(1,4),4,1))
    rasterImage(logo2, 1.6, 2.8, 1.6+s/r, 2.8+s)
    
    # add axis
    axisPhylo()
    mtext(expression(Delta*italic("t")["i"]), side = 1, line = 3)
    dev.off()
    

    【讨论】:

    • @Francisco 现在怎么样?我添加了您要求的轴。
    • 谢谢。我认为这可以解决我的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-17
    • 1970-01-01
    • 2014-03-01
    • 1970-01-01
    相关资源
    最近更新 更多