Learn R Programming

poppr (version 2.6.1)

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

Description

This function performs the same task as diss.dist, calculating the fraction or number of different alleles between two genlight or snpclone objects.

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, including other missing data.

differences_only

logical. When differences_only = TRUE, the output will reflect the number of different loci. The default setting, differences_only = FALSE, reflects the number of different alleles. Note: this has no effect on haploid organisms since 1 locus = 1 allele.

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
# NOT RUN {
set.seed(999)
x <- glSim(n.ind = 10, n.snp.nonstruc = 5e2, n.snp.struc = 5e2, ploidy = 2)
x
# Assess fraction of different alleles (finer measure, usually the most sensible)
system.time(xd <- bitwise.dist(x))
xd

# Assess fraction of different loci (coarse measure)
system.time(xdt <- bitwise.dist(x, differences_only = TRUE))
xdt
# }

Run the code above in your browser using DataLab