Skip to contents

This function write a VCF from a gen_tibble. Phased genotypes (see phased in gen_tibble()) are written as phased (e.g. 0|1), and unphased ones as unphased (e.g. 0/1). The genotypes are read and written in chunks of loci, so that this works on datasets that do not fit in memory.

Usage

gt_as_vcf(x, file = NULL, chunk_size = NULL, overwrite = FALSE)

Arguments

x

a gen_tibble, with population coded as 'population'

file

the .vcf file name with a path, or NULL (the default) to use the location of the backing files.

chunk_size

the number of loci processed at a time (also used for the number of chromosomes processed at a time when writing the contig lines of the header). If left to NULL, 100,000 loci are processed at a time.

overwrite

logical, should the file be overwritten if it already exists?

Value

the path of the .vcf file

Examples

example_gt <- load_example_gt("gen_tbl")

# Write a vcf file
example_gt %>% gt_as_vcf()
#> [1] "/tmp/RtmpZHNEm1/file1f155c5a2432.vcf"