Skip to content

radamsRHA/ROBRT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

output
pdf_document html_document word_document
default
default
default

ROBRT: ROBust Regression on Trees

NOTE See the file https://github.com/radamsRHA/ROBRT/blob/master/ROBRT.pdf for detailed instructions

Installing R package ROBRT from github

The R package ROBRT is freely available to download and distribute from github https://github.com/radamsRHA/ROBRT/. To install and load ROBRT, you must first install the R package devtools,

install.packages("devtools")

Now using devtools we can install ROBRT from github:

library(devtools)
install_github("radamsRHA/ROBRT")
library(ROBRT) # Load package 

To begin using ROBRT try using the examples associated with each function. Importantly, the 5 estimators can be conducted for both PGLS and PIC phylogenetic regression using the primary function Conduct.Robust_PhylogeneticRegression with specific options. See examples below:

Example: L2 with PIC

We can use Conduct.Robust_PhylogeneticRegression with option "PIC" and "L2" in vector.Estimators to run the L2 phylogenetic regression with PIC for a given datasets. First, let's load the R package ROBRT:

################
# Load depends #
################
library(ROBRT)

Next, let's analyze an example phylogeny and dataset. This example phylogeny ExampleTree.tree and example dataset ExampleTraitData.txt can be loaded with the following commands:

#####################
# Load example data #
#####################
handle.ExamplePhylogeny <-  read.tree(system.file("extdata", "ExampleTree.tree", package="ROBRT"))
handle.ExampleDataset <- read.table(system.file("extdata", "ExampleTraitData.txt", package="ROBRT"))

Let's take a peak out our example phylogeny and trait dataset with the following commands:

########################
# View example dataset #
########################
plot(handle.ExamplePhylogeny) # plot tree
View(handle.ExampleDataset) # view trait data for example

For ROBRT to work properly, we need to make sure that the species names in our phylogeny are in the same order as our trait data. We can check that the names match up using the following commands:

########################
# View example dataset #
########################
handle.ExampleDataset <- handle.ExampleDataset[handle.ExamplePhylogeny$tip.label,]
rownames(handle.ExampleDataset) == handle.ExamplePhylogeny$tip.label

As shown above, you can see the trait measurements for TraitY (dependent trait) and TraitX using the command View(handle.ExampleDataset).

We can now use the following command to conduct robust regression for L2, L1, S, M, and MM estimators with PIC:

############################################
# Conduct phylogenetic regression with PIC #
############################################
Conduct.Robust_PhylogeneticRegression(handle.Phylogeny = handle.ExamplePhylogeny, 
                                      Y.trait = handle.ExampleDataset[,1], 
                                      X.traits = cbind(handle.ExampleDataset[,2]),
                                      vector.Estimators = c("L2", "L1", "S", "M", "MM"), 
                                      string.Method = "PIC")

Likewise, we can conduct phylogenetic regression for PGLS using the following

############################################
# Conduct phylogenetic regression with PGLS #
############################################
Conduct.Robust_PhylogeneticRegression(handle.Phylogeny = handle.ExamplePhylogeny, 
                                      Y.trait = handle.ExampleDataset[,1], 
                                      X.traits = cbind(handle.ExampleDataset[,2]),
                                      vector.Estimators = c("L2", "L1", "S", "M", "MM"), 
                                      string.Method = "PGLS")

Next, we can plot diagnostic plots for each estimator to visualize the model with the following commands:

############################################
# Conduct phylogenetic regression with PIC #
############################################
handle.RESULTS <- Conduct.Robust_PhylogeneticRegression(handle.Phylogeny = handle.ExamplePhylogeny, 
                                      Y.trait = handle.ExampleDataset[,1], 
                                      X.traits = cbind(handle.ExampleDataset[,2]),
                                      vector.Estimators = c("L2", "L1", "S", "M", "MM"), 
                                      string.Method = "PIC")
                                      
plot(handle.RESULTS[[1]]) # plot diagnostic plots for L2
plot(handle.RESULTS[[2]]) # plot diagnostic plots for L1
plot(handle.RESULTS[[3]]) # plot diagnostic plots for S
plot(handle.RESULTS[[4]]) # plot diagnostic plots for M
plot(handle.RESULTS[[5]]) # plot diagnostic plots for MM

About

Robust phylogenetic regression on trees

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages