Francisco Francisco - 1 year ago 107
R Question

Adding symbols and information to Phylogenetic tree

I am drawing a phylogenetic tree, and I would like to add something like a 'dead symbol̈́̈́' (e.g a skull) in the tips of the extinct species.

I would also like to add an x-axes bar with latex symbols in the branching times (e.g $\Delta t_i$ or numbers) marked with dots.

What I have so far is this tree. I would like to add the dead symbol right after the green dotted line in this case.

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))

nya nya
Answer Source

I can see two options how to display an "extinct" symbol on a tree tip.

  1. Use a Unicode symbol with an appropriate font that can display it as per this blog.
  2. Add a raster image onto the tree plot.

The following code will display an extinction symbol next to the green edge in your tree. It draws on information found here.

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
mtext(expression(Delta*italic("t")["i"]), side = 1, line = 3)

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download