poppr (version 2.3.0)

bitwise.dist: Calculate a dissimilarity distance matrix for SNP data.

Description

This function performs the same task as diss.dist, calculating the number of allelic differences between two samples.

Usage

bitwise.dist(x, percent = TRUE, mat = FALSE, missing_match = TRUE, differences_only = FALSE, threads = 0)

Arguments

x
percent
logical. Should the distance be represented from 0 to 1? Default set to TRUE. FALSE will return the distance represented as integers from 1 to n where n is the number of loci.
mat
logical. Return a matrix object. Default set to FALSE, returning a dist object. TRUE returns a matrix object.
missing_match
logical. Determines whether two samples differing by missing data in a location should be counted as matching at that location. Default set to TRUE, which forces missing data to match with anything. FALSE forces missing data to not match with any other information.
differences_only
logical. Determines whether the matrix should count differences or distances. For instance, 0 to 2 would be a distance of 2 but a difference of 1.
threads
The maximum number of parallel threads to be used within this function. A value of 0 (default) will attempt to use as many threads as there are available cores/CPUs. In most cases this is ideal. A value of 1 will force the function to run serially, which may increase stability on some systems. Other values may be specified, but should be used with caution.

Value

A dist object containing pairwise distances between samples.

Details

The distance calculated here is quite simple and goes by many names, depending on its application. The most familiar name might be the Hamming distance, or the number of differences between two strings.

See Also

diss.dist, snpclone, genlight, win.ia, samp.ia

Examples

Run this code
set.seed(999)
x <- glSim(n.ind = 10, n.snp.nonstruc = 5e2, n.snp.struc = 5e2, ploidy = 2)
x
system.time(xd <- bitwise.dist(x))
xd

Run the code above in your browser using DataLab