如何使用phytools在系统发育树上绘制离散字符?

时间:2018-08-09 00:11:42

标签: r ggtree

我正在寻找将交配系统的类型(一夫一妻制,一夫多妻制和杂种制图)绘制到使用caper包,ggtree()包和关系文件格式的超级树构建的系统发育树上的方法。我尝试遵循此tutorial on the phytools website,但是我对它的理解还不够。我的S3比较数据集如下所示:

enter image description here

我想生产一种圆形/扇形的系统发育树,显示哺乳动物在树的分支下使用的交配系统的类型。重申一下,我已经制作了一棵令人满意的树-我想在其顶部添加离散字符(MO,PG或PR)-将树的分支可视化为三种颜色(红色,蓝色,紫色)中的一种)。

我正在将这些数据用于我的树:

structure(list(Order = c("Rodentia", "Lagomorpha", "Primates", 
"Afrosoricida", "Carnivora", "Carnivora", "Cingulata", "Artiodactyla", 
"Lagomorpha", "Rodentia", "Peramelemorphia", "Rodentia", "Rodentia", 
"Carnivora", "Artiodactyla", "Artiodactyla", "Artiodactyla", 
"Artiodactyla", "Rodentia", "Artiodactyla", "Chiroptera"), Family = 
c("Nesomyidae", 
"Leporidae", "Galagidae", "Tenrecidae", "Mustelidae", "Mustelidae", 
"Dasypodidae", "Antilocapridae", "Leporidae", "Sciuridae", "Thylacomyidae", 
"Sciuridae", "Sciuridae", "Canidae", "Bovidae", "Bovidae", "Bovidae",     
"Cervidae", "Sciuridae", "Cervidae", "Noctilionidae"), Genus =     
c("Cricetomys", 
"Sylvilagus", "Otolemur", "Tenrec", "Mustela", "Mustela", "Dasypus", 
"Antilocapra", "Romerolagus", "Sciurus", "Macrotis", "Tamias", 
"Tamiasciurus", "Cerdocyon", "Aepyceros", "Redunca", "Saiga", 
"Alces", "Sciurus", "Hydropotes", "Noctilio"), Species = c("gambianus", 
"floridanus", "garnettii", "ecaudatus", "vison", "sibirica", 
"novemcinctus", "americana", "diazi", "niger", "lagotis", "sibiricus", 
"hudsonicus", "thous", "melampus", "redunca", "tatarica", "alces", 
"variegatoides", "inermis", "leporinus"), Common.name = c("Gambian rat", 
"Eastern cottontail", "Northern greater galago", "Tenrec", "American mink", 
"Siberian weasel", "Nine-banded armadillo", "Pronghorn", "Volcano rabbit", 
"Eastern fox squirrel", "Rabbit-bandicoot or bilby", "Siberian chipmunk", 
"Red squirrel", "Crab-eating fox", "Impala", "Bohor reedbuck", 
"Saiga antelope", "Moose", "Variegated squirrel", "Water deer", 
"Greater bulldog bat"), Wild.or.captive = c("Captive", "Captive", 
"Captive", "Captive", "Captive", "Captive", "Captive", "Captive", 
"Captive", "Captive", "Captive", "Captive", "Captive", "Captive", 
"Captive", "Captive", "Captive", "Captive", "Captive", "Captive", 
"Captive"), Sample.size.M = c(3L, 1L, 1L, 1L, 2L, 4L, 1L, NA, 
1L, 1L, 1L, 4L, 3L, 1L, NA, 1L, 1L, NA, 5L, 3L, 1L), Source.M = c("Weigl,R", 
"Weigl,R", "Weigl,R", "Weigl,R", "Weigl,R", "Weigl,R", "Weigl,R", 
"Tidiere, R", "Weigl,R", "Weigl,R", "Weigl,R", "Weigl,R", "Weigl,R", 
"Weigl,R", "Tidiere, R", "Weigl,R", "Weigl,R", "Tidiere, R", 
"Weigl,R", "Weigl,R", "Weigl,R"), Body.weight.F = c(1.235, 1.303, 
0.734, 2, 0.9, 0.395, 4.8, 45.4, 0.536, 0.7643, 0.85, 0.0962, 
0.213, 4.35, 43.8, 36, 40.9, 500, 0.4688, 17.4, 0.06), Source = c("ADW", 
"Swihart", "ADW", "ADW", "Tidiere, R", "ADW", "ADW", "Tidiere, M", 
"ADW", "Hayssen, V", "ADW", "Hayssen, V", "Hayssen, V", "Moehlmen", 
"Tidiere, M", "Weckerly", "Müller, D", "Charlton & Reby; Weckerly", 
"Hayssen, V", "Müller, D", "ADW"), Mating.system = structure(c(1L, 
2L, 3L, 3L, 3L, 2L, 2L, 2L, 1L, 3L, 2L, 3L, 3L, 1L, 2L, 1L, 2L, 
2L, 3L, 1L, 2L), .Label = c("MO", "PG", "PR"), class = "factor"), 
Source2 = c("ADW", "ADW", "ADW", "ADW", "ADW", "ADW", "ADW", 
"ADW", "ADW", "ADW", "ADW", "ADW", "ADW", "Lukas & Clutton-Brock", 
"ADW", "Lukas & Clutton-Brock", "Charlton & Reby", "Charlton & Reby", 
"ADW", "Weckerly", "ADW"), log.FM.lifespan = c(0, -0.0500788643433177, 
0.0662862655764385, -0.00419611459360813, 0.115531268086469, 
-0.180207825250513, 0.221036224623684, -0.0599979296752854, 
-0.0160868198934548, 0.237978249916892, 0, -0.0922148917996766, 
-0.0718820073061254, 0.106296626552242, 0.407957129429562, 
0.0173048582084705, -0.0211892990699381, 0.0634472180602594, 
0.130573776504377, -0.119687227857626, 0), Log.MF.mass = c(0, 
-0.0209627117984714, 0.0341244425110258, 0, 0.142667503568732, 
0.269690243457735, 0.138302698166281, 0.0753379069658646, 
-0.109028734719013, 0.00181452456425008, 0.288065018499614, 
-0.0128281958077196, -0.236009903809617, 0.198467480104913, 
0.113638155890972, 0.0771659548122993, 0.0958468680905946, 
0.198106998873402, 0.0589058009532036, 0.0266224801204141, 
0.113943352306837), Binomial = c("Cricetomys_gambianus", 
"Sylvilagus_floridanus", "Otolemur_garnettii", "Tenrec_ecaudatus", 
"Mustela_vison", "Mustela_sibirica", "Dasypus_novemcinctus", 
"Antilocapra_americana", "Romerolagus_diazi", "Sciurus_niger", 
"Macrotis_lagotis", "Tamias_sibiricus", "Tamiasciurus_hudsonicus", 
"Cerdocyon_thous", "Aepyceros_melampus", "Redunca_redunca", 
"Saiga_tatarica", "Alces_alces", "Sciurus_variegatoides", 
"Hydropotes_inermis", "Noctilio_leporinus")), .Names = c("Order", 
"Family", "Genus", "Species", "Common.name", "Wild.or.captive", 
"Sample.size.M", "Source.M", "Body.weight.F", "Source", "Mating.system", 
"Source2", "log.FM.lifespan", "Log.MF.mass", "Binomial"), class = 
"data.frame", row.names = 30:50)

用于创建S3比较数据集的这段代码(SuperTree是大多数哺乳动物物种的联系文件。我无法像别人给的那样传递此文件)

mammalia <- comparative.data(SuperTree, data, Binomial,vcv=TRUE, 
na.omit=FALSE)

最后,此代码创建树:

library(ggtree)
PreTree <- ggtree(mammalia$phy)

MyTree <- PreTree + 
  geom_tiplab(size=1) + 
  xlim(NA,300) + 
  geom_cladelabel(node=309, label="Carnivora", color="red", offset=40, align=TRUE) + 
  geom_cladelabel(node=273, label="Artiodactyla", color="#006633", offset=40, align=TRUE) + 
  geom_cladelabel(node=224, label="Primates", color="#663300", offset=40, align=TRUE) + 
  geom_cladelabel(node=206, label="Rodentia", color="#666600", offset=40, align=TRUE)  

进化枝标签不会完全重现,因为我只提供了完整数据集的一个样本-希望这不是问题。

感谢您耐心等待我的问题和帮助。

0 个答案:

没有答案