addFrequencies-methods | R Documentation |
Adds genotypes counts
(reference homozygote, heterozygote, and alternate homozygote)
and allele frequencies (alternate and minor)
as INFO fields in an ExpandedVCF
object.
Counts and frequencies may be calculated overall
(i.e. across all samples), or within groups of samples
(i.e. within phenotype levels).
Multiple genotypes can be counted toward a single
frequency (e.g. combined c("0/0", "0|0")
for
homozygote reference genotypes).
## S4 method for signature 'ExpandedVCF,list'
addFrequencies(vcf, phenos, force = FALSE)
## S4 method for signature 'ExpandedVCF,character'
addFrequencies(vcf, phenos, force = FALSE)
## S4 method for signature 'ExpandedVCF,missing'
addFrequencies(vcf, force = FALSE)
vcf |
|
phenos |
If Otherwise,
either a |
force |
If If |
The phenos
argument is central to control the behaviour of this method.
If phenos=NULL
, genotypes and frequencies are calculated across all the
samples in the ExpandedVCF
object, and stored in INFO fields
named according to settings stored in the TVTBparam
object (see below).
If phenos
is a character
vector of phenotypes present in
colnames(colData(vcf))
, counts and frequencies are calculated for each
level of those phenotypes, and stored in INFO fields prefixed with
"<phenotype>_<level>_" and suffixed with the settings stored in the
param
object (see below).
Finally, if phenos
is a named list
, names
must be
phenotypes present in colnames(colData(vcf))
, and values must be levels
of those phenotypes. In this case, counts and frequencies are calculated for
the given levels of the given phenotypes, and stored in INFO fields as
described above.
The param
object controls the key (suffix) of INFO fields as
follows:
names(ref(param))
Count of reference homozygote genotypes.
names(het(param))
Count of heterozygote genotypes.
names(alt(param))
Count of alternate homozygote genotypes.
aaf(param)
Alternate allele frequency.
maf(param)
Minor allele frequency
ExpandedVCF
object including additional
INFO fields for genotype counts and allele frequencies.
See Details.
Kevin Rue-Albrecht
addOverallFrequencies,ExpandedVCF-method
,
addPhenoLevelFrequencies,ExpandedVCF-method
,
VCF
,
and TVTBparam
.
# Example data ----
# VCF file
vcfFile <- system.file("extdata", "moderate.vcf", package = "TVTB")
# Phenotype file
phenoFile <- system.file("extdata", "moderate_pheno.txt", package = "TVTB")
phenotypes <- S4Vectors::DataFrame(read.table(phenoFile, TRUE, row.names = 1))
# TVTB parameters
tparam <- TVTBparam(Genotypes("0|0", c("0|1", "1|0"), "1|1"))
# Pre-process variants
vcf <- VariantAnnotation::readVcf(
vcfFile, param = tparam, colData = phenotypes)
vcf <- VariantAnnotation::expand(vcf, row.names = TRUE)
# Example usage ----
vcf <- addFrequencies(vcf, list(super_pop = "AFR"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.