polyToDistMat: Calculates the distance matrix from a list coefficient...

View source: R/distFunctions.R

polyToDistMatR Documentation

Calculates the distance matrix from a list coefficient matrices

Description

Calculates the distance matrix from a list coefficient matrices

Usage

polyToDistMat(
  coefficientMatrices,
  method = c("fraction", "logDiff", "wLogDiff", "pa", "ap"),
  numThreads = -1
)

Arguments

coefficientMatrices

list of coefficient matrices

method

method to use when calculating coefficient distances:

“fraction”

for two coefficient matrices A and B returns sum(abs(A-B)/(A+B)), excluding elements where both A and B are zero

“logDiff”

for two coefficient matrices A and B returns sum(log(1+abs(A-B))

“wLogDiff”

performs the “logDiff” method with weights on the rows

“pa”

total pairs where the coefficient is present in one matrix and absent in the other (presence-absence)

“ap”

opposite comparison of pa (absence-presence)

numThreads

number of threads to be used, the default (-1) will use the number of cores in the machine and numThreads = 0 will only use the main thread

Value

distance matrix calculated from argument coefficient matrices

Note

  • the substituted y coefficient vector only supports the “logDiff” method and the “fraction” method

  • “pa” and “ap” force symmetry in the output distance matrix

Examples


library(treenomial)
library(ape)

# coefficient matrices for ten trees of 20 tips
coeffs <- treeToPoly(rmtree(10, 20), numThreads = 0)

# distance matrix from the list of coefficient matrices
d <- polyToDistMat(coeffs, method = "logDiff", numThreads = 0)

# using the absence-presence method
d <- polyToDistMat(coeffs, method = "ap", numThreads = 0)

treenomial documentation built on June 7, 2022, 1:08 a.m.