vcf_is_empty: Does the VCF file contain any variants?

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Checks if the VCF file contains any variants.

Usage

1

Arguments

x

Path to VCF file.

Value

TRUE if there is at least one variant in the VCF, FALSE otherwise.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
x <- system.file("extdata/umccrise/snv/somatic-ensemble-PASS.vcf.gz", package = "gpgr")
(y <- vcf_is_empty(x))

tmp1 <- tempfile(pattern = "fakeFile", fileext = "vcf")
writeLines(c("col1\tcol2\tcol3", "1\t2\t3"), con = tmp1)
## Not run: 
vcf_is_empty(tmp1)

## End(Not run)

vcf_cols <- c(
  "#CHROM", "POS", "ID", "REF", "ALT", "QUAL",
  "FILTER", "INFO", "FORMAT"
)
tmp2 <- tempfile(pattern = "fakeFile", fileext = "vcf")
writeLines(paste(vcf_cols, collapse = "\t"), con = tmp2)
(z <- vcf_is_empty(tmp2))

tmp3 <- tempfile(pattern = "fakeFile", fileext = "FOO")
writeLines(paste(vcf_cols, collapse = "\t"), con = tmp3)
## Not run: 
vcf_is_empty(tmp3)

## End(Not run)

umccr/gpgr documentation built on Nov. 25, 2021, 1:15 p.m.