本節(jié)來介紹如何使用ggtree繪制動(dòng)物之間的系統(tǒng)發(fā)育樹并添加動(dòng)物輪廓酱床。圖形的繪制過程比較簡單,主要是數(shù)據(jù)的整理拍摇。
加載R包
library(rotl)
library(ggtree)
library(tidyverse)
library(ggimage)
library(extrafont)
構(gòu)建分類信息
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"))
繪制分類系統(tǒng)發(fā)育樹
tree_data <- tol_induced_subtree(ott_ids = ott_id(taxa))
導(dǎo)入動(dòng)物輪廓數(shù)據(jù)
phylopic_info <- read_tsv("phylopic.xls")
繪制系統(tǒng)發(fā)育樹
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'))
好了本節(jié)介紹到此結(jié)束碗淌,非常簡單的一個(gè)案例喜歡的觀眾老爺歡迎分享轉(zhuǎn)發(fā),更多精彩案例歡迎關(guān)注我的公粽號R語言數(shù)據(jù)分析指南