本节来介绍如何使用ggtree绘制动物之间的系统发育树并添加动物轮廓。图形的绘制过程比较简单,主要是数据的整理。
加载R包
library(rotl)
library(ggtree)
library(tidyverse)
library(ggimage)
library(extrafont)
构建分类信息
taxa <- tnrs_match_names(names = c("Ornithorhynchus anatinus",
"Tachyglossus aculeatus", "Phascolarctos cinereus",
"Macropus giganteus", "Ailuropoda melanoleuca",
"Carcharodon carcharias", "Megaptera novaeangliae",
"Eudyptula minor", "Tiliqua scincoides", "Notechis scutatus",
"Dromaius novaehollandiae", "Dacelo novaeguineae",
"Myrmecia gulosa", "Musca domestica"))
绘制分类系统发育树
tree_data <- tol_induced_subtree(ott_ids = ott_id(taxa))
导入动物轮廓数据
phylopic_info <- read_tsv("phylopic.xls")
绘制系统发育树
ggtree(tree_data) %<+% phylopic_info +
geom_tiplab(aes(image=phylopic),geom="phylopic", alpha=.5, color='#3CB2EC', offset=.1) +
geom_tiplab(aes(label=common_name),offset = .75, col="black") +
xlim(NA,10) +
theme(plot.caption=element_text(size=10, face='italic'))
好了本节介绍到此结束,非常简单的一个案例喜欢的观众老爷欢迎分享转发,更多精彩案例欢迎关注我的公粽号R语言数据分析指南