Converts a VCFArrow object to a MIGRATE-N format infile
Arguments
- 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)
Details
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.
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
vcf2migrate(vcf, out_file = tempfile(fileext = ".txt"))
#> ℹ Accumulating Migrate-N (S): 9313 variants x 18 samples (0 MiB raw storage)
#> ℹ Writing Migrate-N (S) file...
#> ✔ Migrate-N file written to /tmp/RtmpSpcr9J/file1ff87526855a.txt