swap.phylo: Test the effect of phylogenetic uncertainty on rate shifts...

Description Usage Arguments Details Value Examples

View source: R/swap.phylo.R

Description

The function uses a number of alternative phylogenies with altered (as compared to the reference tree) topology and branch lengths tests whether the tips descending from the specified node (node) have statistically different rates from the rest of the tree. A phenotypic vector y must be supplied. Eventually, the effect of a covariate could be included.

Usage

1
swap.phylo(tree,si=0.5,si2=0.5,node,y,rts,nrep=100,cov=NULL,clus=0.5)

Arguments

tree

a phylogenetic tree. The tree needs not to be ultrametric or fully dichotomous.

si

the proportion of tips whose topologic arrangement will be swapped.

si2

the proportion of nodes whose age will be changed.

node

the focal node to be tested.

y

the phenotype under testing.

rts

the rates found by RRphylo on the original tree.

nrep

the number of simulated trees to be produced.

cov

the covariate to be indicated if its effect on rate values must be accounted for. Contrary to RRphylo, cov needs to be as long as the number of tips of the tree.

clus

the proportion of clusters to be used in parallel computing (only if y is multivariate). To run the single-threaded version of swap.phylo set clus = 0.

Details

swap.phylo changes the tree topology and branch lengths to a level specified by the user. Up to half of the tips, and half of the branch lengths can be changed randomly. The function provides a 'swapped' tree, yet, importantly, once a shift in the rate of evolution has been found by RRphylo, this function can be used to test whether the shift depends on the tree topology and branch lengths. It runs RRphylo on swapped trees (default is 100) and then calculates the absolute rate difference between all the branches of the shifted node and the rest of the tree. A t-test is eventually performed to assess significance.

Value

The function returns a 'list' object containing:

$p.swap the probability that the rates at node are different from rates at the rest of the tree.

$rates the distribution of rates per branch as calculated by RRphylo on 'swapped' phylogenies.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Not run: 
  data("DataApes")
  DataApes$PCstage->PCstage
  DataApes$Tstage->Tstage
  DataApes$CentroidSize->CS
  cc<- 2/parallel::detectCores()

# Case 1. swap.phylo without accounting for the effect of a covariate
  RRphylo(tree=Tstage,y=PCstage,clus=cc)->RR
  RR$rates->rr
  swap.phylo(Tstage,node=61,y=PCstage,rts=rr,clus=cc)

# Case 2. swap.phylo accounting for the effect of a covariate
  RRphylo(tree=Tstage,y=CS,clus=cc)->RRcova
  c(RRcova$aces,CS)->cov.values
  c(rownames(RRcova$aces),names(CS))->names(cov.values)
  RRphylo(tree=Tstage,y=PCstage,cov=cov.values,clus=cc)->RR
  RR$rates->rr
  swap.phylo(Tstage,node=61,y=PCstage,rts=rr,cov=CS,clus=cc)

## End(Not run)

pasraia/RRphylo documentation built on Aug. 6, 2021, 9:42 p.m.