gl.propShared: Calculates a similarity matrix for individuals based on the...

View source: R/gl.propShared.r

gl.propSharedR Documentation

Calculates a similarity matrix for individuals based on the proportion of shared alleles

Description

This function calculates the proportion of shared alleles between each pair of individuals and returns it as a similarity matrix.

Usage

gl.propShared(x, verbose = NULL)

Arguments

x

Name of the genlight object containing the SNP data [required].

verbose

Verbosity: 0, silent or fatal errors; 1, begin and end; 2, brief progress messages; 3, progress and results summary; 5, full report [default 2, unless specified using gl.set.verbosity].

Details

At a locus, two diploid individuals with allele dosages g1 and g2 (0, 1 or 2) share 2 - |g1 - g2| of their two alleles. The similarity is the mean proportion of shared alleles over the loci called in both individuals, 1 - mean(|g1 - g2|) / 2, so missing data are handled pair by pair.

The similarity is the exact complement of gl.dist.ind with method = "manhattan", which this function uses for the calculation. Use as.dist(1 - gl.propShared(x)) to obtain a distance.

Only SNP data are accepted: for SilicoDArT (presence/absence) data the division by two does not apply.

Value

A symmetric nInd(x) x nInd(x) similarity matrix with values between 0 (no alleles shared at any locus) and 1 (identical at all loci called in both individuals), and individual names as row and column names. The diagonal is set to 1. Pairs of individuals with no locus called in both get NA.

Author(s)

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

See Also

Other distance: gl.dist.ind(), gl.dist.pop(), gl.fst.pop(), utils.dist.ind.snp()

Examples

res <- gl.propShared(bandicoot.gl)
res[1:5, 1:7] # show only a small part of the matrix


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