Skip to contents

This function produces a "pairwise ratio matrix" that can be used in tests about asymmetric flows among nodes in a data set (e.g. the "asymmetry" and "diversity" hypotheses; Kling and Ackerly (2021)). The input data set can be an asymmetric matrix with entries representing directed edge weights (e.g. directional flows of wind or genes connecting each pair of populations or "nodes"), or it can be a vector of node attributes (e.g. properties of a site or population, such as genetic diversity).

Usage

pairwise_ratios(x, log = TRUE)

Arguments

x

Either a square matrix with entries representing directional edge weights between pairs of nodes, or a numeric vector with a value for each node.

log

Should ratios be log-transformed? Default is TRUE, since this generates a symmetrical frequency distribution desirable for most analyses.

Value

A square matrix the same size as x, with ones in the diagonal and reciprocal values in the upper and lower triangles. If x is a matrix, the output represents the ratios of above-diagonal to below-diagonal values in x. If x is a vector, the output represents the ratios of every pairwise combination of x values; e.g. a matrix in which the value of cell [2,4] equals x[2] / x[4].

References

Kling and Ackerly (2021). Global wind patterns shape genetic differentiation, asymmetric gene flow, and genetic diversity in trees. Proceedings of the National Academy of Sciences. https://doi.org/10.1073/pnas.2017317118