# NOT RUN {
easyGetPBDBtaxa <- function(taxon,show = c("phylo","img","app")){
#let's get some taxonomic data
taxaData <- read.csv(paste0("http://paleobiodb.org/",
"data1.1/taxa/list.txt?base_name = ",taxon,
"&rel = all_children&show = ",
paste0(show,collapse = ","),"&status = senior"),
stringsAsFactors = FALSE)
return(taxaData)
}
#graptolites
graptData <- easyGetPBDBtaxa("Graptolithina")
graptTree <- makePBDBtaxonTree(graptData,"genus",
method = "parentChild", solveMissing = "queryPBDB")
#try Linnean
graptTree <- makePBDBtaxonTree(graptData,"genus",
method = "Linnean")
plot(graptTree,show.tip.label = FALSE,no.margin = TRUE,edge.width = 0.35)
nodelabels(graptTree$node.label,adj = c(0,1/2))
#conodonts
conoData <- easyGetPBDBtaxa("Conodonta")
conoTree <- makePBDBtaxonTree(conoData,"genus",
method = "parentChild", solveMissing = "queryPBDB")
plot(conoTree,show.tip.label = FALSE,no.margin = TRUE,edge.width = 0.35)
nodelabels(conoTree$node.label,adj = c(0,1/2))
#asaphid trilobites
asaData <- easyGetPBDBtaxa("Asaphida")
asaTree <- makePBDBtaxonTree(asaData,"genus",
method = "parentChild", solveMissing = "queryPBDB")
plot(asaTree,show.tip.label = FALSE,no.margin = TRUE,edge.width = 0.35)
nodelabels(asaTree$node.label,adj = c(0,1/2))
#Ornithischia
ornithData <- easyGetPBDBtaxa("Ornithischia")
ornithTree <- makePBDBtaxonTree(ornithData,"genus",
method = "parentChild", solveMissing = "queryPBDB")
#try Linnean
#need to drop repeated taxon first: Hylaeosaurus
ornithData <- ornithData[-(which(ornithData[,"taxon_name"] == "Hylaeosaurus")[1]),]
ornithTree <- makePBDBtaxonTree(ornithData,"genus",
method = "Linnean")
plot(ornithTree,show.tip.label = FALSE,no.margin = TRUE,edge.width = 0.35)
nodelabels(ornithTree$node.label,adj = c(0,1/2))
#Rhynchonellida
rynchData <- easyGetPBDBtaxa("Rhynchonellida")
rynchTree <- makePBDBtaxonTree(rynchData,"genus",
method = "parentChild", solveMissing = "queryPBDB")
plot(rynchTree,show.tip.label = FALSE,no.margin = TRUE,edge.width = 0.35)
nodelabels(rynchTree$node.label,adj = c(0,1/2))
#some of these look pretty messy!
# }
# NOT RUN {
###################################
# }
# NOT RUN {
#let's try time-scaling the graptolite tree
#get some example occurrence and taxonomic data
data(graptPBDB)
#get the taxon tree: Linnean method
graptTree <- makePBDBtaxonTree(graptTaxaPBDB, "genus", method = "Linnean")
plot(graptTree,cex = 0.4)
nodelabels(graptTree$node.label,cex = 0.5)
#get the taxon tree: parentChild method
graptTree <- makePBDBtaxonTree(graptTaxaPBDB, "genus", method = "parentChild")
plot(graptTree,cex = 0.4)
nodelabels(graptTree$node.label,cex = 0.5)
#get time data from occurrences
graptOccGenus <- taxonSortPBDBocc(graptOccPBDB,rank = "genus",onlyFormal = FALSE)
graptTimeGenus <- occData2timeList(occList = graptOccGenus)
#let's time-scale the parentChild tree with paleotree
# use minimum branch length for visualization
# and nonstoch.bin so we plot maximal ranges
timeTree <- bin_timePaleoPhy(graptTree,timeList = graptTimeGenus,
nonstoch.bin = TRUE,type = "mbl",vartime = 3)
#drops a lot of taxa; some of this is due to mispellings, etc
# }
# NOT RUN {
#make pretty plot with library strap
library(strap)
geoscalePhylo(timeTree, ages = timeTree$ranges.used)
nodelabels(timeTree$node.label,cex = 0.5)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab