Title: | Procrustes Application to Cophylogenetic Analysis |
---|---|
Description: | Procrustes analyses to infer co-phylogenetic matching between pairs of phylogenetic trees. |
Authors: | Juan Antonio Balbuena <[email protected]>, Timothee Poisot <[email protected]>, Matthew Hutchinson <[email protected]>, Fernando Cagua <[email protected]>; see PLoS ONE Balbuena et al 2013 <https://doi.org/10.1371/journal.pone.0061048> |
Maintainer: | Matthew Hutchinson <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.2 |
Built: | 2025-02-22 03:23:46 UTC |
Source: | https://github.com/matthutchinson1/paco |
Translates the distance matrices of 'host' and 'parasite' phylogenies into Principal Coordinates, as needed for Procrustes superimposition.
add_pcoord(D, correction = "none")
add_pcoord(D, correction = "none")
D |
A list with objects H, P, and HP, as returned by |
correction |
In some cases, phylogenetic distance matrices are non-Euclidean which generates negative eigenvalues when those matrices are translated into Principal Coordinates. There are several methods to correct negative eigenvalues. Correction options available here are "cailliez", "lingoes", and "none". The "cailliez" and "lingoes" corrections add a constant to the eigenvalues to make them non-negative. Default is "none". |
The list that was input as the argument ‘D’ with four new elements; the Principal Coordinates of the ‘host’ distance matrix and the Principal Coordinates of the ‘parasite’ distance matrix, as well as, a ‘correction’ object stating the correction used for negative eigenvalues and a ‘note’ object stating whether or not negative eigenvalues were present and therefore corrected.
To find the Principal Coordinates of each distance matrix, we internally a modified version of the function ape::pcoa
that uses vegan::eigenvals
and zapsmall
data(gopherlice) library(ape) gdist <- cophenetic(gophertree) ldist <- cophenetic(licetree) D <- prepare_paco_data(gdist, ldist, gl_links) D <- add_pcoord(D)
data(gopherlice) library(ape) gdist <- cophenetic(gophertree) ldist <- cophenetic(licetree) D <- prepare_paco_data(gdist, ldist, gl_links) D <- add_pcoord(D)
One part of example data. The associations between pocket gophers and their chewing lice ectoparasites.
data(gopherlice)
data(gopherlice)
One part of example data. The phylogeny of pocket gophers.
data(gopherlice)
data(gopherlice)
One part of example data. The phylogeny of chewing lice.
data(gopherlice)
data(gopherlice)
Two sets of Principal Coordinates are superimposed by Procrustes superimposition. The sum of squared residuals of this superimposition give an indication of how congruent the two datasets are. For example, in a biological system the two sets of Principal Coordinates can be composed from the phylogenetic distance matrices of two interacting groups. The congruence measured by PACo indicates how concordant the two phylogenies are based on observed ecological interactions between them.
PACo( D, nperm = 1000, seed = NA, method = "r0", symmetric = FALSE, proc.warnings = TRUE, shuffled = FALSE )
PACo( D, nperm = 1000, seed = NA, method = "r0", symmetric = FALSE, proc.warnings = TRUE, shuffled = FALSE )
D |
A list of class |
nperm |
The number of permutations to run. In each permutation, the network is randomized following the |
seed |
An integer with which to begin the randomizations. If the same seed is used the randomizations will be the same and results reproducible. If |
method |
The method with which to permute association matrices: "r0", "r1", "r2", "c0", "swap", "quasiswap", "backtrack", "tswap", "r00". Briefly, "r00" produces the least conservative null model as it only maintains total fill (i.e., total number of interactions). "r0" and "c0" maintain the row sums and column sums, respectively, as well as the total number of interactions. "backtracking" and any of the "swap" algorithms conserve the total number of interactions in the matrix, as well as both row and column sums. Finally, "r1" and "r2" conserve the row sums, the total number of interactions, and randomize based on observed interaction frequency. See |
symmetric |
Logical. Whether or not to use the symmetric Procrustes statistic, or not. When |
proc.warnings |
Logical. Make any warnings from the Procrustes superimposition callable. If |
shuffled |
Logical. Return the Procrustes sum of squared residuals for every permutation of the network. When |
A paco
object that now includes (alongside the Principal Coordinates and input distance matrices) the PACo sum of sqaured residuals, a p-value for this statistic, and the PACo statistics for each randomisation of the network if shuffled=TRUE in the PACo call.
Any call of PACo in which the distance matrices have differing dimensions (i.e., different numbers of tips of the two phylogenies) will produce warnings from the vegan::procrustes
function. These warnings require no action by the user but are merely letting the user know that, as the distance matrices had differing dimensions, their Principal Coordinates have differing numbers of columns. vegan::procrustes
deals with this internally by adding columns of zeros to the smaller of the two until the are the same size.
data(gopherlice) require(ape) gdist <- cophenetic(gophertree) ldist <- cophenetic(licetree) D <- prepare_paco_data(gdist, ldist, gl_links) D <- add_pcoord(D) D <- PACo(D, nperm=10, seed=42, method="r0") print(D$gof)
data(gopherlice) require(ape) gdist <- cophenetic(gophertree) ldist <- cophenetic(licetree) D <- prepare_paco_data(gdist, ldist, gl_links) D <- add_pcoord(D) D <- PACo(D, nperm=10, seed=42, method="r0") print(D$gof)
Uses a jackknife procedure to perform bias correction on procrustes residuals (i.e. interactions) that are indicative of the degree to which individual interactions are more supportive of a hypothesis of phylogenetic congruence than others. Interactions are iteratively removed, the global fit of the two phylogenies is reassessed and bias in observed residuals calculated and corrected.
paco_links(D, .parallel = FALSE, proc.warnings = TRUE)
paco_links(D, .parallel = FALSE, proc.warnings = TRUE)
D |
A list of class |
.parallel |
If TRUE, calculate the jackknife contribution in parallel using the backend provided by foreach. |
proc.warnings |
As in PACo. If |
The input list of class paco
with the added object jackknife which contains the bias-corrected residual for each link.
data(gopherlice) require(ape) gdist <- cophenetic(gophertree) ldist <- cophenetic(licetree) D <- prepare_paco_data(gdist, ldist, gl_links) D <- add_pcoord(D) D <- PACo(D, nperm=10, seed=42, method="r0") D <- paco_links(D)
data(gopherlice) require(ape) gdist <- cophenetic(gophertree) ldist <- cophenetic(licetree) D <- prepare_paco_data(gdist, ldist, gl_links) D <- add_pcoord(D) D <- PACo(D, nperm=10, seed=42, method="r0") D <- paco_links(D)
Simple wrapper to make sure that the matrices are sorted accordingly and to group them together into a paco object (effectively a list) that is then passed to the remaining steps of PACo analysis.
prepare_paco_data(H, P, HP)
prepare_paco_data(H, P, HP)
H |
Host distance matrix. This is the distance matrix upon which the other will be superimposed. We term this the host matrix in reference to the original cophylogeny studies between parasites and their hosts, where parasite evolution was thought to track host evolution hence why the parasite matrix is superimposed on the host. |
P |
Parasite distance matrix. The distance matrix that will be superimposed on the host matrix. As mentioned above, this is the group that is assumed to track the evolution of the other. |
HP |
Host-parasite association matrix, hosts in rows. This should be a binary matrix. If host species aren't in the rows, the matrix will be translated internally. |
A list with objects H, P, HP to be passed to further functions for PACo analysis.
data(gopherlice) library(ape) gdist <- cophenetic(gophertree) ldist <- cophenetic(licetree) D <- prepare_paco_data(gdist, ldist, gl_links)
data(gopherlice) library(ape) gdist <- cophenetic(gophertree) ldist <- cophenetic(licetree) D <- prepare_paco_data(gdist, ldist, gl_links)
Takes the Procrustes object from vegan::procrustes
of the global superimpostion and pulls out either the residual matrix of superimposition or the residual of each individual interaction (link between host and parasite).
residuals_paco(object, type = "interaction")
residuals_paco(object, type = "interaction")
object |
An obejct of class |
type |
Character string. Whether the whole residual matrix ( |
If type=interaction
, a named vector of the Procrustes residuals is returned where names are the interactions. If type=matrix
, a matrix of residuals from Procrustes superimposition is returned.
data(gopherlice) library(ape) gdist <- cophenetic(gophertree) ldist <- cophenetic(licetree) D <- prepare_paco_data(gdist, ldist, gl_links) D <- add_pcoord(D, correction='cailliez') D <- PACo(D, nperm=100, seed=42, method='r0') residuals_paco(D$proc)
data(gopherlice) library(ape) gdist <- cophenetic(gophertree) ldist <- cophenetic(licetree) D <- prepare_paco_data(gdist, ldist, gl_links) D <- add_pcoord(D, correction='cailliez') D <- PACo(D, nperm=100, seed=42, method='r0') residuals_paco(D$proc)