prob_statistic: Frequencies of the associations for the posterior probability...

prob_statisticR Documentation

Frequencies of the associations for the posterior probability trees

Description

Computes frequencies (or residual/corrected frequencies) of the host-symbiont associations for pairs (H and S) of posterior probability trees from the statistics generatedwith GD (Geodesic Distances), PACo (PACo) or ParaFit(ParaFit).

Usage

prob_statistic(
  ths,
  HS,
  mTreeH,
  mTreeS,
  freqfun = "paco",
  fx,
  percentile = 0.01,
  correction = "none",
  symmetric = FALSE,
  ei.correct = "none",
  algm = "maxcong",
  proc.warns = FALSE,
  strat = "sequential",
  cl = 1
)

Arguments

ths

List of trimmed matrices produced by trimHS_maxC() or trimHS_maxI().

HS

Host-Symbiont association matrix.

mTreeH

Number of posterior-probability trees of host.

mTreeS

Number of posterior-probability trees of symbiont.

freqfun

The global-fit method to compute using the posterior probability trees. Options are "geoD" (Geodesic Distances), "paco" (PACo) or "paraF" (ParaFit). It should be the same method used to obtain "fx".

fx

Vector of statistics produced with max_cong() or max_incong() for GD, PACo or ParaFit.

percentile

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

correction

Correction to be assumed. The default value is "none". If = "res.fq", a residual frequency value (observed - expected frequency) is computed for each host-symbiont association that maximizes phylogenetic congruence. If = "diff.fq", a corrected frequency value (observed in p - observed in (p-1)) is computed for each host-symbiont association. It should be the same correction used to obtain "fx".

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.

algm

Only required if correction = "none". Specifies the algorithm that has been used to obtain "fx" without correction. Use = "maxcong" for max_cong(), and = "maxincong" for max_incong().

proc.warns

Switches on/off trivial warnings returned when treeH and treeS differ in size (number of tips). Default is FALSE.

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 matrix with the value of the statistics for each of the probability trees.

Examples


data("nuc_cp")
N = 10 #for the example, we recommend 1e+4 value
n = 15
# Maximizing congruence (not run)
NPc <- max_cong(np_matrix, NUCtr, CPtr, n, N, method = "paco",
                symmetric = FALSE, ei.correct = "sqrt.D",
                percentile = 0.01, strat = "parallel", cl = 8)
THSc <- trimHS_maxC(N, np_matrix, n)
pp_treesPACOo_cong <- prob_statistic(THSc, np_matrix, NUC_500tr[1:10],
                         CP_500tr[1:10], freqfun = "paco", NPc,
                         percentile = 0.01, correction = "none",
                         algm = "maxcong", symmetric = FALSE,
                         ei.correct = "sqrt.D",
                         strat = "parallel", cl = 8)

# Maximizing incongruence
NPi <- max_incong(np_matrix, NUCtr, CPtr, n, N, method = "paco",
                  symmetric = FALSE, ei.correct = "sqrt.D",
                  percentile = 0.99, diff.fq = TRUE)
THSi <- trimHS_maxI(N, np_matrix, n)
pp_treesPACOo_incong <- prob_statistic(THSi, np_matrix, NUC_500tr[1:5],
                                 CP_500tr[1:5], freqfun = "paco", NPi,
                                 percentile = 0.99, correction = "diff.fq",
                                 symmetric = FALSE, ei.correct = "sqrt.D",
                                 strat = "parallel", cl = 8)



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