Skip to contents

This function parses a set of mutations in the Variant Calling Format (VCF), using the vcfR R package. The function takes in input the column names of the INFO field referring to allele depth counts, and number of reads with the variant. The two columns are used to compute the variant allele frequency (VAF) value; if any of the required columns are not found, an error is returned. This function does not filter any of the variants annotated in the input VCF file.

Usage

load_vcf(file, DP_column = "DP", NV_column = "NV")

Arguments

file

A VCF file name.

DP_column

Column with the total depth (DP), i.e., sum of reads at a locus.

NV_column

Column with the number of reads with the variant (NV).

Value

A tibble with the loaded data which contains, besides all the content parsable from the VCF file, three columns named DP, NV and VAF where VAF = NV/DP.

Examples

# Bundled example with total and alternate read counts.
file <- system.file("extdata", "example.vcf", package = "mobster")
load_vcf(file)
#> ℹ Loading VCF file /__w/mobster/mobster/.ci-library/mobster/extdata/example.vcf with package vcfR, file size 399 bytes.
#> # A tibble: 2 × 15
#>   CHROM POS   ID    REF   ALT   QUAL  FILTER INFO    Key    DP    NV Indiv gt_GT
#>   <chr> <chr> <chr> <chr> <chr> <chr> <chr>  <chr> <int> <dbl> <dbl> <chr> <chr>
#> 1 1     10000 NA    A     C     100   PASS   DP=8…     1    80    24 exam… 0/1  
#> 2 1     10010 NA    G     T     100   PASS   DP=5…     2    50     8 exam… 0/1  
#> # ℹ 2 more variables: gt_GT_alleles <chr>, VAF <dbl>