alleleFrequency {SeqVarTools} | R Documentation

## Allele frequency

### Description

Calculate allele frequency for each variant

### Usage

    ## S4 method for signature 'SeqVarGDSClass'
    alleleFrequency(gdsobj, n=0, use.names=FALSE, parallel=FALSE)
    ## S4 method for signature 'SeqVarData'
    alleleFrequency(gdsobj, n=0, use.names=FALSE, sex.adjust=TRUE, male.diploid=TRUE,
        genome.build=c("hg19", "hg38"), parallel=FALSE)
    ## S4 method for signature 'SeqVarGDSClass'
    alleleCount(gdsobj, n=0, use.names=FALSE, parallel=FALSE)
    ## S4 method for signature 'SeqVarData'
    alleleCount(gdsobj, n=0, use.names=FALSE, sex.adjust=TRUE, male.diploid=TRUE,
        genome.build=c("hg19", "hg38"), parallel=FALSE)
    ## S4 method for signature 'SeqVarData'
    minorAlleleCount(gdsobj, use.names=FALSE, sex.adjust=TRUE, male.diploid=TRUE,
        genome.build=c("hg19", "hg38"), parallel=FALSE)

### Arguments

`gdsobj` | A `SeqVarGDSClass` object with VCF data.
`n` | An integer indicating which allele to calculate the frequency of. `n=0` is the reference allele, `n=1` is the first alternate allele, and so on.
`use.names` | A logical indicating whether to assign variant IDs as names of the output vector.
`sex.adjust` | Logical for whether to adjust frequency calculations based on sex. If `TRUE`, X chromosome frequency (excluding the PAR) will be calculated assuming the dosage of the specifed allele for males is half that for females. Y chromosome frequency will be calculated using males only.
`male.diploid` | Logical for whether males on sex chromosomes are coded as diploid.
`genome.build` | A character sting indicating genome build; used to identify pseudoautosomal regions on the X and Y chromosomes.
`parallel` | Logical, numeric, or other value to control parallel processing; see `seqParallel` for details.

### Details

Frequency or count can be calculated over any allele, specified by the argument `n`. Default is the reference allele frequency (`n=0`).

The `SeqVarData` method will calculate frequency and count correctly for X and Y chromosomes, provided a column "sex" is included in the sampleData slot with values "M"/"F" or 1/2. Arguments given to this method are passed to the parent method for `SeqVarGDSClass`. If the ploidy of the "genotype" node in the GDS file is 2, the default assumption is that genotypes for males on sex chromosomes are coded as diploid, "0/0" or "1/1". If this is not the case, use `male.diploid=FALSE`.

For multiallelic variants, the minor allele count will be the smaller of the reference allele count or the sum of all alternate allele counts.

### Value

A numeric vector of allele frequencies.

### Author(s)

Stephanie Gogarten

### See Also

`chromWithPAR`, `SeqVarGDSClass`, `applyMethod`, `heterozygosity`

### Examples

    gds <- seqOpen(seqExampleFileName("gds"))
    head(alleleFrequency(gds))
    head(alleleFrequency(gds, n=1))
    head(alleleFrequency(gds, n=2))
    seqClose(gds)

[Package SeqVarTools version 1.28.1 Index]