Thursday, August 4, 2022

sigmoidPhylogram now in development version of phytools. (That's it.)

sigmoidPhylogram is now part of the development version of phytools which can be installed from GitHub using the devtools CRAN package as follows:

devtools::install_github("liamrevell/phytools")

As documented in a prior post, in addition to plotting a simple "phylo" object in sigmoidal style, sigmoidPhylogram can also plot a "simmap" or (by extension) "contMap" object.

Here's a quick demonstration of that using a phylogeny & dataset from Collar et al. (2014) that also features in my upcoming book with Luke Harmon.

## load phytools
library(phytools)
## check package version
packageVersion("phytools")
## [1] '1.1.8'
## read tree & data from file
eel.tree<-read.tree(file="http://www.phytools.org/Rbook/8/elopomorph.tre")
eel.data<-read.csv(file="http://www.phytools.org/Rbook/8/elopomorph.csv",
    row.names=1,stringsAsFactors=TRUE)
## extract variable of interest
Max_TL_cm<-setNames(eel.data$Max_TL_cm,rownames(eel.data))
## create and re-color contMap
eel.contMap<-contMap(eel.tree,Max_TL_cm,plot=FALSE)
eel.contMap<-setMap(eel.contMap,hcl.colors(10,
    palette="YlGnBu",rev=TRUE))
## plot outline
sigmoidPhylogram(eel.tree,fsize=0.6,ftype="i",lwd=7,
    ylim=c(-5,Ntip(eel.tree)))
## plot contMap
sigmoidPhylogram(eel.contMap$tree,colors=eel.contMap$cols,
    ftype="off",lwd=5,
    xlim=get("last_plot.phylo",envir=.PlotPhyloEnv)$x.lim,
    ylim=c(-5,Ntip(eel.tree)),
    add=TRUE)
## add legend
dd<-diff(par()$usr[1:2])
add.color.bar(dd/2,eel.contMap$cols,"max length (cm)",
    lims=eel.contMap$lims,digits=1,prompt=FALSE,
    x=0,y=-5,lwd=5,subtitle="",fsize=0.9)

plot of chunk unnamed-chunk-2

No comments:

Post a Comment

Note: due to the very large amount of spam, all comments are now automatically submitted for moderation.