| Title: | Fast and Memory-Efficient Manipulation and Conversion of VCF Files |
|---|---|
| Description: | Reads Variant Call Format (VCF) files into an S4 object whose genotypes are stored on disk as an 'Apache Arrow' dataset and loaded lazily, allowing large datasets to be processed with little memory. Provides functions to filter variants and samples, subset and merge datasets, compute summary statistics and diagnostic plots, write VCF files, and convert data to input formats of population genetic and phylogenetic software such as 'STRUCTURE', 'ADMIXTURE', 'PLINK', 'EIGENSTRAT', 'Arlequin', 'GENEPOP', 'BayeScan', 'TreeMix', 'SNAPP' and 'adegenet'. |
| Authors: | Tomas Hrbek [aut, cre, cph] (ORCID: <https://orcid.org/0000-0003-3239-7068>) |
| Maintainer: | Tomas Hrbek <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.9.0 |
| Built: | 2026-10-16 17:47:48 UTC |
| Source: | https://github.com/cran/VCFArrow |
Subset a VCFArrow object by variants (rows) and samples (columns)
## S4 method for signature 'VCFArrow' x[i, j, ..., drop = FALSE]## S4 method for signature 'VCFArrow' x[i, j, ..., drop = FALSE]
x |
A VCFArrow object |
i |
Variant (row) positions, numeric or logical |
j |
Column indices: numeric, logical, or sample name character vector |
... |
Ignored |
drop |
Ignored; kept for S4 compatibility |
This function is a method of the VCFArrow S4 class Method to subset by row and column of GT
A new VCFArrow object containing the selected variants and samples
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) vcf[1:100, 1:5]f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) vcf[1:100, 1:5]
Quantifying read depth of all samples in VCF
assess_vcf_coverage( vcf_arrow, res_path, species, project, details = TRUE, max_points_per_sample = 5000L )assess_vcf_coverage( vcf_arrow, res_path, species, project, details = TRUE, max_points_per_sample = 5000L )
vcf_arrow |
-> VCFArrow object |
res_path |
-> path to results (directory for output dataframe and plots) |
species |
-> sample name for plot (character) |
project |
-> project name / base output file name (character) |
details |
-> flag for adding project name into figure title, default TRUE (Boolean) |
max_points_per_sample |
-> maximum number of SNVs from which to plot coverage, default 5000 (integer) |
This function generates a violin plot of read depths per sample.
violin plot of read depth for each sample in VCF
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) assess_vcf_coverage(vcf, res_path = tempdir(), species = "Phyllomedusa vaillantii", project = "vaillantii")f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) assess_vcf_coverage(vcf, res_path = tempdir(), species = "Phyllomedusa vaillantii", project = "vaillantii")
Quantifying missing data of all samples in VCF
assess_vcf_missing_data(vcf_arrow, res_path, species, project, details = TRUE)assess_vcf_missing_data(vcf_arrow, res_path, species, project, details = TRUE)
vcf_arrow |
-> VCFArrow object |
res_path |
-> path to results (directory for output dataframe and plots) |
species |
-> sample name for plot (character) |
project |
-> project name / base output file name (character) |
details |
-> flag for adding project name into figure title, default TRUE (Boolean) |
This function generates a dataframe of absolute and relative missing data per sample, and a plot of relative missing data % per sample.
dataframe and plot of missing data for each sample in VCF
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) assess_vcf_missing_data(vcf, res_path = tempdir(), species = "Phyllomedusa vaillantii", project = "vaillantii")f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) assess_vcf_missing_data(vcf, res_path = tempdir(), species = "Phyllomedusa vaillantii", project = "vaillantii")
Read VCF file and store its content within a VCFArrow object
read_vcf(vcf_file, chunk_size = 50000)read_vcf(vcf_file, chunk_size = 50000)
vcf_file |
-> VCF file |
chunk_size |
-> number of variants to read in at a time, default 50000 (integer) |
This function read a VCF file into an S4 class object in chunks, returning a VCFArrow object. It accepts both uncompressed and gz compressed files. The GT field is stored as an Apache Arrow in Long format. Various metrics are precalculated for fast and easy filtering. GT slot content stored in a TEMP directory for lazy loading.
VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) vcff <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) vcf
Associate samples with group info based on "strt" file
set_vcf_groups(vcf_arrow, data_path, strt = "strata")set_vcf_groups(vcf_arrow, data_path, strt = "strata")
vcf_arrow |
-> VCFArrow object |
data_path |
-> path to data (where strata are located) |
strt |
-> file with 2+ columns, one id column and one pop column (tsv file, header = TRUE) |
This function creates list of factors of sample-to-group assignments and groups based on a strata and group file. The strt is a tsv file with 2+ columns, with 2 columns named 'id' and 'pop'. By default strt is named 'strata' and found in the datapath where the VCF file is found.
vcf_arrow object with groups slot filled
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- set_vcf_groups(read_vcf(f), data_path = dirname(f), strt = "strata") table(vcf@groups)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- set_vcf_groups(read_vcf(f), data_path = dirname(f), strt = "strata") table(vcf@groups)
Print a summary of a VCFArrow object
## S4 method for signature 'VCFArrow' show(object)## S4 method for signature 'VCFArrow' show(object)
object |
A VCFArrow object |
This function is a method of the VCFArrow S4 class Method to show object content summary
Invisibly returns object; called for its side effect of printing
a summary.
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) show(vcf)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) show(vcf)
Bind two or more VCFArrow objects into a new VCFArrow object
vcf_bind( ..., mode = c("intersect", "union"), absent_as = c("missing", "hom_ref"), outgroup = FALSE, recover_loci = FALSE, .check = NULL )vcf_bind( ..., mode = c("intersect", "union"), absent_as = c("missing", "hom_ref"), outgroup = FALSE, recover_loci = FALSE, .check = NULL )
... |
-> a collection of VCFArrow objects |
mode |
-> "intersect" keeps variants present in all objects, "union" keeps variants present in any object, default "intersect" (character) |
absent_as |
-> for mode = "union" or outgroup = TRUE, how genotypes absent from a source object are coded, "missing" or "hom_ref", default "missing" (character) |
outgroup |
-> add the other objects (e.g. outgroups) to the first object (e.g. a filtered ingroup), keeping exactly the variants of the first object; mode and recover_loci are then not used, default FALSE (Boolean) |
recover_loci |
-> for mode = "union", restore the genotypes of variants an object removed by filtering, where its genotype files still hold them, instead of coding them according to absent_as, default FALSE (Boolean) |
.check |
-> deprecated and ignored; objects no longer need to share the same variants |
This function binds two or more VCFArrow objects with different sets of individuals, returning a new VCFArrow object. Sample names must be unique across objects. The objects need not have the same variants: mode = "intersect" keeps the variants present in all objects, mode = "union" keeps the variants present in any object and codes the genotypes an object lacks according to absent_as. For objects with the same variants both modes give the same result. In mode = "union", variants an object removed stay removed for it: a variant that one object removed by filtering but that another object contains is included, with the genotypes of the object that removed it coded according to absent_as. Binding in steps and binding all objects in one call then give the same result. With recover_loci = TRUE, the real genotypes of such variants are restored instead, read from the genotype files of the object that removed them (which keep every variant the object had when its files were written). This suits joining separately filtered datasets; binding in steps can then differ from binding in one call.
outgroup = TRUE is meant for adding outgroups to an ingroup that was filtered on its own (so that properties of the outgroup, such as its missingness, cannot remove ingroup variants): the result keeps exactly the variants of the first object, and variants removed from it stay removed. The other objects contribute their genotypes for these variants, read from their genotype files wherever present (including variants they removed, for example as invariant); genotypes they do not have are coded according to absent_as.
Variants are matched by CHROM, POS, REF and ALT, so the objects may come
from different VCF files (e.g. separate sequencing runs); REF and ALT must
be written the same way in all of them (including the order of alternative
alleles). This is assured when all datasets were called against the same
reference genome assembly, which gives the same CHROM, POS and REF for the
same locus. It is generally not possible for de novo (reference-free) SNP
calling, for example with DiscoSnp, where locus names and positions are
generated anew in each calling run, so the same locus will usually not
match between separately called datasets; such datasets should be called
together in a single run instead. Multi-allelic sites can list their ALT
alleles in a different order in different files, so it is best to
normalize the VCFs first, for example by splitting multi-allelic sites with
bcftools norm -m -any. Variants keep the .row_id of the first object where its source
VCF has them, other variants get new ids; the variant metadata of the first
object and, in mode = "intersect", its record of removed invariant variants
are kept, so bound objects can be bound again.
VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) ingroup <- vcf_extract_groups(vcf, c("GS", "BS", "WA")) outgroup <- vcf_extract_groups(vcf, "OG") vcf_bind(ingroup, outgroup, mode = "intersect") vcf_bind(ingroup, outgroup, mode = "union", absent_as = "missing") vcf_bind(vcf_filter_missingness(ingroup, 0.2), outgroup, outgroup = TRUE, absent_as = "missing")f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) ingroup <- vcf_extract_groups(vcf, c("GS", "BS", "WA")) outgroup <- vcf_extract_groups(vcf, "OG") vcf_bind(ingroup, outgroup, mode = "intersect") vcf_bind(ingroup, outgroup, mode = "union", absent_as = "missing") vcf_bind(vcf_filter_missingness(ingroup, 0.2), outgroup, outgroup = TRUE, absent_as = "missing")
Copy a VCFArrow object
vcf_copy(vcf_arrow)vcf_copy(vcf_arrow)
vcf_arrow |
-> VCFArrow object |
This function copies a VCFArrow object. It makes an actual physical copy of the object.
VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_copy(vcf_filter_maf(vcf, 0.05))f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_copy(vcf_filter_maf(vcf, 0.05))
Extract groups of samples from a VCFArrow object
vcf_extract_groups( vcf_arrow, groups, keep = TRUE, f_invar = TRUE, verbose = TRUE )vcf_extract_groups( vcf_arrow, groups, keep = TRUE, f_invar = TRUE, verbose = TRUE )
vcf_arrow |
-> VCFArrow object |
groups |
-> groups to retain/drop (character) |
keep |
-> retain (TRUE) or drop (FALSE) individuals flag, default TRUE (Boolean) |
f_invar |
-> filter invariant loci flag, default TRUE (Boolean) |
verbose |
-> report filtering stats, default TRUE (Boolean) |
This function removes groups of samples from a VCFArrow object, returning a new VCFArrow object. It uses the 'keep' flag to either keep or drop the groups in the list. By default will remove any loci that may have become invariant as the result of the removal of samples. By default will report removed samples, final % missing data, and number of retained samples after sample filtering.
subsetted VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_extract_groups(vcf, groups = c("GS", "BS")) vcf_extract_groups(vcf, groups = "OG", keep = FALSE)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_extract_groups(vcf, groups = c("GS", "BS")) vcf_extract_groups(vcf, groups = "OG", keep = FALSE)
Extract samples from a VCFArrow object
vcf_extract_samples( vcf_arrow, samples, keep = TRUE, f_invar = TRUE, verbose = TRUE )vcf_extract_samples( vcf_arrow, samples, keep = TRUE, f_invar = TRUE, verbose = TRUE )
vcf_arrow |
-> VCFArrow object |
samples |
-> individuals to retain/drop (character) |
keep |
-> retain (TRUE) or drop (FALSE) individuals flag, default TRUE (Boolean) |
f_invar |
-> filter invariant loci flag, default TRUE (Boolean) |
verbose |
-> report filtering stats, default TRUE (Boolean) |
This function removes samples from a VCFArrow object, returning a new VCFArrow object. It uses the 'keep' flag to either keep or drop the samples in the list. By default will remove any loci that may have become invariant as the result of the removal of samples. By default will report removed samples, final % missing data, and number of retained samples after sample filtering.
subsetted VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_extract_samples(vcf, samples = c("Pv14", "Pv27", "Pv28")) vcf_extract_samples(vcf, samples = c("Pb2Jp", "Pb2Scx", "Pb1Rd"), keep = FALSE)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_extract_samples(vcf, samples = c("Pv14", "Pv27", "Pv28")) vcf_extract_samples(vcf, samples = c("Pb2Jp", "Pb2Scx", "Pb1Rd"), keep = FALSE)
Correct or remove genotypes with > % ALT/REF ratio from a VCFArrow object
vcf_filter_adr( vcf_arrow, mode = c("correct", "remove"), threshold = 0.1, f_invar = TRUE )vcf_filter_adr( vcf_arrow, mode = c("correct", "remove"), threshold = 0.1, f_invar = TRUE )
vcf_arrow |
-> VCFArrow object |
mode |
-> switch between 'correct' or 'remove' mode (character) |
threshold |
-> decimal missing threshold, default 0.1 (numeric) |
f_invar |
-> filter invariant loci flag, default TRUE (Boolean) |
This function either changes genotypes or makes genotypes missing in a VCFArrow object if they have above/below threshold normalized ADR ratio, returning a new VCFArrow object. The ADR is calculated as ADR = ALT / (REF + ALT). If ADR > threshold, the genotype becomes ALT homozygous. If ADR < threshold, the genotype becomes REF homozygous. By default will remove any loci that may have become invariant as the result of the change/removal of genotypes
subsetted VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_adr(vcf, mode = "correct")f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_adr(vcf, mode = "correct")
Remove non-biallelic loci from a VCFArrow object
vcf_filter_biallelic(vcf_arrow)vcf_filter_biallelic(vcf_arrow)
vcf_arrow |
-> VCFArrow object |
This function removes non-biallelic loci from a VCFArrow object, returning a new VCFArrow object.
subsetted VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_biallelic(vcf)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_biallelic(vcf)
Remove genotypes below read DP threshold from a VCFArrow object
vcf_filter_coverage(vcf_arrow, threshold = 10)vcf_filter_coverage(vcf_arrow, threshold = 10)
vcf_arrow |
-> VCFArrow object |
threshold |
-> DP threshold, default 10 (integer) |
This function removes genotypes below a DP threshold from a VCFArrow object, returning a new VCFArrow object.
subsetted VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_coverage(vcf, threshold = 10)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_coverage(vcf, threshold = 10)
Remove loci above a heterozigosity threshold from a VCFArrow object
vcf_filter_hets(vcf_arrow, threshold = 0.5)vcf_filter_hets(vcf_arrow, threshold = 0.5)
vcf_arrow |
-> VCFArrow object |
threshold |
-> heterozigosity threshold, default 0.5 (numeric) |
This function removes loci above a heterozigosity threshold from a VCFArrow object, returning a new VCFArrow object. High heterozigosities are indicative of potential paralogs.
subsetted VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_hets(vcf, threshold = 0.5)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_hets(vcf, threshold = 0.5)
Remove indels from a VCFArrow object
vcf_filter_indels(vcf_arrow)vcf_filter_indels(vcf_arrow)
vcf_arrow |
-> VCFArrow object |
This function removes indel loci from a VCFArrow object, returning a new VCFArrow object.
subsetted VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_indels(vcf)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_indels(vcf)
Remove invariant loci from a VCFArrow object
vcf_filter_invariant(vcf_arrow)vcf_filter_invariant(vcf_arrow)
vcf_arrow |
-> VCFArrow object |
This function removes invariant loci from a VCFArrow object, returning a new VCFArrow object. This might be desirable after subsetting a VCFArrow object by individuals.
subsetted VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_invariant(vcf)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_invariant(vcf)
Remove loci below MAF threshold from a VCFArrow object
vcf_filter_maf(vcf_arrow, threshold = 0.05)vcf_filter_maf(vcf_arrow, threshold = 0.05)
vcf_arrow |
-> VCFArrow object |
threshold |
-> decimal MAF threshold, default 0.05 (numeric) |
This function removes loci below MAF threshold from a VCFArrow object, returning a new VCFArrow object.
subsetted VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_maf(vcf, threshold = 0.05)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_maf(vcf, threshold = 0.05)
Remove samples with > % missing data from a VCFArrow object
vcf_filter_missing(vcf_arrow, threshold = 0.5, f_invar = TRUE, verbose = TRUE)vcf_filter_missing(vcf_arrow, threshold = 0.5, f_invar = TRUE, verbose = TRUE)
vcf_arrow |
-> VCFArrow object |
threshold |
-> decimal missing threshold, default 0.5 (numeric) |
f_invar |
-> filter invariant loci flag, default TRUE (Boolean) |
verbose |
-> report filtering stats, default TRUE (Boolean) |
This function removes samples from a VCFArrow object if they have above threshold missing loci, returning a new VCFArrow object. By default will remove any loci that may have become invariant as the result of the removal of samples. By default will report removed samples, final % missing data, and number of retained samples after sample filtering.
subsetted VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf |> vcf_filter_missingness(threshold = 0.2) |> vcf_filter_missing(threshold = 0.3)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf |> vcf_filter_missingness(threshold = 0.2) |> vcf_filter_missing(threshold = 0.3)
Remove loci above missingness threshold from a VCFArrow object
vcf_filter_missingness(vcf_arrow, threshold = 0.1, verbose = TRUE)vcf_filter_missingness(vcf_arrow, threshold = 0.1, verbose = TRUE)
vcf_arrow |
-> VCFArrow object |
threshold |
-> decimal missingness threshold, default 0.1 (numeric) |
verbose |
-> flag to report total % missing data after filtering, default TRUE (Boolean) |
This function removes loci above missingness threshold from a VCFArrow object, returning a new VCFArrow object. Missingness is a locus focused metric, i.e. missing data per locus.
subsetted VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_missingness(vcf, threshold = 0.2)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_missingness(vcf, threshold = 0.2)
Subset a VCFArrow object keeping only loci with 2+ SNVs per locus
vcf_filter_multiSNV(vcf_arrow, block_size = 10000, minSNV = 2, maxSNV = 5)vcf_filter_multiSNV(vcf_arrow, block_size = 10000, minSNV = 2, maxSNV = 5)
vcf_arrow |
-> VCFArrow object |
block_size |
-> size of linked SNV blocks, default 10000 bp (integer) |
minSNV |
-> minimum linked block size, default 2 (integer) |
maxSNV |
-> maximum number of selected linked SNVs per block, default 5 (integer) |
This function subsets a VCFArrow object keeping only loci with between min and max # of SNVs per locus, returning a new VCFArrow object. Default min = 2 and max = 5 SNVs per locus (recommended as input for fineRADstructure analyses). Locus is defined as a different chromosome or a block of the 'block_size' parameter value within a chromosome.
subsetted VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_multiSNV(vcf, block_size = 10000, minSNV = 2, maxSNV = 5)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_multiSNV(vcf, block_size = 10000, minSNV = 2, maxSNV = 5)
Subset a VCFArrow object keeping only 1 SNV per locus
vcf_filter_oneSNV(vcf_arrow, block_size = 10000)vcf_filter_oneSNV(vcf_arrow, block_size = 10000)
vcf_arrow |
-> VCFArrow object |
block_size |
-> size of linked SNV blocks, default 10000 bp (integer) |
This function subsets a VCFArrow object keeping only 1 SNV per locus, returning a new VCFArrow object. Locus is defined as a different chromosome or a block of the 'block_size' parameter value within a chromosome. The first SNV independent of quality is taken (may modify this in the future).
subsetted VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_oneSNV(vcf)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_oneSNV(vcf)
Remove loci above REPEAT and below RANK threshold from a VCFArrow object
vcf_filter_paralogs( vcf_arrow, threshold_rk = 0.2, threshold_rpt = 0.5, keep_na = FALSE )vcf_filter_paralogs( vcf_arrow, threshold_rk = 0.2, threshold_rpt = 0.5, keep_na = FALSE )
vcf_arrow |
-> VCFArrow object |
threshold_rk |
-> decimal RANK threshold, loci below it are removed, default 0.2 (numeric) |
threshold_rpt |
-> decimal REPEAT threshold, loci above it are removed, default 0.5 (numeric) |
keep_na |
-> retain loci without a RANK or REPEAT value, default FALSE (Boolean) |
This function removes loci below the RANK threshold and above the REPEAT threshold from a VCFArrow object, returning a new VCFArrow object. It applies vcf_filter_rank() and then vcf_filter_rpt(). RANK and REPEAT metrics focus on different paralog signals, and used jointly maximize true positive and minimize false positive detections. Simulations indicate that removing loci with Rk < 0.2 or RPT > 0.5 gives the best results, with Rk < 0.4 or RPT > 0.5 being slightly more conservative.
subsetted VCFArrow object
Tomas Hrbek September 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_paralogs(vcf, threshold_rk = 0.2, threshold_rpt = 0.5)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_paralogs(vcf, threshold_rk = 0.2, threshold_rpt = 0.5)
Remove loci that did not PASS FILTER in a VCFArrow object
vcf_filter_pass(vcf_arrow)vcf_filter_pass(vcf_arrow)
vcf_arrow |
-> VCFArrow object |
This function removes loci that did not PASS the FILTER in a VCFArrow object, returning a new VCFArrow object. PASS indicates that a variant has successfully passed all applied quality control filters. When no filters were applied and the FILTER field is '.' (Dot), vcf_filter_pass() defaults to passing the locus.
subsetted VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_pass(vcf)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_pass(vcf)
Remove loci below QUAL threshold from a VCFArrow object
vcf_filter_quality(vcf_arrow, threshold = 30)vcf_filter_quality(vcf_arrow, threshold = 30)
vcf_arrow |
-> VCFArrow object |
threshold |
-> QUAL threshold, default 30 (integer) |
This function removes loci below QUAL threshold from a VCFArrow object, returning a new VCFArrow object. QUAL is a Phred-scaled quality metric assessing whether any variant exists at that position across all samples. QUAL is different from PL which represents the confidence in a genotype call of a specific sample. When QUAL not reported '.' (Dot), QUAL is assumed to be above threshold.
subsetted VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_quality(vcf, threshold = 30)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_quality(vcf, threshold = 30)
Remove loci below RANK threshold from a VCFArrow object
vcf_filter_rank(vcf_arrow, threshold = 0.4, keep_na = FALSE)vcf_filter_rank(vcf_arrow, threshold = 0.4, keep_na = FALSE)
vcf_arrow |
-> VCFArrow object |
threshold |
-> decimal rank threshold, default 0.4 (numeric) |
keep_na |
-> retain loci without a rank value, default FALSE (Boolean) |
This function removes loci below RANK threshold from a VCFArrow object, returning a new VCFArrow object. RANK is calculated by kissreads2 in DiscoSNP-RAD (Gauthier et. al. 2020) and registered as Rk in INFO. RANK is calculated as sqrt(chi-sqr/n) of allele read counts, and used for paralog detection -> very low rank values (<0.4) are indicative of paralogs.
subsetted VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_rank(vcf, threshold = 0.5)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_rank(vcf, threshold = 0.5)
Remove loci above REPEAT threshold from a VCFArrow object
vcf_filter_rpt(vcf_arrow, threshold = 0.5, keep_na = FALSE)vcf_filter_rpt(vcf_arrow, threshold = 0.5, keep_na = FALSE)
vcf_arrow |
-> VCFArrow object |
threshold |
-> decimal REPEAT threshold, loci above it are removed, default 0.5 (numeric) |
keep_na |
-> retain loci without a REPEAT value, default FALSE (Boolean) |
This function removes loci above REPEAT threshold from a VCFArrow object, returning a new VCFArrow object. REPEAT is calculated by disco_haplotypes in DiscoSNP-RAD (Gauthier et. al. 2020) and registered as RPT in INFO. REPEAT is calculated as max of overlap, depth score and is 1 if in a giant-component bubble, and is used for paralog detection -> high repeat values (>0.5) are indicative of paralogs.
subsetted VCFArrow object
Tomas Hrbek September 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_rpt(vcf, threshold = 0.5)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_filter_rpt(vcf, threshold = 0.5)
Triggers R's garbage collector (three full passes to handle the finalizer -> pending-queue -> unlink chain), then flushes any directories whose reference count has already reached zero.
vcf_gc(force = FALSE, verbose = TRUE)vcf_gc(force = FALSE, verbose = TRUE)
force |
Logical. If TRUE, also force-deregister and delete directories
for objects that are still nominally live in the registry. Use this when
you have called |
verbose |
Logical. Print a status message. |
Invisibly returns NULL; called for its side effect of deleting
temporary directories.
rm(vcf1, vcf2, vcf3) vcf_gc() # usually sufficient vcf_gc(force = TRUE) # if directories remain after rm()
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) rm(vcf) vcf_gc()f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) rm(vcf) vcf_gc()
Estimate RAM required for a VCFArrow export operation
vcf_memory_estimate( vcf_arrow, keep_groups = NULL, format = c("individual", "pop", "chunk"), chunk_size = 100000L, lowmem = FALSE )vcf_memory_estimate( vcf_arrow, keep_groups = NULL, format = c("individual", "pop", "chunk"), chunk_size = 100000L, lowmem = FALSE )
vcf_arrow |
A VCFArrow object. |
keep_groups |
Groups to export (NULL = all). |
format |
One of "individual" (Structure, Arlequin, FASTA, ...) or "pop" (BayesScan, Treemix, Migrate-N C, ...) or "chunk" (SmartSNP, fineRADstructure, sNMF, EIGENSTRAT, ...). |
chunk_size |
Feather chunk size used at read_vcf() time. |
lowmem |
If TRUE, estimate uses raw-byte matrices (vcf2*() lowmem variants); otherwise integer matrices. |
Invisibly, a list with elements:
n_var: number of variants
n_samples: number of samples retained
n_pops: number of populations
chunk_arrow_bytes: Arrow memory per chunk read
matrix_bytes: size of the accumulation matrices
peak_bytes: estimated peak memory
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_memory_estimate(vcf, format = "individual")f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_memory_estimate(vcf, format = "individual")
Set the number of parallel worker processes used by VCFArrow
vcf_set_workers(workers = 1L)vcf_set_workers(workers = 1L)
workers |
-> number of worker processes, default 1 (no parallelism) (integer) |
Functions that process the on-disk genotype chunks independently
distribute the chunks over workers background R processes: read_vcf(),
the genotype-based filters, sample and group extraction, vcf_stats() and
the assess functions, vcf_bind(), write_vcf(), the vcf2*() exporters and
vcf2gt_long() with CSV output (with feather or Parquet output it runs
serially). Results do not depend on the number of workers. The workers are started once and reused
until vcf_set_workers(1) is called or the session ends.
Each worker holds one chunk in memory at a time, so memory use grows with
the number of workers (see vcf_memory_estimate()). Useful values are up
to the number of physical CPU cores; disk speed limits the gain beyond that.
Invisibly, the previous number of workers.
Tomas Hrbek September 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") # 2 workers (CRAN examples may use at most 2 cores) vcf_set_workers(2) vcf <- read_vcf(f) vcf_set_workers(1)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") # 2 workers (CRAN examples may use at most 2 cores) vcf_set_workers(2) vcf <- read_vcf(f) vcf_set_workers(1)
Calculates basic stats of each samples from VCFArrow format data. Includes average read depth per individual, missing data per individual, Watterson's theta and pi.
vcf_stats(vcf_arrow, res_path, project, theta = FALSE)vcf_stats(vcf_arrow, res_path, project, theta = FALSE)
vcf_arrow |
-> VCFArrow object |
res_path |
-> directory where to write results |
project |
-> base name of the project file |
theta |
-> flag to perform theta and pi calculation, default FALSE (Boolean) |
This function calculates average read depth, heterozygosity number of heterozygotes, number of reference and alternative homozygotes, missing data and total number SNPs of each sample in an VCFArrow object. Optionally calls vcf_theta() to get total and group Watterson's theta and pi.
table of statistics
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_stats(vcf, res_path = tempdir(), project = "vaillantii", theta = TRUE)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_stats(vcf, res_path = tempdir(), project = "vaillantii", theta = TRUE)
Randomly subsets SNVs from a VCFArrow object
vcf_sub_SNVs(vcf_arrow, n_SNVs = 10000, seed = NULL)vcf_sub_SNVs(vcf_arrow, n_SNVs = 10000, seed = NULL)
vcf_arrow |
-> VCFArrow object |
n_SNVs |
-> number of SNVs to subset, default 10000 (integer) |
seed |
-> random number generator seed, default NULL (integer) |
This function subsets a VCFArrow object to specific number of SNVs, returning new VCFArrow object. The seed for random number generator is automatically generated unless otherwise specified.
VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_sub_SNVs(vcf, n_SNVs = 1000, seed = 42)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_sub_SNVs(vcf, n_SNVs = 1000, seed = 42)
Randomly subsets SNVs from a VCFArrow object
vcf_sub_SNVs_stratified(vcf_arrow, n_SNVs = 1000, seed = NULL)vcf_sub_SNVs_stratified(vcf_arrow, n_SNVs = 1000, seed = NULL)
vcf_arrow |
-> VCFArrow object |
n_SNVs |
-> number of SNVs to subset, default 1000 (integer) |
seed |
-> random number generator seed, default NULL (integer) |
This function subsets a VCFArrow object to specific number of SNVs, returning new VCFArrow object. The subsampling is stratified, i.e. the same proportion of SNVs per CHROM. The seed for random number generator is automatically generated unless specified.
VCFArrow object
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_sub_SNVs_stratified(vcf, n_SNVs = 1000, seed = 42)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_sub_SNVs_stratified(vcf, n_SNVs = 1000, seed = 42)
Suggest a chunk_size for read_vcf() given available RAM
vcf_suggest_chunk_size(available_gb, n_samples, n_columns = 5L)vcf_suggest_chunk_size(available_gb, n_samples, n_columns = 5L)
available_gb |
RAM available in gigabytes. |
n_samples |
Number of samples. |
n_columns |
Number of columns per gt row (default 5: row_id, sample, a1, a2, phased). |
Invisibly, the suggested chunk size (numeric).
vcf_suggest_chunk_size(available_gb = 8, n_samples = 100)vcf_suggest_chunk_size(available_gb = 8, n_samples = 100)
Calculates basic Watterson's theta and pi for all samples and for sample groups from VCFArrow format data.
vcf_theta(vcf_arrow, keep_groups = NULL)vcf_theta(vcf_arrow, keep_groups = NULL)
vcf_arrow |
-> VCFArrow object |
keep_groups |
-> groups to retain, default NULL (character) |
This function calculates Watterson's theta and pi for the entire VCFArrow object, and for groups of individuals whose grouping is indicated by the groups slot in the VCFArrow object. The statistics are accumulated chunk by chunk as running sums per group, so memory use does not grow with the number of variants, and chunks are processed in parallel when workers are set with vcf_set_workers().
list of statistics
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_theta(vcf)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_theta(vcf)
Converts a VCFArrow object to a PLINK .bed format infile plus ADMIXTURE-specific .pop file
vcf2admixture( vcf_arrow, out_file, keep_groups = NULL, sex = NULL, pheno = NULL, chrom_code = c("zero", "auto", "index", "keep"), supervised = FALSE, reference_groups = NULL )vcf2admixture( vcf_arrow, out_file, keep_groups = NULL, sex = NULL, pheno = NULL, chrom_code = c("zero", "auto", "index", "keep"), supervised = FALSE, reference_groups = NULL )
vcf_arrow |
-> VCFArrow object |
out_file |
-> output file prefix; extensions are added automatically, no default (character) |
keep_groups |
-> groups to retain, default NULL (character) |
sex |
-> vector of sexes of samples, default NULL (character) |
pheno |
-> vector of phenotypes of samples, default NULL (character) |
chrom_code |
-> how CHROM is written: "auto" (keep numeric CHROM, otherwise 0), "index" (1..n by first appearance), "zero" (all 0) or "keep" (verbatim), default "zero" (character) |
supervised |
-> flag to generate .pop for use in ADMIXTURE's supervised mode, default FALSE (Boolean) |
reference_groups |
-> vector of ancestry group labels, default NULL (character) |
This function converts a VCFArrow object to an external PLINK .bed 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. Sex and phenotype vectors are optional. If not defined sex = 0, pheno = -9. For supervised analyses, the supervised flag needs to be true to generate .pop file needed for ADMIXTURE's supervised mode. The reference_groups vector specifies ancestral information of individuals. When NULL, or for any missing individual, ancestry is inferred.
Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2admixture(vcf, out_file = file.path(tempdir(), "admixture_in")) vcf2admixture(vcf, out_file = file.path(tempdir(), "admixture_sup"), supervised = TRUE, reference_groups = c("GS", "BS", "WA"))f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2admixture(vcf, out_file = file.path(tempdir(), "admixture_in")) vcf2admixture(vcf, out_file = file.path(tempdir(), "admixture_sup"), supervised = TRUE, reference_groups = c("GS", "BS", "WA"))
Converts a VCFArrow object to an Apparent format infile
vcf2apparent(vcf_arrow, out_file, keep_groups = NULL, key = "All")vcf2apparent(vcf_arrow, out_file, keep_groups = NULL, key = "All")
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) |
This function converts a VCFArrow object to an external SmartSNP 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. Possible relationships defined by the parameter 'kee' are All, Pa, Mo, Fa, Off.
Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2apparent(vcf, out_file = tempfile(fileext = ".txt"))f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2apparent(vcf, out_file = tempfile(fileext = ".txt"))
Converts a VCFArrow object to an Arlequin infile
vcf2arlequin(vcf_arrow, out_file, keep_groups = NULL)vcf2arlequin(vcf_arrow, out_file, keep_groups = NULL)
vcf_arrow |
-> VCFArrow object |
out_file |
-> name of file to output, no default (character) |
keep_groups |
-> groups to retain, default NULL (character) |
This function converts a VCFArrow object to an external Arlequin 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.
Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2arlequin(vcf, out_file = tempfile(fileext = ".arp"))f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2arlequin(vcf, out_file = tempfile(fileext = ".arp"))
Converts a VCFArrow object to BayesAss format infile
vcf2bayesass(vcf_arrow, out_file, keep_groups = NULL)vcf2bayesass(vcf_arrow, out_file, keep_groups = NULL)
vcf_arrow |
-> VCFArrow object |
out_file |
-> name of file to output, no default (character) |
keep_groups |
-> groups to retain, default NULL (character) |
This function converts a VCFArrow object to an external BayesAss 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.
Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2bayesass(vcf, out_file = tempfile(fileext = ".immanc"))f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2bayesass(vcf, out_file = tempfile(fileext = ".immanc"))
Converts a VCFArrow object to Bayescan format infile
vcf2bayescan(vcf_arrow, out_file, keep_groups = NULL)vcf2bayescan(vcf_arrow, out_file, keep_groups = NULL)
vcf_arrow |
-> VCFArrow object |
out_file |
-> name of file to output, no default (character) |
keep_groups |
-> groups to retain, default NULL (character) |
This function converts a VCFArrow object to an external BayesAss 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.
Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2bayescan(vcf, out_file = tempfile(fileext = ".txt"))f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2bayescan(vcf, out_file = tempfile(fileext = ".txt"))
Converts a VCFArrow object to Eigenstrat format infile
vcf2eigenstrat(vcf_arrow, out_file, keep_groups = NULL, sex = NULL)vcf2eigenstrat(vcf_arrow, out_file, keep_groups = NULL, sex = NULL)
vcf_arrow |
-> VCFArrow object |
out_file |
-> output file prefix; extensions are added automatically, no default (character) |
keep_groups |
-> groups to retain, default NULL (character) |
sex |
-> sex of the individual, default = U (undefined) (character) |
This function converts a VCFArrow object to an external BayesAss 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.
Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2eigenstrat(vcf, out_file = file.path(tempdir(), "eigenstrat_in"))f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2eigenstrat(vcf, out_file = file.path(tempdir(), "eigenstrat_in"))
Converts a VCFArrow object to a FASTA format infile
vcf2fasta(vcf_arrow, out_file, keep_groups = NULL)vcf2fasta(vcf_arrow, out_file, keep_groups = NULL)
vcf_arrow |
-> VCFArrow object |
out_file |
-> name of file to output, no default (character) |
keep_groups |
-> groups to retain, default NULL (character) |
This function converts a VCFArrow object to an external FASTA 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.
Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2fasta(vcf, out_file = tempfile(fileext = ".fas"))f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2fasta(vcf, out_file = tempfile(fileext = ".fas"))
Converts a VCFArrow object to FineRadStructure format infile
vcf2fineradstructure(vcf_arrow, out_file, keep_groups = NULL)vcf2fineradstructure(vcf_arrow, out_file, keep_groups = NULL)
vcf_arrow |
-> VCFArrow object |
out_file |
-> name of file to output, no default (character) |
keep_groups |
-> groups to retain, default NULL (character) |
This function converts a VCFArrow object to an external Treemix 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.
Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_linked <- vcf_filter_multiSNV(vcf) vcf2fineradstructure(vcf_linked, out_file = tempfile(fileext = ".txt"))f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf_linked <- vcf_filter_multiSNV(vcf) vcf2fineradstructure(vcf_linked, out_file = tempfile(fileext = ".txt"))
Converts a VCFArrow object to a Genepop format infile
vcf2genepop(vcf_arrow, out_file, keep_groups = NULL)vcf2genepop(vcf_arrow, out_file, keep_groups = NULL)
vcf_arrow |
-> VCFArrow object |
out_file |
-> name of file to output, no default (character) |
keep_groups |
-> groups to retain, default NULL (character) |
This function converts a VCFArrow object to an external Genpop 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.
Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2genepop(vcf, out_file = tempfile(fileext = ".gen"))f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2genepop(vcf, out_file = tempfile(fileext = ".gen"))
Converts a VCFArrow object to Genlight format infile
vcf2genlight( vcf_arrow, out_file = NULL, keep_groups = NULL, ploidy = 2L, save = FALSE )vcf2genlight( vcf_arrow, out_file = NULL, keep_groups = NULL, ploidy = 2L, save = FALSE )
vcf_arrow |
-> VCFArrow object |
out_file |
-> name of .rds file to write, required when save = TRUE, default NULL (character) |
keep_groups |
-> groups to retain, default NULL (character) |
ploidy |
-> ploidy level, default = 2 (integer) |
save |
-> save as R data object, default = FALSE (Boolean) |
This function converts a VCFArrow object to an adegenet Genlight object.
It requires the 'adegenet' package, which VCFArrow only suggests: install
it with install.packages("adegenet") to use this function.
Genotypes are read in chunks whose size is determined by the read_vcf() function.
If no groups are defined, the default behavior is to use all groups.
Genlight objects can encode polyploid genomes, by default diploid genomes are assumed.
Genlight objects are in-memory S4 objects and are always returned; if
save = TRUE, the object is also written to out_file with saveRDS().
Unlike the other exporters, out_file is optional because nothing is written
unless save = TRUE.
An adegenet genlight object.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) gl <- vcf2genlight(vcf) gl gl <- vcf2genlight(vcf, out_file = tempfile(fileext = ".rds"), save = TRUE)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) gl <- vcf2genlight(vcf) gl gl <- vcf2genlight(vcf, out_file = tempfile(fileext = ".rds"), save = TRUE)
Converts a VCFArrow object to tidy long format infile
vcf2gt_long( vcf_arrow, out_file, keep_groups = NULL, format = c("feather", "parquet", "csv"), col_select = NULL )vcf2gt_long( vcf_arrow, out_file, keep_groups = NULL, format = c("feather", "parquet", "csv"), col_select = NULL )
vcf_arrow |
-> VCFArrow object |
out_file |
-> name of file to output, no default (character) |
keep_groups |
-> groups to retain, default NULL (character) |
format |
-> one of three output formats (arrow, parquet, CSV) (character) |
col_select |
-> optional selection of columns to save, default ALL |
This function converts a VCFArrow object to an external SmartSNP 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. The tidy data can be saved in either Arrow, Parquet or CSV formats. File extension is added automatically if missing. Optionally, specific columns can be saved, by default all columns are saved. The gt long slot contains pre-calculated metrics in addition to just genotypes.
Invisibly returns the path of the written file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2gt_long(vcf, out_file = tempfile(), format = "csv")f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2gt_long(vcf, out_file = tempfile(), format = "csv")
Converts a VCFArrow object to a MIGRATE-N format infile
vcf2migrate( vcf_arrow, out_file, keep_groups = NULL, block_size = 100L, method = "S" )vcf2migrate( vcf_arrow, out_file, keep_groups = NULL, block_size = 100L, method = "S" )
vcf_arrow |
-> VCFArrow object |
out_file |
-> name of file to output, no default (character) |
keep_groups |
-> groups to retain, default NULL (character) |
block_size |
-> number of SNPs (method S) or base pairs (method N) per linked block, default 100 (integer) |
method |
-> "C" (allele counts), "S" (sequences, fixed blocks) or "N" (sequences, chromosome intervals), default "S" (character) |
This function converts a VCFArrow object to an external MIGRATE-N 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. The function implements two different SNP formats, new (un)linked SNPs (S) - fixed blocks, and new (un)linked SNPs (N) - chromosome intervals. Alleles are sequence data when SNPs are mapped to a reference. The S option generates blocks of a specific number of SNPs and treats them as linked; this is appropriate if SNPs are extracted without a reference. The N format extracts all SNPs within a chromosome, within the block size and treats them as linked; this is appropriate if SNPs are mapped against a reference. The size of the linked block is determined by the block_size parameter. See the Migrate-N documentation (https://peterbeerli.com/migrate-html5/) for format detail.
Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2migrate(vcf, out_file = tempfile(fileext = ".txt"))f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2migrate(vcf, out_file = tempfile(fileext = ".txt"))
Converts a VCFArrow object to a NEXUS format infile
vcf2nexus(vcf_arrow, out_file, keep_groups = NULL)vcf2nexus(vcf_arrow, out_file, keep_groups = NULL)
vcf_arrow |
-> VCFArrow object |
out_file |
-> name of file to output, no default (character) |
keep_groups |
-> groups to retain, default NULL (character) |
This function converts a VCFArrow object to an external NEXUS 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.
Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2nexus(vcf, out_file = tempfile(fileext = ".nex"))f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2nexus(vcf, out_file = tempfile(fileext = ".nex"))
Converts a VCFArrow object to a PLINK .bed format infile
vcf2plink_bed( vcf_arrow, out_file, keep_groups = NULL, sex = NULL, pheno = NULL, chrom_code = c("auto", "index", "zero", "keep") )vcf2plink_bed( vcf_arrow, out_file, keep_groups = NULL, sex = NULL, pheno = NULL, chrom_code = c("auto", "index", "zero", "keep") )
vcf_arrow |
-> VCFArrow object |
out_file |
-> output file prefix; extensions are added automatically, no default (character) |
keep_groups |
-> groups to retain, default NULL (character) |
sex |
-> vector of sexes of samples, default NULL (character) |
pheno |
-> vector of phenotypes of samples, default NULL (character) |
chrom_code |
-> how CHROM is written: "auto" (keep numeric CHROM, otherwise 0), "index" (1..n by first appearance), "zero" (all 0) or "keep" (verbatim), default "auto" (character) |
This function converts a VCFArrow object to an external PLINK .bed 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. Sex and phenotype vectors are optional. If not defined sex = 0, pheno = -9.
Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2plink_bed(vcf, out_file = file.path(tempdir(), "plink_out"))f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2plink_bed(vcf, out_file = file.path(tempdir(), "plink_out"))
Converts a VCFArrow object to a PLINK .ped format infile
vcf2plink_ped( vcf_arrow, out_file, keep_groups = NULL, sex = NULL, pheno = NULL, chrom_code = c("auto", "index", "zero", "keep") )vcf2plink_ped( vcf_arrow, out_file, keep_groups = NULL, sex = NULL, pheno = NULL, chrom_code = c("auto", "index", "zero", "keep") )
vcf_arrow |
-> VCFArrow object |
out_file |
-> output file prefix; extensions are added automatically, no default (character) |
keep_groups |
-> groups to retain, default NULL (character) |
sex |
-> vector of sexes of samples, default NULL (character) |
pheno |
-> vector of phenotypes of samples, default NULL (character) |
chrom_code |
-> how CHROM is written: "auto" (keep numeric CHROM, otherwise 0), "index" (1..n by first appearance), "zero" (all 0) or "keep" (verbatim), default "auto" (character) |
This function converts a VCFArrow object to an external PLINK .ped 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. Sex and phenotype vectors are optional. If not defined sex = 0, pheno = -9.
Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2plink_ped(vcf, out_file = file.path(tempdir(), "plink_out"))f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2plink_ped(vcf, out_file = file.path(tempdir(), "plink_out"))
Converts a VCFArrow object to smartsnp tabular format infile
vcf2smartsnp(vcf_arrow, out_file, keep_groups = NULL)vcf2smartsnp(vcf_arrow, out_file, keep_groups = NULL)
vcf_arrow |
-> VCFArrow object |
out_file |
-> name of file to output, no default (character) |
keep_groups |
-> groups to retain, default NULL (character) |
This function converts a VCFArrow object to an external SmartSNP 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.
Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2smartsnp(vcf, out_file = tempfile(fileext = ".txt"))f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2smartsnp(vcf, out_file = tempfile(fileext = ".txt"))
Converts a VCFArrow object to a SNAPP encoded NEXUS format infile
vcf2snapp(vcf_arrow, out_file, keep_groups = NULL)vcf2snapp(vcf_arrow, out_file, keep_groups = NULL)
vcf_arrow |
-> VCFArrow object |
out_file |
-> name of file to output, no default (character) |
keep_groups |
-> groups to retain, default NULL (character) |
This function converts a VCFArrow object to an external SNAPP/SNAPPER 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.
Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2snapp(vcf, out_file = tempfile(fileext = ".nex"))f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2snapp(vcf, out_file = tempfile(fileext = ".nex"))
Converts a VCFArrow object to an sNMF format infile
vcf2snmf(vcf_arrow, out_file, keep_groups = NULL)vcf2snmf(vcf_arrow, out_file, keep_groups = NULL)
vcf_arrow |
-> VCFArrow object |
out_file |
-> name of file to output, no default (character) |
keep_groups |
-> groups to retain, default NULL (character) |
This function converts a VCFArrow object to an external sNMF 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.
Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2snmf(vcf, out_file = tempfile(fileext = ".geno"))f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2snmf(vcf, out_file = tempfile(fileext = ".geno"))
Converts a VCFArrow object to a Structure or FastStructure infile
vcf2structure(vcf_arrow, out_file, keep_groups = NULL, method = "S")vcf2structure(vcf_arrow, out_file, keep_groups = NULL, method = "S")
vcf_arrow |
-> VCFArrow object |
out_file |
-> name of file to output, no default (character) |
keep_groups |
-> groups to retain, default NULL (character) |
method |
-> flag for Structure/FastStructure formats, default 'S' (character) |
This function converts a VCFArrow object to an external Structure or FastStructure 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. The flag parameter controls whether Structure (flag = 'S') or FastStructure (flag = 'F') formatted output is written out.
Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2structure(vcf, out_file = tempfile(fileext = ".str")) vcf2structure(vcf, out_file = tempfile(fileext = ".fstr"), method = "F")f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2structure(vcf, out_file = tempfile(fileext = ".str")) vcf2structure(vcf, out_file = tempfile(fileext = ".fstr"), method = "F")
Converts a VCFArrow object to Treemix format infile
vcf2treemix(vcf_arrow, out_file, keep_groups = NULL)vcf2treemix(vcf_arrow, out_file, keep_groups = NULL)
vcf_arrow |
-> VCFArrow object |
out_file |
-> name of file to output, no default (character) |
keep_groups |
-> groups to retain, default NULL (character) |
This function converts a VCFArrow object to an external Treemix 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.
Invisibly returns the input VCFArrow object; called for its side effect of writing out_file.
Tomas Hrbek May 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2treemix(vcf, out_file = tempfile(fileext = ".txt"))f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) vcf2treemix(vcf, out_file = tempfile(fileext = ".txt"))
S4 class holding VCF data. Variant metadata are kept in memory while
genotypes are stored on disk as an Apache Arrow dataset and loaded lazily.
Objects are created with read_vcf().
headerComplete VCF header (character).
infoINFO field of each variant (character).
formatFORMAT field of each variant (data.frame).
variantsCHROM, POS, ID, REF, ALT, QUAL, FILTER and precalculated per-variant metrics (data.frame).
gtArrow dataset of genotypes in long format.
samplesSample names (character).
groupsGroup assignment of each sample (character).
pathLocation of the on-disk Arrow dataset (character).
finalizer_envEnvironment used to clean up path on garbage collection.
lociCHROM, POS, REF and ALT of every variant of the source VCF, row
i describing .row_id i; never filtered, so variants can be identified
(e.g. by vcf_bind()) even after they were removed from variants
(data.frame).
invariant_removedVariants removed as invariant, with their metadata (data.frame).
Tomas Hrbek April 2026
Write a VCFArrow object to an external VCF file
write_vcf(vcf_arrow, out_file, gzip = FALSE)write_vcf(vcf_arrow, out_file, gzip = FALSE)
vcf_arrow |
-> VCFArrow object |
out_file |
-> name of the VCF file to be written to, no default (character) |
gzip |
-> a flag to GZIP VCF when writing, default FALSE (Boolean) |
This function writes a VCFArrow object to an external VCF file. Writing occurs in chunks whose size is determined by the read_vcf() function. Larger chunks result in faster writing speeds. It writes both uncompressed and gz compressed files. Compressing increases writing time be about 50%. For large files, it is recommended to output an uncompressed VCF file, and then compress with GZIP or PIGZ.
Invisibly returns the path of the written file.
Tomas Hrbek April 2026
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) write_vcf(vcf, out_file = tempfile(fileext = ".vcf")) write_vcf(vcf, out_file = tempfile(fileext = ".vcf.gz"), gzip = TRUE)f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz", package = "VCFArrow") vcf <- read_vcf(f) |> set_vcf_groups(dirname(f)) write_vcf(vcf, out_file = tempfile(fileext = ".vcf")) write_vcf(vcf, out_file = tempfile(fileext = ".vcf.gz"), gzip = TRUE)