Skip to contents

Converts a VCFArrow object to an Apparent format infile

Usage

vcf2apparent(vcf_arrow, out_file, keep_groups = NULL, key = "All")

Arguments

vcf_arrow

-> VCFArrow object

out_file

-> name of file to output, no default (character)

keep_groups

-> groups to retain, default NULL (character)

key

-> relationship type (All, Pa, Mo, Fa, Off), default All (character)

Value

Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.

Details

This function converts a VCFArrow object to an external Apparent formatted file. Writing occurs in chunks whose size is determined by the read_vcf() function. Larger chunks result in faster writing speeds. If no groups are defined, the default behavior is to use all groups. Only biallelic SNVs are exported (multiallelic sites and indels are left out), and every sample must be assigned to a group (see set_vcf_groups()), also when keep_groups is NULL. Possible relationships defined by the parameter 'key' are All, Pa, Mo, Fa, Off. Each line (no header) holds the sample name, the key and one genotype per SNP as two nucleotides separated by '/', with '-/-' for a missing genotype, as apparent expects. The same key is given to every sample.

Author

Tomas Hrbek May 2026

Examples

f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz",
                 package = "VCFArrow")
vcf <- read_vcf(f) |> set_vcf_groups(dirname(f))
#> ℹ VCF is being read in chunks of 50000 variants
#> ✔ VCF successfully read into a VCFArrow object
vcf2apparent(vcf, out_file = tempfile(fileext = ".txt"))
#> ℹ Accumulating Apparent: 9313 variants x 18 samples (0 MiB raw storage)
#> ℹ Writing Apparent file...
#> ✔ Apparent file written to /tmp/Rtmpq4egqB/file1db27084f0f2.txt