R: Retrieve and Count Unique Alleles

alleleDiversity {polysat} | R Documentation

## Retrieve and Count Unique Alleles

### Description

`alleleDiversity` returns the number of unique alleles and/or a list of vectors of all unique alleles, indexed by locus and population.

### Usage

    alleleDiversity(genobject, samples = Samples(genobject),
                    loci = Loci(genobject), alleles = TRUE, counts = TRUE)

### Arguments

`genobject` | An object of the class `"genambig"`.
`samples` | Optional. A character or numeric vector indicating samples to include in the analysis.
`loci` | Optional. A character or numeric vector indicating loci to include in the analysis.
`alleles` | Boolean, indicating whether or not to return the alleles themselves.
`counts` | Boolean, indicating whether or not to return the number of unique alleles.

### Value

Under default settings, a list is returned:

`alleles` | A two dimensional list. The first dimension is indexed by population, with the additional element “overall” representing the entire dataset. The second dimension is indexed by locus. Each element of the list is a vector, containing all unique alleles found for that population and locus. `Missing(genobject)` is not counted as an allele.
`counts` | A matrix, indexed in the same way as `alleles`. Each element of the matrix is an integer indicating how many alleles were found at that population and locus.

If the argument `alleles` or `counts` is set to `FALSE`, then only one of the above list elements is returned.

### Author(s)

Lindsay V. Clark

### See Also

`genotypeDiversity`

### Examples

    # generate a dataset for this example
    mygen <- new("genambig", samples=c("a","b","c","d"), loci=c("E","F"))
    PopInfo(mygen) <- c(1,1,2,2)
    Genotypes(mygen, loci="E") <- list(c(122,132),c(122,124,140),
                                       c(124,130,132),c(132,136))
    Genotypes(mygen, loci="F") <- list(c(97,99,111),c(113,115),
                                       c(99,113),c(111,115))

    # look at unique alleles
    myal <- alleleDiversity(mygen)
    myal$counts
    myal$alleles
    myal$alleles[["Pop1","E"]]
    myal$alleles[["overall","F"]]

[Package polysat version 1.7-6 Index]