Title: | To Slice Phylogenetic Trees and Infer Evolutionary Patterns Over Time |
---|---|
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. |
Authors: | Matheus Lima Araujo [aut, cre, cph] , Luiz Gabriel Souza e Souza Ferreira [aut] , Gabriel Nakamura [aut] , Marco Tulio Pacheco Coelho [aut] , Thiago Fernando Rangel [aut] |
Maintainer: | Matheus Lima Araujo <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.1 |
Built: | 2024-11-21 04:51:44 UTC |
Source: | https://github.com/araujomat/treeslicer |
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.
AU_adj
AU_adj
Matrix
This is a gridded shapefile of Australia, with grid cells at a 0.5-degree resolution.
AU_grid
AU_grid
Shapefile
This function estimates the rates of accumulation of phylogenetic B-diversity (CpB) over time for inputted assemblages.
CpB(tree, n, mat, adj, comp, method, criterion, pBO, ncor)
CpB(tree, n, mat, adj, comp, method, criterion, pBO, ncor)
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. |
Parallelization
Users are advised to check the number of available cores within their machines before running parallel programming.
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).
Matheus Lima de Araujo [email protected]
See the tutorial on how to use this function on our website.
Other cumulative phylogenetic index analysis: CpD()
, CpE()
, CpB_RW()
# 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")
# 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")
This function estimates the range-weighted rates of accumulation of phylogenetic B-diversity (CpB_RW) over time for inputted assemblages.
CpB_RW(tree, n, mat, adj, method = "multisite", criterion = "my", pBO = 5, ncor = 0)
CpB_RW(tree, n, mat, adj, method = "multisite", criterion = "my", pBO = 5, ncor = 0)
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. |
Parallelization
Users are advised to check the number of available cores within their machines before running parallel programming.
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).
Matheus Lima de Araujo [email protected]
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
Other cumulative phylogenetic index analysis: CpD()
, CpE()
, CpB()
# 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")
# 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")
This function estimates the rates of accumulation of phylogenetic diveristy (CpD) over time for inputted assemblages.
CpD(tree, n, mat, criterion = "my", pDO = 5, ncor = 0)
CpD(tree, n, mat, criterion = "my", pDO = 5, ncor = 0)
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. |
Parallelization
Users are advised to check the number of available cores within their machines before running parallel programming.
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).
Matheus Lima de Araujo [email protected]
Other cumulative phylogenetic rates analysis: CpE()
, CpB()
, CpB_RW()
# 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)
# 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)
This function estimates the rates of accumulation of phylogenetic endemism (CpE) over time for inputted assemblages.
CpE(tree, n, mat, criterion = "my", pEO = 5, ncor = 0)
CpE(tree, n, mat, criterion = "my", pEO = 5, ncor = 0)
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. |
Parallelization
Users are advised to check the number of available cores within their machines before running parallel programming.
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).
Matheus Lima de Araujo [email protected]
Other cumulative phylogenetic index analysis: CpD()
, CpB()
, CpB_RW()
# 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)
# 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)
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()
.
CpR_graph(data, rate = NULL, map = NULL, pal = NULL, qtl = FALSE)
CpR_graph(data, rate = NULL, map = NULL, pal = NULL, qtl = FALSE)
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. |
The function returns a ggplot graph.
Matheus Lima de Araujo [email protected]
See the tutorial on how to use this function on our website.
Other cumulative phylogenetic rate analysis: CpD()
, CpE()
, CpB()
, CpB_RW()
, CpR_sensitivity()
Other plotting: CpR_sensitivity_plot()
.
# 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")
# 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")
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.
CpR_sensitivity(tree, vec, mat, adj, rate, samp, comp, method, criterion, ncor)
CpR_sensitivity(tree, vec, mat, adj, rate, samp, comp, method, criterion, ncor)
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. |
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()
.
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.
Matheus Lima de Araujo [email protected]
See the tutorial on how to use this function on our website.
Other cumulative phylogenetic index rate analysis: CpD()
, CpE()
, CpB()
, CpB_RW()
# 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)
# 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)
This function generates a plot of the sensitivity analysis calculated for a given cumulative phylogenetic rate (CpR) assessed through the CpR_sensitivity()
function.
CpR_sensitivity_plot(sst_output, rate = NULL, stc = "mean")
CpR_sensitivity_plot(sst_output, rate = NULL, stc = "mean")
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". |
The function returns a ggplot graph.
Matheus Lima de Araujo [email protected]
Users can use the CpR_sensitivity_plot()
function for plotting sensitivity analysis outputs.
CpR sensitivity analysis: CpR_sensitivity()
.
# 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")
# 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")
This function computes the tip diversification rates Jetz et al., 2012, or DR, for an inputted ultrametric phylogenetic tree.
DR(tree)
DR(tree)
tree |
phylo. An ultrametric phylogenetic tree in the "phylo" format. |
The function returns a data frame containing the tip diversification rates for all species within the inputted phylogenetic tree.
Matheus Lima de Araujo [email protected]
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
# Generate a random tree tree <- ape::rcoal(20) # Computing the tip-DR DR(tree)
# Generate a random tree tree <- ape::rcoal(20) # Computing the tip-DR DR(tree)
This function captures general tree information, including branching, node positions, and depths. It serves as a core function underlying all algorithms for slicing phylogenies.
nodes_config(tree)
nodes_config(tree)
tree |
phylo. An ultrametric phylogenetic tree in the "phylo" format. |
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.
The function returns a phylogenetic tree in the "phylo" format containing three novel pieces of information (stored within "config", "node_matrix", and "tree_depth").
Matheus Lima de Araujo [email protected]
Phylogenetic slicing methods: squeeze_tips()
,squeeze_root()
,squeeze_int()
.
# 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
# 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
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.
pass_mat
pass_mat
Matrix
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".
pass_trees
pass_trees
List of phylogenetic trees of format phylo
This function slices a phylogenetic tree into multiple slices, spaced equally either in million years or intervals of phylogenetic diversity (PD).
phylo_pieces(tree, n, criterion, method, timeSteps, dropNodes, returnTree)
phylo_pieces(tree, n, criterion, method, timeSteps, dropNodes, returnTree)
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. |
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.
Matheus Lima de Araujo [email protected]
Other slicing methods: squeeze_root()
, squeeze_tips()
, squeeze_int()
, prune_tips()
# 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]])
# 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]])
This function collapses, or prune, the tips of a phylogenetic tree based on an inputted temporal threshold.
prune_tips(tree, time, qtl = FALSE, method = 1)
prune_tips(tree, time, qtl = FALSE, method = 1)
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. |
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.
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.
Matheus Lima de Araujo [email protected]
See the tutorial on how to use this function on our website.
Other slicing methods: squeeze_root()
,squeeze_tips()
,squeeze_int()
,phylo_pieces()
# 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]])
# 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]])
This function estimates the relative value of a phylogenetic index in a sequence of multiple phylogenetic slices cut from roots to tips.
r_phylo(tree, n, mat, adj, index = NULL, comp, method, criterion = "my", ncor = 0)
r_phylo(tree, n, mat, adj, index = NULL, comp, method, criterion = "my", ncor = 0)
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. |
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.
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.
Matheus Lima de Araujo [email protected]
Other cumulative phylogenetic rates analysis: CpD()
, CpE()
, CpB()
, CpB_RW()
# 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]])
# 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]])
This function slices a temporal interval located within an ultrametric phylogenetic tree.
squeeze_int(tree, from, to, invert = FALSE, criterion = "my", dropNodes = FALSE)
squeeze_int(tree, from, to, invert = FALSE, criterion = "my", dropNodes = FALSE)
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. |
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.
The function returns an time-slice interval of a phylogenetic tree in the "phylo" format.
Matheus Lima de Araujo [email protected]
See the tutorial on how to use this function on our website.
Other slicing methods: squeeze_tips()
, squeeze_root()
, phylo_pieces()
, prune_tips()
# 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)
# 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)
This function slices a phylogenetic tree in a 'rootward' orientation, starting from the root and moving towards the tips of the tree.
squeeze_root(tree, time, criterion = "my", dropNodes = FALSE)
squeeze_root(tree, time, criterion = "my", dropNodes = FALSE)
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. |
Slicing approach
The treesliceR package uses a simple approach for cutting phylogenies, which reduces branch lengths in relation to an inputted temporal threshold.
The function returns a time-slice of an inputted phylogenetic tree in the "phylo" format, following a 'rootward' orientation.
Matheus Lima de Araujo [email protected]
See the tutorial on how to use this function on our website.
Other slicing methods: squeeze_tips()
, squeeze_int()
, prune_tips()
, phylo_pieces()
.
# 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)
# 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)
This function slices a phylogenetic tree in a 'tipward' orientation, starting from the tips and moving towards the root of the tree.
squeeze_tips(tree, time, criterion = "my", dropNodes = FALSE)
squeeze_tips(tree, time, criterion = "my", dropNodes = FALSE)
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. |
Slicing approach The treesliceR package uses a simple approach for cutting phylogenies, which reduces branch lengths in relation to an inputted temporal threshold.
The function returns a time-slice of an inputted phylogenetic tree in the "phylo" format, following a 'tipward' orientation.
Matheus Lima de Araujo [email protected]
See the tutorial on how to use this function on our website.
Other slicing methods: squeeze_root()
, squeeze_int()
, phylo_pieces()
, prune_tips()
.
# 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)
# 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)