utils.fbm.grm: Additive relationship matrix of a file-backed object, as...

View source: R/utils.fbm.export.r

utils.fbm.grmR Documentation

Additive relationship matrix of a file-backed object, as rrBLUP::A.mat with its default settings, in blocks of loci

Description

WARNING: UTILITY SCRIPTS ARE FOR INTERNAL USE ONLY AND SHOULD NOT BE USED BY END USERS AS THEIR USE OUT OF CONTEXT COULD LEAD TO UNPREDICTABLE OUTCOMES.

Computes the realized additive relationship matrix of rrBLUP::A.mat(as.matrix(x) - 1, min.MAF, max.missing) with A.mat's default mean imputation and no shrinkage (Endelman & Jannink 2012; VanRaden 2008), reading the genotypes in two passes over blocks of loci, so the genotype matrix is never decoded as a whole.

As in A.mat, with genotypes g (0, 1, 2) and X = g - 1: per locus the frequency p is mean(g, na.rm = TRUE) / 2 (computed per column exactly as A.mat computes it) and the missing fraction is the share of NA. Loci with min(p, 1 - p) >= min.MAF and missing fraction <= max.missing are used (m loci). W = g - 2p, with missing genotypes set to 0 (mean imputation) and loci fixed in the sample set to 0, and A = tcrossprod(W) / (2 * mean(p * (1 - p))) / m, where the mean is over the m loci.

The frequencies, filter and scaling are identical to A.mat; the cross-product is added block by block, so A agrees with A.mat to about 1e-13 (relative) rather than bit for bit. Memory: the n x n result and one block of loci.

Usage

utils.fbm.grm(x, min.MAF = NULL, max.missing = NULL)

Arguments

x

A file-backed dartR object (diploid SNP) [required].

min.MAF

Minimum minor allele frequency [default 1/(2n), as A.mat].

max.missing

Maximum missing fraction of a locus [default 1 - 1/(2n), as A.mat].

Value

An n x n matrix with indNames(x) as row and column names.

Author(s)

Custodian: Bernd Gruber – Post to https://groups.google.com/d/forum/dartr

References

Endelman, J.B. and Jannink, J.-L. (2012) Shrinkage estimation of the realized relationship matrix. G3 2:1405-1413.

See Also

Other utilities: gl.He(), gl.Ho(), gl.alf(), utils.allelic.richness(), utils.basic.stats(), utils.check.datatype(), utils.collapse.matrix(), utils.dart2genlight(), utils.dist.binary(), utils.fbm.amat(), utils.fbm.blocks(), utils.fbm.colblocks(), utils.fbm.colwise(), utils.fbm.copy(), utils.fbm.count.mean(), utils.fbm.decode(), utils.fbm.has(), utils.fbm.new(), utils.fbm.pair.counts(), utils.fbm.reader(), utils.fbm.rowwise(), utils.fbm.tempfile(), utils.flag.start(), utils.het.pop(), utils.history.call(), utils.is.fixed(), utils.jackknife(), utils.n.var.invariant(), utils.plot.save(), utils.read.fasta(), utils.read.ped(), utils.recalc.avgpic(), utils.recalc.callrate(), utils.recalc.freqhets(), utils.recalc.freqhomref(), utils.recalc.freqhomsnp(), utils.recalc.maf(), utils.reset.flags(), utils.transpose(), utils.vcf.depth(), utils.vcfr2genlight.polyploid()


dartR.base documentation built on Nov. 18, 2026, 9:06 a.m.