This function saves a given data frame in variant calling format (VCF) with necessary headers.
Arguments
- data
A data frame containing variant data (
data.frame
). The first column should represent the chromosome.- file
A character string specifying the output file path with the
.vcf
or.vcf.gz
extension (character string
). If the file has the.vcf.gz
extension it will be compressed.- header
An optional custom header for the VCF format (
character
vector). By default,NULL
sets a minimal header.
Details
The function ensures that the first column is named #CHROM
and writes standard VCF headers.
It then appends the variant data in a tab-separated format.
Examples
if (FALSE) { # \dontrun{
vcf_data <- data.frame(
CHROM = c("chr1", "chr2"),
POS = c(12345, 67890),
ID = c(".", "."),
REF = c("A", "T"),
ALT = c("G", "C"),
QUAL = c(".", "."),
FILTER = c("PASS", "PASS"),
INFO = c("AF=0.5", "AF=0.3"),
FORMAT = c("GT", "GT"),
SAMPLE = c("0/1", "1/1")
)
save_as_vcf(vcf_data, "output.vcf")
} # }