Pairwise marker relatedness (r2, mutual information, or variation of information)
Source:R/pairwise_distance.R
pairwise_distance.RdCompute a symmetric markers x markers relatedness matrix from a
markers x samples dosage matrix, under a pluggable measure. The measure is
computed over the samples where both markers are non-missing (any NA/NaN).
The result is handed to select_independent() for maximal-independent-set
marker thinning; the measure is thresholded in its own units (no r2<->MI
conversion).
Arguments
- geno
Numeric matrix, rows = markers, cols = samples; dosages (typically
0/1/2). Missing entries areNA/NaN. Row names (marker ids) are carried onto both dimensions of the result.- method
One of
"r2"(default),"mi","vi".- base
For
mi/vi: information unit,"nats"(default) or"bits". Ignored forr2.- max_markers
Safety guard on the marker count (default
7000L, the validated scale). The output is an O(n^2) markers x markers matrix, so a request abovemax_markerserrors cleanly (before any large allocation) rather than risking amallocfailure; large-but-allowed sizes warn. Raise it (up to the ceiling ingetOption("nilHMM.marker_hard_cap"), default30000) only if the memory is available; the intended workflow prunes per chromosome, well under the default.
Value
Symmetric numeric matrix (markers x markers) with attr(, "kind")
"similarity" (r2, mi) or "distance" (vi) and attr(, "method") the
measure. Dimnames from rownames(geno).
Details
r2(default, a similarity)cor(g_i, g_j)^2, the squared Pearson correlation of the dosage rows – the PLINK--indep-pairwiseconvention. High = related. A constant (zero-variance) marker contributes0.mi(a similarity)plug-in mutual information from the joint genotype contingency table, with the Miller-Madow bias correction
I_MM = I_plugin + (m_X + m_Y - m_XY - 1) / (2N). High = related.vi(a distance, a true metric)variation of information
VI(X,Y) = H(X) + H(Y) - 2*I(X,Y), on MM-corrected entropies. LOW = related;VIis a metric (obeys the triangle inequality), unlike r2/MI.
For near-linearly-dependent genotypes (e.g. RIL ancestry dosages) r2 and mi
rank pairs almost identically; mi/vi earn their keep on non-monotone or
multiallelic data and for the metric/embedding direction.