heterozygosity: Heterozygosity and Homozygosity

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Calculate heterozygosity and homozygosity by variant or by sample

Usage

1
2
3
4
5
6
7
8
## S4 method for signature 'SeqVarGDSClass'
heterozygosity(gdsobj, margin=c("by.variant", "by.sample"), use.names=FALSE,
    parallel=FALSE)
## S4 method for signature 'SeqVarGDSClass'
homozygosity(gdsobj, allele=c("any", "ref", "alt"), margin=c("by.variant", "by.sample"), use.names=FALSE,
    parallel=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.

parallel

Logical, numeric, or other value to control parallel processing; see seqParallel for details. Only applies if margin="as.variant".

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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)

Example output

Loading required package: SeqArray
Loading required package: gdsfmt
[1] 0.07017544 0.01886792 0.07792208 0.21917808 0.14606742 0.01123596
[1] 0.9298246 0.9811321 0.9220779 0.7808219 0.8539326 0.9887640
[1] 0.92982456 0.98113208 0.92207792 0.01369863 0.85393258 0.98876404
[1] 0.0000000 0.0000000 0.0000000 0.7671233 0.0000000 0.0000000
[1] 2.211765 1.643678 1.844660 2.011364 1.961039 1.720721

SeqVarTools documentation built on Nov. 22, 2020, 2 a.m.