heterozygosity {SeqVarTools} | R Documentation

## Heterozygosity and Homozygosity

### Description

Calculate heterozygosity and homozygosity by variant or by sample

### Usage

    ## S4 method for signature 'SeqVarGDSClass'
    heterozygosity(gdsobj, margin=c("by.variant", "by.sample"), use.names=FALSE)
    ## S4 method for signature 'SeqVarGDSClass'
    homozygosity(gdsobj, allele=c("any", "ref", "alt"), margin=c("by.variant", "by.sample"), use.names=FALSE)
    ## S4 method for signature 'SeqVarGDSClass'
    hethom(gdsobj, use.names=FALSE)

### Arguments

`gdsobj` | A `SeqVarGDSClass` object with VCF data.
`margin` | Possible values are "by.variant" or "by.sample," indicating whether the calculation should be done over all samples for each variant, or over all variants for each sample.
`use.names` | A logical indicating whether to assign variant or samples IDs as names of the output vector.
`allele` | Possible values are "any", "ref," or "alt," indicating which alleles to consider when calculating homozygosity.

### Details

`heterozyogosity` calulates the fraction of heterozygous genotypes in a GDS object, either by variant or by sample.

`homozygosity` calculates the rate of homozygous genotypes in a GDS object, either by sample or by variant. If `allele="any"`, all homozygous genotypes are considered (reference or any alternate allele). If `allele="ref"`, only reference homozygotes are considered. If `allele="alt"`, any alternate allele homozygote is considered. For example, "ref" will count "0/0" genotypes only, "alt" will count "1/1", "2/2", etc. (but not "0/0"), and "any" will count all of the above.

`hethom` calculates the ratio of heterozygous genotypes to alternate homozygous genotypes by sample.

### Value

A numeric vector of heterozyogity or homozygosity rates. If `margin="by.variant"`, the vector will have length equal to the number of variants in the GDS object. If `margin="by.sample"`, the vector will have length equal to the number of samples.

### Author(s)

Stephanie Gogarten

### See Also

`SeqVarGDSClass`, `applyMethod`, `alleleFrequency`

### Examples

    gds <- seqOpen(seqExampleFileName("gds"))
    head(heterozygosity(gds, margin="by.variant"))
    head(homozygosity(gds, allele="any", margin="by.variant"))
    head(homozygosity(gds, allele="ref", margin="by.variant"))
    head(homozygosity(gds, allele="alt", margin="by.variant"))

    ## Het/Hom Non-Ref by sample
    head(hethom(gds))

    seqClose(gds)

[Package SeqVarTools version 1.16.1 Index]