Getting started with phylocurve


Step 1: Get the most recent version of phylocurve

require(devtools)
install_github(repo="ericgoolsby/phylocurve")


Step 2: Format the data and tree

The tree should be a phylogenetic tree of class "phylo". Format the data variable as a data frame with 3 columns:

column 1 (labeled "species") with species names (must match tip names in phylogenetic tree)
column 2 (labeled with the predictor variable -- e.g., "x") with predictor values
column 3 (labeled with the response variable -- e.g., "y") with response values (should be between 0 and 1, for now)

There should be one data point per row.

Alternatively, simulate data (and tree) with the sim.curves function:
data <- sim.curves()


Step 3: Perform ancestral curve reconstruction

anc_recon <- phylocurve(formula = y~x,tree = data$tree,data = data$data)
tip_coefficients <- anc_recon$tip_coefficients

...or estimate regression coefficients without performing ancestral curve reconstruction (for other comparative analyses)

tip_coefficients <- get_tip_coefficients(formula = y~x,tree = data$tree,data = data$data)

tip_coefficients can also be supplied by the user as a 2-column matrix with the number of rows equal to the number of tips in the phylogeny (rows should be named). The first column is the glm logit intercept and the second column is the glm logit slope parameter.


Step 4: Generate aligned function-valued data

aligned_data <- get_aligned_function_data(tip_coefficients = tip_coefficients)


Step 5: Perform other comparative analyses

Estimate evolutionary rates

rate.mult.fitted <- rate.mult(tree = data$tree,Y = aligned_data)

Test for multivariate phylogenetic signal

K.mult(rate.mult.fitted = rate.mult.fitted)

Perform phylogenetic regression

require(phytools) # To simulate a univariate trait under Brownian motion with fastBM
X <- as.matrix(fastBM(data$tree)) # Simulated univariate trait
pgls.mult(rate.mult.fitted = rate.mult.fitted,X = X)