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)
    ## S4 method for signature 'SeqVarData'
    alleleFrequency(gdsobj, n=0, use.names=FALSE, sex.adjust=TRUE, genome.build=c("hg19", "hg38"))
    ## S4 method for signature 'SeqVarGDSClass'
    alleleCount(gdsobj, n=0, use.names=FALSE)
    ## S4 method for signature 'SeqVarData'
    alleleCount(gdsobj, n=0, use.names=FALSE, sex.adjust=TRUE, genome.build=c("hg19", "hg38"))

### 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.
`genome.build` | A character sting indicating genome build.

### 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`. The 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 `sex.adjust=FALSE`.

### 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.22.0 Index]