make_unit_tree | R Documentation |
Generic method for creating a 'unit.tree' object
make_unit_tree(x, ...)
x |
fitted model object or |
... |
additional arguments |
This function is a generic function which takes a fitted
model object (from a number of different packages), rescales the phylogeny
based on the model fitted parameters, computes the contrasts on the rescaled
phylogeny and returns an object of class unit.tree
. The unit.tree
object
can then be used to assess the adequacy of phylogenetic models of continuous character
evolution. Alternatively, the function can take a phylo
object or a multiPhylo
object
and compute the contrasts on the phylogeny without rescaling. This is only meaningful for
downstream analyses if the phylogenies have been rescaled beforehand. Currently,
the following object types have been implemented:
a gfit
object returned from fitting a model of continuous character evolution using
fitContinuous
in the geiger
package.
a fit.mle
object returned from fitting a model of continuous character evolution
using find.mle
in the diversitree
package.
a mcmcsamples
object returned from fitting a model of continuous character evolution
using MCMC methods in the diversitree
package. make_unit_tree
will apply the same
trait dataset to a set of unit trees based on sampled parameters. By default this will create a
unit tree for every sample in the mcmc chain. To modify this, additional arguments can be use.
burnin
specifies how many samples to remove from the beginning of the chain.
thin
specifies the thinning interval (e.g. if thin=5
, the function will create a unit
tree from every fifth parameter set sampled.
sample
specifies how many samples to draw from the MCMC run.
a gls
object returned from fitting a phylogenetic generalized least squares model
of character correlation using gls
in the nlme
package.
a pgls
object returned from fitting a phylogenetic generalized least squares model
of character correlation using pgls
in the caper
package.
a phylolm
object returned from fitting a phylogenetic generalized linear model of
character correlation using phylolm
in the phylolm
package. As the phylogeny is not
returned with the phylolm
object, a phy
argument must also be specified.
a phylo
object. If a phylo
object is supplied, the tree is assumed to have been
rescaled previously. A second argument data
must also be provided included the trait
data as a named vector with names equal to the tip.labels of the phylogeny.
a multiPhylo object
. If a multiPhylo
object is supplied, the tree is assumed to have been
rescaled previously. A second argument data
must also be provided included the trait
data as a named vector with names equal to the tip.labels of the phylogenies. Note that this
function will append the same data set to every tree in the multiPhylo
object.
a OUwie
object returned from fitting a model of continuous character evolution using
OUwie
in the OUwie
package.
a unit.tree
object containing (or a list of unit.tree
objects,
each containing) the following elements:
a phylo
object. If a model fitted object has been supplied
(see details), the phylo
object will be rescaled based on fitted model
parameters.
the original comparative data
a matrix consisting of the contrasts calculated using the original data on the (rescaled) phylogeny. The matrix has two columns: the "contrasts" and a "variance" for each contrast.
pic
, arbutus
## finch data data(finch) phy <- finch$phy dat <- finch$data[,"wingL"] ## using just the given phylogeny ## without rescaling unit.tree.phy <- make_unit_tree(phy, data=dat) ## Not run: require(geiger) ## fit Brownian motion model ## using geiger's fitContinuous function fit.bm <- fitContinuous(phy=phy, dat=data, model="BM", control=list(niter=10), ncores=1) ## this creates a 'gfit' object which can be used ## in 'make_unit_tree()' unit.tree.geiger <- make_unit_tree(fit.bm) unit.tree.geiger require(diversitree) ## fit Brownian motion model using ML ## using diversitree's find.mle function bmlik <- make.bm(phy, data) fit.bm.dt <- find.mle(bmlik, 0.1) ## this creates a 'fit.mle' object which can be used ## in 'make_unit_tree()' unit.tree.dt <- make_unit_tree(fit.bm.dt) ## fit Brownian motion model using MCMC mcmc.bm.dt <- mcmc(bmlik, x.init=1, nsteps=1000, w=1) ## construct a unit tree object from mcmcsamples ## removing 100 samples as burnin ## and sampling 10 parameter sets unit.tree.mcmc <- make_unit_tree(mcmc.bm.dt, burnin=100, samples=10) require(nlme) ## Use pgls to look for a correlation between two traits t1 <- data t2 <- td$data[,"tarsusL"] dd <- cbind.data.frame(t1, t2) ## fit gls model with corPagel correlation structure fit.gls <- gls(t1~t2, data=dd, correlation=corPagel(phy=phy, value=1)) ## this creates a 'gls' object which can be used ## in 'make_unit_tree()' unit.tree.gls <- make_unit_tree(fit.gls) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.