Title: | To Slice Phylogenetic Trees and Infer Evolutionary Patterns Over Time |
Version: | 1.0.3 |
Description: | Provide a range of functions with multiple criteria for cutting phylogenetic trees at any evolutionary depth. It enables users to cut trees in any orientation, such as rootwardly (from root to tips) and tipwardly (from tips to its root), or allows users to define a specific time interval of interest. It can also be used to create multiple tree pieces of equal temporal width. Moreover, it allows the assessment of novel temporal rates for various phylogenetic indexes, which can be quickly displayed graphically. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.1 |
URL: | https://github.com/AraujoMat/treesliceR, https://araujomat.github.io/treesliceR/ |
Depends: | R (≥ 2.10) |
BugReports: | https://github.com/AraujoMat/treesliceR/issues |
Imports: | ape (≥ 5.7-1), doParallel (≥ 1.0.17), foreach (≥ 1.5.2), ggplot2 (≥ 3.4.2), sf (≥ 1.0-9) |
LazyData: | true |
Config/Needs/website: | rmarkdown |
Suggests: | devtools, ggpubr (≥ 0.6.0), knitr, rmarkdown, testthat (≥ 3.0.0) |
VignetteBuilder: | knitr |
Config/testthat/edition: | 3 |
NeedsCompilation: | no |
Packaged: | 2025-06-08 23:59:02 UTC; Mathe |
Author: | Matheus Lima Araujo
|
Maintainer: | Matheus Lima Araujo <matheusaraujolima@live.com> |
Repository: | CRAN |
Date/Publication: | 2025-06-09 16:00:02 UTC |
Adjacency matrix for focal and adjacent assemblages
Description
This is a square matrix containing information abount the presence-absence of each focal cell assemblage and its respective neighborhood assemblages, following the chessboard queen's case.
Usage
AU_adj
Format
Matrix
Australia grid map
Description
This is a gridded shapefile of Australia, with grid cells at a 0.5-degree resolution.
Usage
AU_grid
Format
Shapefile
Calculates the rate of accumulation of phylogenetic B-diversity (CpB) over time slices
Description
This function estimates the rates of accumulation of phylogenetic B-diversity (CpB) over time for inputted assemblages.
Usage
CpB(tree, n, mat, adj, comp, method, criterion, pBO, ncor)
Arguments
tree |
phylo. An ultrametric phylogenetic tree in the "phylo" format. |
n |
numeric. A numeric value indicating the number of temporal slices (method = 1) or the time interval in million years (or phylogenetic diversity) among the tree slices (method = 2). Default is 1. |
mat |
matrix. A presence/absence matrix containing all studied species and sites. |
adj |
matrix. A square adjacency matrix containing the presence/absence information of all sites and their spatially adjacent ones. |
comp |
character string. The component of the phylogenetic beta-diversity to obtain the rates of accumulation. It can be either "sorensen", "turnover", or "nestedness". Default is "sorensen". |
method |
character string. The method for calculating the phylogenetic beta-diversity. It can be either obtained through a "pairwise" or "multisite" approach. Default is "multisite". |
criterion |
character string. The method for cutting the tree. It can be either "my" (million years) or "PD" (accumulated phylogenetic diversity). Default is "my". |
pBO |
numeric. A value indicating the numeric proportion to define the temporal origin at which the phylogenetic B-diversity (PB) started to accumulate in a given assemblage. Default is 5%. |
ncor |
numeric. A value indicating the number of cores the user wants to parallelize. Default is 0. |
Details
Parallelization
Users are advised to check the number of available cores within their machines before running parallel programming.
Value
The function returns a data frame containing the assemblages' rates of cumulative phylogenetic B-diversity (CpB), their total phylogenetic B-diversity (PB), and their PB origin (pBO).
Author(s)
Matheus Lima de Araujo matheusaraujolima@live.com
References
See the tutorial on how to use this function on our website.
See Also
Other cumulative phylogenetic index analysis: CpD()
, CpE()
, CpB_RW()
Examples
# Generate a random tree
tree <- ape::rcoal(20)
# Create a presence-absence matrix
mat <- matrix(sample(c(1,0), 20*10, replace = TRUE), ncol = 20, nrow = 10)
colnames(mat) <- tree$tip.label
# Create a random adjacency matrix
adj <- matrix(sample(c(1,0), 10*10, replace = TRUE), ncol = 10, nrow = 10)
# Fill the diagonals with 1
diag(adj) <- 1
# Calculate their CpB (sorensen) for 100 tree slices
CpB(tree, n = 100, mat = mat, adj = adj, comp = "sorensen", method = "multisite")
Calculates the range weighted rate of accumulation of phylogenetic B-diversity (CpB_RW) over time slices
Description
This function estimates the range-weighted rates of accumulation of phylogenetic B-diversity (CpB_RW) over time for inputted assemblages.
Usage
CpB_RW(tree, n, mat, adj, method = "multisite", criterion = "my", pBO = 5, ncor = 0)
Arguments
tree |
phylo. An ultrametric phylogenetic tree in the "phylo" format. |
n |
numeric. A numeric value indicating the number of temporal slices (method = 1) or the time interval in million years (or phylogenetic diversity) among the tree slices (method = 2). Default is 1. |
mat |
matrix. A presence/absence matrix containing all studied species and sites. |
adj |
matrix. A square adjacency matrix containing the presence/absence information of all sites and their spatially adjacent ones. |
method |
character string. The method for calculating the phylogenetic beta-diversity. It can be either obtained through a "pairwise" or "multisite" approach. Default is "multisite". |
criterion |
character string. The method for cutting the tree. It can be either "my" (million years) or "PD" (accumulated phylogenetic diversity). Default is "my". |
pBO |
numeric. A value indicating the numeric proportion to define the temporal origin at which the range-weighted phylogenetic B-diversity (PB_RW) started to accumulate in a given assemblage. Default is 5%. |
ncor |
numeric. A value indicating the number of cores the user wants to parallelize. Default is 0. |
Details
Parallelization
Users are advised to check the number of available cores within their machines before running parallel programming.
Value
The function returns a data frame containing the assemblages' rates of cumulative range-weighted phylogenetic B-diversity (CpB_RW), their total range-weighted phylogenetic B-diversity (PB_RW), and their origin (pBO).
Author(s)
Matheus Lima de Araujo matheusaraujolima@live.com
References
Laffan, S. W., Rosauer, D. F., Di Virgilio, G., Miller, J. T., González-Orozco, C. E., Knerr, N., Thornhill, A. H., & Mishler, B. D. (2016). Range-weighted metrics of species and phylogenetic turnover can better resolve biogeographic transition zones. Methods in Ecology and Evolution, 7(5), 580–588. https://doi.org/10.1111/2041-210x.12513
See Also
Other cumulative phylogenetic index analysis: CpD()
, CpE()
, CpB()
Examples
# Generate a random tree
tree <- ape::rcoal(20)
# Create a presence-absence matrix
mat <- matrix(sample(c(1,0), 20*10, replace = TRUE), ncol = 20, nrow = 10)
colnames(mat) <- tree$tip.label
# Create a random adjacency matrix
adj <- matrix(sample(c(1,0), 10*10, replace = TRUE), ncol = 10, nrow = 10)
# Fill the diagonals with 1
diag(adj) <- 1
# Calculate their CpB range weighted for 100 tree slices
CpB_RW(tree, n = 100, mat = mat, adj = adj, method = "multisite")
Calculates the rate of accumulation of phylogenetic diversity (CpD) over time slices
Description
This function estimates the rates of accumulation of phylogenetic diveristy (CpD) over time for inputted assemblages.
Usage
CpD(tree, n, mat, criterion = "my", pDO = 5, ncor = 0)
Arguments
tree |
phylo. An ultrametric phylogenetic tree in the "phylo" format. |
n |
numeric. A numeric value indicating the number of temporal slices (method = 1) or the time interval in million years (or phylogenetic diversity) among the tree slices (method = 2). Default is 1. |
mat |
matrix. A presence/absence matrix containing all studied species and sites. |
criterion |
character string. The method for cutting the tree. It can be either "my" (million years) or "PD" (accumulated phylogenetic diversity). Default is "my". |
pDO |
numeric. A value indicating the numeric proportion to define the temporal origin at which the phylogenetic diversity (PD) started to accumulate in a given assemblage. Default is 5%. |
ncor |
numeric. A value indicating the number of cores the user wants to parallelize. Default is 0. |
Details
Parallelization
Users are advised to check the number of available cores within their machines before running parallel programming.
Value
The function returns a data frame containing the assemblages' rates of cumulative phylogenetic diversity (CpD), their total phylogenetic diversity (PD), and their PD origin (pDO).
Author(s)
Matheus Lima de Araujo matheusaraujolima@live.com
See Also
Other cumulative phylogenetic rates analysis: CpE()
, CpB()
, CpB_RW()
Examples
# Generate a random tree
tree <- ape::rcoal(20)
# Create a presence-absence matrix
mat <- matrix(sample(c(1,0), 20*10, replace = TRUE), ncol = 20, nrow = 10)
colnames(mat) <- tree$tip.label
# Calculate the CpD for 100 tree slices
CpD(tree, n = 100, mat = mat)
Calculates the rate of accumulation of phylogenetic endemism (CpE) over time slices
Description
This function estimates the rates of accumulation of phylogenetic endemism (CpE) over time for inputted assemblages.
Usage
CpE(tree, n, mat, criterion = "my", pEO = 5, ncor = 0)
Arguments
tree |
phylo. An ultrametric phylogenetic tree in the "phylo" format. |
n |
numeric. A numeric value indicating the number of temporal slices (method = 1) or the time interval in million years (or phylogenetic diversity) among the tree slices (method = 2). Default is 1. |
mat |
matrix. A presence/absence matrix containing all studied species and sites. |
criterion |
character string. The method for cutting the tree. It can be either "my" (million years) or "PD" (accumulated phylogenetic diversity). Default is "my". |
pEO |
numeric. A value indicating the numeric proportion to define the temporal origin at which the phylogenetic endemism (PE) started to accumulate in a given assemblage. Default is 5%. |
ncor |
numeric. A value indicating the number of cores the user wants to parallelize. Default is 0. |
Details
Parallelization
Users are advised to check the number of available cores within their machines before running parallel programming.
Value
The function returns a data frame containing the assemblages' rates of cumulative phylogenetic endemism (CpE), their total phylogenetic endemism (PE), and their PE origin (pEO).
Author(s)
Matheus Lima de Araujo matheusaraujolima@live.com
See Also
Other cumulative phylogenetic index analysis: CpD()
, CpB()
, CpB_RW()
Examples
# Generate a random tree
tree <- ape::rcoal(20)
# Create a presence-absence matrix
mat <- matrix(sample(c(1,0), 20*10, replace = TRUE), ncol = 20, nrow = 10)
colnames(mat) <- tree$tip.label
# Calculate the CpE for 100 tree slices
CpE(tree, n = 100, mat = mat)
Make a line graph or a grid map of estimated rates of accumulation of a given phylogenetic index.
Description
This function creates a line graph, or a grid map, depicting the estimated rates of accumulation of a given phylogenetic index (e.g., phylogenetic diversity, endemism, etc.), obtained from functions such as CpD()
, CpE()
, CpB()
, or CpB_RW()
.
Usage
CpR_graph(data, rate = NULL, map = NULL, pal = NULL, qtl = FALSE)
Arguments
data |
data frame. The outputted data frame from a CpR-rate function. |
rate |
character string. The desired cumulative phylogenetic rate to plot, which can be phylogenetic diversity (CpD), phylogenetic endemism (CpE), phylogenetic B-diversity (CpB), or phylogenetic B-diversity range-weighted (CpB_RW). Default is NULL, but must be filled with "CpD", "CPE", "CpB", or "CpB_RW". |
map |
spatial data. A grid map containing the assemblages at which the phylogenetic rates were assessed. Default is NULL. |
pal |
character vector. A vector containing a color palette. If none provided, a default color palette will be used. |
qtl |
boolean. Should the color palette be displayed according to CpR-rates quantiles? It can be either TRUE or FALSE. Default is FALSE. |
Value
The function returns a ggplot graph.
Author(s)
Matheus Lima de Araujo matheusaraujolima@live.com
References
See the tutorial on how to use this function on our website.
See Also
Other cumulative phylogenetic rate analysis: CpD()
, CpE()
, CpB()
, CpB_RW()
, CpR_sensitivity()
Other plotting: CpR_sensitivity_plot()
.
Examples
# Generate a random tree
tree <- ape::rcoal(20)
# Create a presence-absence matrix
mat <- matrix(sample(c(1,0), 20*10, replace = TRUE), ncol = 20, nrow = 10)
colnames(mat) <- tree$tip.label
# Calculate the CpD for 100 tree slices
CpD_DF <- CpD(tree, n = 100, mat = mat)
# Plot it using the CpR_graph
CpR_graph(CpD_DF, rate = "CpD")
Runs a sensitivity analysis for rates of accumulation of a given phylogenetic index
Description
This function allows the evaluation of the sensitivity of the estimated rates of accumulation of a given phylogenetic index (e.g., CpD()
, CpE()
, CpB()
, CpB_RW()
) to the number of slices inputted by the user.
Usage
CpR_sensitivity(tree, vec, mat, adj, rate, samp, comp, method, criterion, ncor)
Arguments
tree |
phylo. An ultrametric phylogenetic tree in the "phylo" format. |
vec |
numeric vector. A numeric vector containing a series of numbers of slices. |
mat |
matrix. A presence/absence matrix containing all studied species and sites. |
adj |
matrix. A square adjacency matrix containing the presence/absence information of all sites and their spatially adjacent ones. |
rate |
character string. The desired cumulative phylogenetic rate to be assessed, which can be the phylogenetic diversity (CpD), phylogenetic endemism (CpE), phylogenetic B-diversity (CpB), or phylogenetic B-diversity range-weighted (CpB_RW). Default is NULL, but must be filled with "CpD", "CPE", "CpB_RW", or "CpB". |
samp |
numeric. The number of assemblages, or sites, to be sampled to make the sensitivity analysis. |
comp |
character string. The component of beta-diversity that the user wants to calculate the CpB. It can be either "sorensen", turnover" or "nestedness". This argument works only when "rate = CpB". Default is "sorensen". |
method |
character string. The method for calculating the CpB-rate. It can be either "pairwise" or "multisite". This argument works only when the argument "rate" is set to run for "CpB" or "CpB_RW". Default is "multisite". |
criterion |
character string. The method for cutting the tree. It can be either "my" (million years) or "PD" (accumulated phylogenetic diversity). Default is "my". |
ncor |
numeric. A value indicating the number of cores the user wants to parallelize. Default is 0. |
Details
Parallelization
Users are advised to check the number of available cores within their machines before running parallel programming.
Plotting
For plotting the sensitivity analysis output users can use CpR_sensitivity_plot()
.
Value
This function returns a data frame containing the sensitivity analysis for a given rate of accumulation of a phylogenetic index. This outputted data frame contains, for each row or assemblage, a column with the rate value assessed for each inputted number of slices.
Author(s)
Matheus Lima de Araujo matheusaraujolima@live.com
References
See the tutorial on how to use this function on our website.
See Also
Other cumulative phylogenetic index rate analysis: CpD()
, CpE()
, CpB()
, CpB_RW()
Examples
# Generate a random tree
tree <- ape::rcoal(20)
# Create a presence-absence matrix
mat <- matrix(sample(c(1,0), 20*10, replace = TRUE), ncol = 20, nrow = 10)
colnames(mat) <- tree$tip.label
# Calculate the CpD for 100 tree slices
CpD(tree, n = 100, mat = mat)
# Create a vector of number of slices
vec <- c(25, 50, 75, 100, 125, 150)
# Calculate the sensitivity of the CpD
CpR_sensitivity(tree, vec, mat, rate = "CpD", samp = 5)
Make a plot of the sensitivity analysis evaluated under cumulative phylogenetic rate functions
Description
This function generates a plot of the sensitivity analysis calculated for a given cumulative phylogenetic rate (CpR) assessed through the CpR_sensitivity()
function.
Usage
CpR_sensitivity_plot(sst_output, rate = NULL, stc = "mean")
Arguments
sst_output |
data frame. The outputted data frame from the |
rate |
character string. The desired phylogenetic index rate to display. It can be filled with "CpD", "CPE", "CpB", or "CpB_RW". |
stc |
character string. A statistical measure to summarize the phylogenetic rates and create the plot, which could be filled with "mean", "var", "median", "sd", "min", and "max". Default is "mean". |
Value
The function returns a ggplot graph.
Author(s)
Matheus Lima de Araujo matheusaraujolima@live.com
References
Users can use the CpR_sensitivity_plot()
function for plotting sensitivity analysis outputs.
See Also
CpR sensitivity analysis: CpR_sensitivity()
.
Examples
# Generate a random tree
tree <- ape::rcoal(20)
# Create a presence-absence matrix
mat <- matrix(sample(c(1,0), 20*10, replace = TRUE), ncol = 20, nrow = 10)
colnames(mat) <- tree$tip.label
# Calculate the CpD for 100 tree slices
CpD(tree, n = 100, mat = mat)
# Create a vector of number of slices
vec <- c(25, 50, 75, 100, 125, 150)
# Calculate the sensitivity of the CpD
Sens_out <- CpR_sensitivity(tree, vec, mat, rate = "CpD", samp = 5)
# Plot the sensitity analysis
CpR_sensitivity_plot(Sens_out, rate = "CpD", stc = "mean")
Calculate the tip diversification rates (DR) for a phylogenetic tree
Description
This function computes the tip diversification rates Jetz et al., 2012, or DR, for an inputted ultrametric phylogenetic tree.
Usage
DR(tree)
Arguments
tree |
phylo. An ultrametric phylogenetic tree in the "phylo" format. |
Value
The function returns a data frame containing the tip diversification rates for all species within the inputted phylogenetic tree.
Author(s)
Matheus Lima de Araujo matheusaraujolima@live.com
References
See the tutorial on how to use this function on our website. Jetz, Walter, et al. "The global diversity of birds in space and time." Nature 491.7424 (2012): 444-448. doi:10.1038/nature11631
Examples
# Generate a random tree
tree <- ape::rcoal(20)
# Computing the tip-DR
DR(tree)
Capture general branching information for an inputted phylogenetic tree
Description
This function captures general tree information, including branching, node positions, and depths. It serves as a core function underlying all algorithms for slicing phylogenies.
Usage
nodes_config(tree)
Arguments
tree |
phylo. An ultrametric phylogenetic tree in the "phylo" format. |
Details
This function captures node and edge information from an ultrametric phylogenetic tree. The function provides a data frame containing detailed branching information (within the internal "config" object), a node matrix (within "node_matrix"), and the tree age (within "tree_depth").
More specifically, the "config" object returns the following information: NodeBegin: the node at which a given branch begins. NodeEnd: the node at which a given branch ends. NodeLength: the branch length of that nodes interval. YearBegin: the year at which a given node begins. YearEnd: the year at which a given node ends.
Value
The function returns a phylogenetic tree in the "phylo" format containing three novel pieces of information (stored within "config", "node_matrix", and "tree_depth").
Author(s)
Matheus Lima de Araujo matheusaraujolima@live.com
See Also
Phylogenetic slicing methods: squeeze_tips()
,squeeze_root()
,squeeze_int()
.
Examples
# Generate a random tree
tree <- ape::rcoal(20)
# Capture tree information
tree <- nodes_config(tree)
# Accessing these informations
tree$config # Nodes configurations
tree$node_matrix # Node matrix
tree$tree_depth # Tree age
Presence-absence matrix of Australian passeriformes
Description
This is a presence-absence matrix for passeriformes obtained from Australian grid-cells. Each column represents a specific passeriforme species, while each row corresponds to an assemblage (or grid cell) within the Australian grid-map. All passerine range maps were sourced from the BirdLife platform.
Usage
pass_mat
Format
Matrix
Source
Phylogenetic tree of passerines from Australia
Description
This is a list contaning 100 phylogenetic trees of passerines from Australia. Each object within the list corresponds to a sampled phylogeny of class "phylo". The phylogenies are subsets obtained from the global bird phylogeny (https://birdtree.org/) made available by Jetz et al. (2012) in their published research, "The global diversity of birds in space and time".
Usage
pass_trees
Format
List of phylogenetic trees of format phylo
Source
Slices a phylogenetic tree into multiple temporal slices
Description
This function slices a phylogenetic tree into multiple slices, spaced equally either in million years or intervals of phylogenetic diversity (PD).
Usage
phylo_pieces(tree, n, criterion, method, timeSteps, dropNodes, returnTree)
Arguments
tree |
phylo. An ultrametric phylogenetic tree in the "phylo" format. |
n |
numeric. A numeric value indicating either the number of temporal slices (method = 1) or the time interval in million years (or phylogenetic diversity) among the tree slices (method = 2). Default is 1. |
criterion |
character string. The method for slicing the tree. It can be either "my" (million years) or "PD" (accumulated phylogenetic diversity). Default is "my". |
method |
numerical. A numerical value indicating the method to make the multiple slices. Setting "method = 1" will slice the phylogeny based on an "n" number of slices. If method = 2, the slices will be created based on a temporal interval. Default is 1. |
timeSteps |
logical. A logical value indicating whether the vector containing the time-steps used for creating the multiple slices should be returned. If "timeSteps = TRUE", then it returns a list containing both the time vector and a list with the multiple tree slices. Default is FALSE. |
dropNodes |
logical. A logical value indicating whether the nodes that were sliced (void nodes, presenting no branch length) should be preserved in the node matrix. Default is FALSE. |
returnTree |
logical. A logical value indicating whether the original input tree should be returned with its slices in a list. Default is FALSE. |
Value
The function returns a list containing multiple slices of a phylogenetic tree. The slices list is ordered from roots to tips. Thus, the first object within the outputted list is the root-slice, whereas the last is the tips-slice.
Author(s)
Matheus Lima de Araujo matheusaraujolima@live.com
See Also
Other slicing methods: squeeze_root()
, squeeze_tips()
, squeeze_int()
, prune_tips()
Examples
# Generate a random tree
tree <- ape::rcoal(20)
# Cuts a phylogeny into multiple temporal slices
tree <- phylo_pieces(tree, n = 3, criterion = "my", method = 1)
# Plotting the three slices of our phylogeny
plot(tree[[1]])
plot(tree[[2]])
plot(tree[[3]])
Collapse the tips of a phylogenetic tree based on a temporal threshold
Description
This function collapses, or prune, the tips of a phylogenetic tree based on an inputted temporal threshold.
Usage
prune_tips(tree, time, qtl = FALSE, method = 1)
Arguments
tree |
phylo. An ultrametric phylogenetic tree in the "phylo" format. |
time |
numeric or numeric vector. A numeric value, or vector, containing the temporal threshold(s) in million years for pruning the tree tips. It must be within the interval of the tips ages present in the phylogenetic tree. |
qtl |
logical. A logical value indicating whether the user wants to use the quantile values of the tip ages to prune the tree. Default is FALSE |
method |
numerical. A numerical value indicating the method to prune the tips. If "method = 1", the function will prune the tips originating after an inputted temporal threshold. If method = 2, the function will prune the tips originating before a temporal threshold. Default is 1. |
Details
It uses the tip ages location in relation to an inputted time threshold to prune the phylogenetic tree. Setting "method = 2" makes slices based on the quantile distribution of tip ages available within the phylogenetic tree.
Value
The function returns a pruned tree in the "phylo" format if a single temporal threshold was inputted. Otherwise, if a vector of thresholds was inputted, it returns an list of pruned trees.
Author(s)
Matheus Lima de Araujo matheusaraujolima@live.com
References
See the tutorial on how to use this function on our website.
See Also
Other slicing methods: squeeze_root()
,squeeze_tips()
,squeeze_int()
,phylo_pieces()
Examples
# Generate a random tree
tree <- ape::rcoal(20)
# Pruning the tips originating after 0.3 million years
tree1 <- prune_tips(tree, time = 0.1)
# Plot it
plot(tree1)
# Pruning the tips based on quantiles of tip ages
tree2 <- prune_tips(tree, time = c(0.25, 0.75), qtl = TRUE)
plot(tree2[[1]])
plot(tree2[[2]])
Calculates the relative value of a phylogenetic index in a temporal sequence of phylogenetic slices.
Description
This function estimates the relative value of a phylogenetic index in a sequence of multiple phylogenetic slices cut from roots to tips.
Usage
r_phylo(tree, n, mat, adj, index = NULL, comp, method, criterion = "my", ncor = 0)
Arguments
tree |
phylo. An ultrametric phylogenetic tree in the "phylo" format. |
n |
numeric. A numeric value indicating either the number of temporal slices (method = 1) or the time interval in million years (or phylogenetic diversity) among the tree slices (method = 2). Default is 1. |
mat |
matrix. A presence/absence matrix containing all studied species and sites. |
adj |
matrix. A square adjacency matrix containing the presence/absence information of all sites and their spatially adjacent ones. |
index |
character string. The phylogenetic index to be calculated over the phylogenetic slices. It can be set as "PD" (phylogenetic diversity), "PE" (phylogenetic endemism), "PB" (phylogenetic B-diversity), or "PB_RW" (phylogenetic B-diversity range-weighted). |
comp |
character string. The component of phylogenetic beta-diversity to obtain the relative value. It can be "sorensen", "turnover", or "nestedness". Default is "sorensen". |
method |
character string. The method for calculating phylogenetic beta-diversity. It can be obtained through a "pairwise" or "multisite" approach. Default is "multisite". |
criterion |
character string. The method for cutting the tree. It can be either "my" (million years) or "PD" (accumulated phylogenetic diversity). Default is "my". |
ncor |
numeric. A value indicating the number of cores the user wants to parallel. Default is 0. |
Details
The "adj" argument
Must be filled only for phylogenetic B-diversity ("PB") or it's range weight version ("PB_RW", defined in "index").
Parallelization
Users are advised to check the number of cores available within their machines before running in parallel programming.
Value
The function returns a list where each object contains a vector (of length "n") with the relative phylogenetic index, from the phylogeny root to the tips, from the inputted assemblage.
Author(s)
Matheus Lima de Araujo matheusaraujolima@live.com
See Also
Other cumulative phylogenetic rates analysis: CpD()
, CpE()
, CpB()
, CpB_RW()
Examples
# Generate a random tree
tree <- ape::rcoal(20)
# Create a presence-absence matrix
mat <- matrix(sample(c(1,0), 20*10, replace = TRUE), ncol = 20, nrow = 10)
colnames(mat) <- tree$tip.label
# Create a random adjacency matrix
adj <- matrix(sample(c(1,0), 10*10, replace = TRUE), ncol = 10, nrow = 10)
# Fill the diagonals with 1
diag(adj) <- 1
# Calculate the relative PD for 100 slices
rPD <- r_phylo(tree, n = 100, mat = mat, index = "PD")
# Plot the relative PD of the first assemblage
plot(rPD[[1]])
# Calculate the relative PE for 100 slices
rPE <- r_phylo(tree, n = 100, mat = mat, index = "PE")
# Plot the relative PE of the first assemblage
plot(rPE[[1]])
# Calculate the relative PB for 100 slices
rPB <- r_phylo(tree, n = 100, mat = mat, adj = adj, index = "PB")
# Plot the relative PB of the first assemblage
plot(rPB[[1]])
# Calculate the relative PB_RW for 100 slices
rPB_RW <- r_phylo(tree, n = 100, mat = mat, adj = adj, index = "PB_RW")
# Plot the relative PB_RW of the first assemblage
plot(rPB_RW[[1]])
Objects exported from other packages
Description
These objects are imported from other packages. Follow the links below to see their documentation.
Slices a temporal interval within a phylogenetic tree
Description
This function slices a temporal interval located within an ultrametric phylogenetic tree.
Usage
squeeze_int(tree, from, to, invert = FALSE, criterion = "my", dropNodes = FALSE)
Arguments
tree |
phylo. An ultrametric phylogenetic tree in the "phylo" format. |
from |
numeric. A temporal threshold value that determines the time at which the interval should start. |
to |
numeric. A temporal threshold value that determines the time at which the interval should end. |
invert |
logical. A logical value indicating if the desired slice must be executed inside (invert = FALSE) or outside (invert = TRUE) the defined interval. Using the argument as TRUE will return a list containing a root and tip slices. Default is FALSE. |
criterion |
character string. The method for cutting the tree. It can be either "my" (million years) or "PD" (accumulated phylogenetic diversity). Default is "my". |
dropNodes |
logical. A logical value indicating whether the nodes that were sliced (void nodes, presenting no branch length) should be preserved in the node matrix. Default is FALSE. |
Details
Slicing approach
To return a given phylogenetic interval, this function simultaneously applies simultaneously the same logic as squeeze_tips()
and squeeze_root()
. If "invert = TRUE", then the temporal interval set will be excluded from the phylogeny, returning a list containing a tip and a root slices.
Value
The function returns an time-slice interval of a phylogenetic tree in the "phylo" format.
Author(s)
Matheus Lima de Araujo matheusaraujolima@live.com
References
See the tutorial on how to use this function on our website.
See Also
Other slicing methods: squeeze_tips()
, squeeze_root()
, phylo_pieces()
, prune_tips()
Examples
# Generate a random tree
tree <- ape::rcoal(20)
# Slice an interval from 0.5 to 0.2 million years
tree <- squeeze_int(tree, from = 0.5, to = 0.2)
# Plot it
plot(tree)
Slices a phylogenetic tree following a 'rootward' orientation
Description
This function slices a phylogenetic tree in a 'rootward' orientation, starting from the root and moving towards the tips of the tree.
Usage
squeeze_root(tree, time, criterion = "my", dropNodes = FALSE)
Arguments
tree |
phylo. An ultrametric phylogenetic tree in the "phylo" format. |
time |
numeric. A value that determines the time, or accumulated phylogenetic diversity (PD), at which the tree should be cut. |
criterion |
character string. The method for cutting the tree. It can be either "my" (million years) or "PD" (accumulated phylogenetic diversity). Default is "my". |
dropNodes |
logical. A logical value indicating whether the nodes that were sliced (void nodes, presenting no branch length) should be preserved in the node matrix. Default is FALSE. |
Details
Slicing approach
The treesliceR package uses a simple approach for cutting phylogenies, which reduces branch lengths in relation to an inputted temporal threshold.
Value
The function returns a time-slice of an inputted phylogenetic tree in the "phylo" format, following a 'rootward' orientation.
Author(s)
Matheus Lima de Araujo matheusaraujolima@live.com
References
See the tutorial on how to use this function on our website.
See Also
Other slicing methods: squeeze_tips()
, squeeze_int()
, prune_tips()
, phylo_pieces()
.
Examples
# Generate a random tree
tree <- ape::rcoal(20)
# Slice "rootwardly" the phylogeny at 0.1 million years
tree <- squeeze_root(tree, time = 0.1)
# Plot it
plot(tree)
Slices a phylogenetic tree following a 'tipward' orientation
Description
This function slices a phylogenetic tree in a 'tipward' orientation, starting from the tips and moving towards the root of the tree.
Usage
squeeze_tips(tree, time, criterion = "my", dropNodes = FALSE)
Arguments
tree |
phylo. An ultrametric phylogenetic tree in the "phylo" format. |
time |
numeric. A value that determines the time, or accumulated phylogenetic diversity (PD), at which the tree should be cut. |
criterion |
character string. The method for cutting the tree. It can be either "my" (million years) or "PD" (accumulated phylogenetic diversity). Default is "my". |
dropNodes |
logical. A logical value indicating whether the nodes that were sliced (void nodes, presenting no branch length) should be preserved in the node matrix. Default is FALSE. |
Details
Slicing approach The treesliceR package uses a simple approach for cutting phylogenies, which reduces branch lengths in relation to an inputted temporal threshold.
Value
The function returns a time-slice of an inputted phylogenetic tree in the "phylo" format, following a 'tipward' orientation.
Author(s)
Matheus Lima de Araujo matheusaraujolima@live.com
References
See the tutorial on how to use this function on our website.
See Also
Other slicing methods: squeeze_root()
, squeeze_int()
, phylo_pieces()
, prune_tips()
.
Examples
# Generate a random tree
tree <- ape::rcoal(20)
# Slice "tipwardly" the phylogeny at 0.1 million years
tree <- squeeze_tips(tree, time = 0.1)
# Plot it
plot(tree)