max_cong: Algortihm for maximizing congruence between two phylogenies

max_congR Documentation

Algortihm for maximizing congruence between two phylogenies

Description

Prunes the host (H) and symbiont (S) phylogenies to conform with trimmed matrices and computes the given global fit method, Geodesic distances (GD), Procrustes Approach to Cophylogeny (PACo) or ParaFit (Legendre et al. 2002) between the pruned trees. Then, determines the frequency or corrected residual of each host-symbiont association occurring in a given percentile of cases that maximize phylogenetic congruence.

Usage

max_cong(
  HS,
  treeH,
  treeS,
  n,
  N,
  method = "paco",
  symmetric = FALSE,
  ei.correct = "none",
  percentile = 0.01,
  res.fq = TRUE,
  strat = "sequential",
  cl = 1
)

Arguments

HS

Host-Symbiont association matrix.

treeH

Host phyolgeny. An object of class "phylo".

treeS

Symbiont phylogeny. An object of class "phylo".

n

Number of unique associations.

N

Number of runs.

method

Specifies the desired global-fit method (GD, PACo or ParaFit). The default is PACo. Options are "geoD" (Geodesic Distances), "paco" (PACo) or "paraF" (ParaFit).

symmetric

Specifies the type of Procrustes superimposition. Default is FALSE, indicates that the superposition is applied asymmetrically (S depends on H). If TRUE, PACo is applied symmetrically (dependency between S and H is reciprocal).

ei.correct

Specifies how to correct potential negative eigenvalues from the conversion of phylogenetic distances into Principal Coordinates: "none" (the default) indicates that no correction is applied, particularly if H and S are ultrametric; "sqrt.D" takes the element-wise square-root of the phylogenetic distances; "lingoes" and "cailliez" apply the classical Lingoes and Cailliez corrections, respectively.

percentile

Percentile to evaluate (p). Default is 0.01 (1\%).

res.fq

Determines whether a correction to avoid one-to-one associations being overrepresented in the percentile evaluated. If TRUE (default) a residual frequency value (observed - expected frequency) is computed for each host-symbiont association.

strat

Flag indicating whether execution is to be "sequential" or "parallel". Default is "sequential", resolves R expressions sequentially in the current R process. If "parallel" resolves R expressions in parallel in separate R sessions running in the background.

cl

Number of cluster to be used for parallel computing. parallelly::availableCores() returns the number of clusters available. Default is cl = 1 resulting in "sequential" execution.

Value

A dataframe with host-symbiont associations in rows. The first and second columns display the names of the host and symbiont terminals, respectively. The third column designates the host-symbiont association by pasting the names of the terminals, and the fourth column displays the frequency of occurrence of each host-symbiont association in p. If res.fq = TRUE, column 5 displays the corrected frequencies as a residual.

NOTE

If the node.label object in both trees contains NAs or empty values (i.e. no numeric value). All nodes should have a value. Else remove node labels within the "phylo" class tree with tree$node.label <- NULL. For more details, see distory::dist.multiPhylo()

Examples

data(nuc_pc)
N = 1 #for the example, we recommend 1e+4 value
n = 15
NPc <- max_cong(np_matrix, NUCtr, CPtr, n, N, method = "paco",
                symmetric = FALSE, ei.correct = "sqrt.D",
                percentile = 0.01, res.fq = FALSE)


Rtapas documentation built on June 22, 2024, 10:47 a.m.