swapBL: swapBL

View source: R/swapBL.R

swapBLR Documentation

swapBL

Description

The function calculates the effect on PD of swapping terminal or internal branch lengths.

Usage

swapBL(
  tree = tree,
  distribution = distribution,
  model = "allswap",
  nTimes = 100,
  root = TRUE,
  index = "PD",
  branch = "terminals",
  percentual = FALSE,
  verbose = TRUE
)

Arguments

tree

A single phylogenetic tree with terminal labels, an 'ape' phylo object.

distribution

A labeled matrix object, with the distribution of terminal taxa (columns) across areas (rows).

model

The type of swap to be performed. Valid values are: * "simpleswap" - Two branch lengths are swapped. * "allswap" (default) - Branch lengths are swapped within the specified branch scope, defined using the 'sample' function. * "uniform" - Branch lengths are replaced by uniformly distributed values between the minimum and maximum values of the original lengths.

nTimes

The number of times to repeat the swap.

root

Whether to use the root node in PD calculations (default = FALSE).

branch

The type of branches to swap: "terminals" (default), "internals", or "all".

verbose

Logical indicating whether to print messages during execution (default = TRUE).

Value

Returns a 'blepd' object containing: * 'initialPD': The PD value of the initial tree. * 'bestInitialArea': The area(s) with the highest PD value in the initial tree. * 'bestModifiedArea': A data frame summarizing the frequency of each area recovered after swaps. * 'tree': The original tree object. * 'distribution': The distribution matrix used for PD calculations. * 'model': The type of swap performed ("simpleswap", "allswap", or "uniform"). * 'nTimes': The number of times the swap was repeated. * 'root': Whether the root was used in PD calculations. * 'index': The PD index used (currently always "PD"). * 'branch': The type of branches swapped ("terminals", "internals", or "all").

Author(s)

Miranda-Esquivel Daniel R.

Examples

library(blepd)
data(tree)
data(distribution)
swapBL(tree = tree, distribution = distribution, model = "allswap", nTimes = 100, branch = "terminals")

Dmirandae/blepd documentation built on April 2, 2024, 12:24 p.m.