amPairwise {allelematch}R Documentation

Pairwise matching of multilocus genotypes


Functions to perform a pairwise matching analysis of a multilocus genotype dataset, and review the output in formatted text or HTML. For each genotype in the focal dataset all genotypes in the comparison genotype are returned that match at or above a threshold matching score. The matching score is also known as the s-hat criterion (see the supplementary documentation). This is determined using amMatrix.


amPairwise(amDatasetFocal, amDatasetComparison = amDatasetFocal,
    alleleMismatch=NULL, matchThreshold = NULL, missingMethod = 2)

amHTML.amPairwise(x, htmlFile = NULL, htmlCSS = amCSSForHTML())

amCSV.amPairwise(x, csvFile)

## S3 method for class 'amPairwise'
summary(object, html = NULL, csv = NULL, ...)



An amDataset object containing focal genotypes.


Optional. An amDataset object containing comparison genotypes. If not supplied, the focal dataset is also the comparison dataset (i.e. all members of the focal dataset are compared against themselves).


Maximum number of mismatching alleles which will be tolerated when identifying individuals. Also known as m-hat parameter. If given, matchThreshold should be omitted.


Return comparison genotypes that match with the focal genotype at or above this score or similarity. Also known as s-hat parameter.


The method used to determine the similarity of multilocus genotypes when data is missing. The default (=2) is preferable in all cases. Please see amMatrix.

object, x

An amPairwise object.


The path to an HTML file to create. If htmlFile=NULL a file is created in the operating system temporary directory and is then opened in the default browser.


A string containing a valid cascading style sheet. A default style sheet is provided in amCSSForHTML. See amCSSForHTML for details of how to tweak this CSS.


If html=NULL or html=FALSE formatted textual output is displayed on the console.
If html=TRUE the summary method produces and loads an HTML file in the default browser.
html can also contain a path to a file where HTML output will be written.

csvFile, csv

The path to a CSV file to create giving a data frame representation of the pairwise matching results.


Additional arguments to summary


Pairwise matching of genotypes is a useful means to assess data quality and inspect for genotyping errors.

The matchThreshold represents the similarity between two multilocus genotypes, and can be thought of as a percentage similarity (or a Hamming's distance between two vectors) that has been corrected where missing data is present, such that missing data represents neither a match nor a mismatch, but a "partial" match. Please see amMatrix for more discussion of this metric.


An amPairwise object.
Or side effects: analysis summary written to an HTML file or to the console.


As matchThreshold is lowered the size of the output increases rapidly. Typically analyses will not be very useful or manageable with thresholds below 0.7.

There is an additional side effect of html=TRUE (or of htmlFile=NULL). If required, there is a clean up of the operating system temporary directory where AlleleMatch temporary HTML files are stored. Files that match the pattern am*.htm and are older 24 hours are deleted from this temporary directory.


Paul Galpern (


Please see the supplementary documentation for more information. This is available as a vignette. Click on the index link at the bottom of this page to find it.

See Also

amDataset, amMatrix, amUnique


## Not run: 


## Produce amDataset object
myDataset <- amDataset(amExample5, missingCode="-99", indexColumn=1,
    metaDataColumn=2, ignoreColumn="gender")

## Typical usage
myPairwise <- amPairwise(myDataset, alleleMismatch=2)

## Display analysis as HTML in default browser
summary(myPairwise, html=TRUE)

## Save analysis to HTML file
summary(myPairwise, html="myPairwise.htm")

## Save analysis to CSV file
summary(myPairwise, csv="myPairwise.csv")

## Display analysis as formatted text on the console

## Compare one dataset against a second
## Both must have same number of allele columns
## Here we create two datasets artificially from one for illustration purposes
myDatasetA <- amDataset(amExample5[sample(nrow(amExample5))[1:25], ],
    missingCode="-99", indexColumn=1, ignoreColumn=2)
myDatasetB <- amDataset(amExample5[sample(nrow(amExample5))[1:100], ],
    missingCode="-99", indexColumn=1, ignoreColumn=2)
myPairwise2 <- amPairwise(myDatasetA, myDatasetB, alleleMismatch=3)
summary(myPairwise2, html=TRUE)

## End(Not run)

[Package allelematch version 2.5.1 Index]