addCountGenos-methods: Add count of genotypes to INFO field

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

Description

Adds the total occurences of a set of genotypes as an INFO field for each variant. All given genotypes are counted toward a single total (e.g. grand total of c("0/0", "0|0")), while other genotypes are silently ignored.

Usage

1
2
3
4
## S4 method for signature 'ExpandedVCF'
addCountGenos(
        vcf, genos, key, description,
        samples = 1:ncol(vcf), force = FALSE)

Arguments

vcf

ExpandedVCF object.

genos

character vector of genotypes to count (toward a common unique total).

key

Name of the INFO field to create or update (character vector of length 1). See Details below.

description

character description of the INFO field to create or overwrite (character vector of length 1).

samples

integer, numeric or character vector indicating samples to consider in VariantAnnotation::geno(vcf). If not specified, all samples are considered.

force

If TRUE, the field header and data will be overwritten if present; If FALSE, an error is thrown if the field already exists.

Details

In all cases, the new INFO field is inserted after the last existing field. In other words, overwriting an existing INFO field is achieved by dropping it from the data and header of the info slot, and subsequently inserting the new data after the last remaining INFO field.

Value

ExpandedVCF object including an additional INFO field stating the count of genotypes.

Author(s)

Kevin Rue-Albrecht

See Also

countGenos,ExpandedVCF-method and geno,VCF-method

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Example data ----

# VCF file
vcfFile <- system.file("extdata", "moderate.vcf", package = "TVTB")

# TVTB parameters
tparam <- TVTBparam(Genotypes(ref = "0|0", het = c("0|1", "1|0"), alt = "1|1"))

# Pre-process variants
vcf <- VariantAnnotation::readVcf(vcfFile, param = tparam)
vcf <- VariantAnnotation::expand(vcf, row.names = TRUE)


# Example usage ----

vcf <- addCountGenos(
    vcf, het(tparam),
    suffix(tparam)["het"],
    "Number of heterozygous genotypes")

kevinrue/TVTB documentation built on Sept. 6, 2021, 10:52 p.m.