1

I am looking to plot type of mating system (monogamous, polygynous and promiscuous) onto a phylogenetic tree built using caper package, ggtree() and a super tree in nexus file format. I have tried to follow this tutorial on the phytools website, however I do not understand it well it enough. My S3 comparative data set looks like this:

enter image description here

I would like to produce a circular/fan phylogenetic tree showing the type of mating system used by a mammal down the branches of tree. To kindly reiterate, I have already made a satisfactory tree - I would like to add the discrete characters (MO, PG, or PR) on top of it - visualised down branches of the tree as one of three colours (red, blue, purple).

I am using this data for my tree:

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)

This code to create the S3 comparative dataset (SuperTree is a nexus file of most mammal species. I can't pass this file on as I was given it by someone else)

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

And finally, this code to create the tree:

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)  

The clade labels won't reproduce exactly as I've only provided a sample of my full data set - hopefully that isn't a problem.

Thanks for your patience with my question and help.

camille
  • 16,432
  • 18
  • 38
  • 60
Nik
  • 39
  • 1
  • 7
  • Even if you don't have *any* code to provide, please [see here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on making an R question folks can answer. That includes posting data as text, as well as making it clear what language you're working in – camille Aug 09 '18 at 01:05
  • Thank you camille. I have added more info to my question - hope it better assists in answering the q. – Nik Aug 09 '18 at 01:56

0 Answers0