Learn R Programming

dispRity (version 1.5.0)

dtt.dispRity: dtt dispRity (from geiger::dtt)

Description

A wrapper for the dtt function working with any disparity metric.

Usage

dtt.dispRity(
  data,
  metric,
  tree,
  nsim = 0,
  model = "BM",
  alternative = "two-sided",
  scale.time = TRUE,
  ...
)

Arguments

data

A dispRity object or a matrix

metric

The disparity metric to be passed to dispRity.

tree

A phylo object matching the data and with a root.time element.

nsim

The number of simulations to calculate null disparity-through-time.

model

A evolutionary model for the simulations (see sim.char - default is "BM").

alternative

The H1 alternative (for calculating the p-value). Can be "two-sided" (default), "greater" or "lesser"; see details.

scale.time

Optional, whether to scale the time (between 0 and 1; TRUE, default) or not (FALSE).

...

Any other arguments to be passed to dtt.

Details

See dtt for details. Note that for calculating the default metrics implemented in dtt (i.e c("avg.sq", "avg.manhattan", "num.states")) this implementation in dispRity is much slower!

See Also

dtt, test.dispRity, custom.subsets, chrono.subsets, plot.dispRity.

Examples

Run this code
# NOT RUN {
## Loading geiger's example data set
require(geiger)
geiger_data <- get(data(geospiza))

## Calculate the disparity of the dataset using dtt::geiger
geiger_dtt <- dtt(phy = geiger_data$phy, data = geiger_data$dat, nsim = 100)

## The average squared pairwise distance metric (used in geiger::dtt)
average.sq <- function(X) mean(pairwise.dist(X)^2)

## Calculate the disparity of the dataset using dtt.dispRity
dispRity_dtt <- dtt.dispRity(data = geiger_data$dat, metric = average.sq,
                             tree = geiger_data$phy, nsim = 100)

## Plotting the results
plot(dispRity_dtt)

## Disparity values are identical up to the 9th digit!
round(geiger_dtt$dtt, 9) == round(dispRity_dtt$dtt, 9)
 
## Calculate disparity with a different metric using dtt.dispRity
dispRity_dtt2 <- dtt.dispRity(data = geiger_data$dat, tree = geiger_data$phy,
                             metric = c(median, centroids), nsim = 50)
plot(dispRity_dtt2)

# }

Run the code above in your browser using DataLab