gbsrVCF2GDS: Convert a VCF file to a GDS file

View source: R/AllUtilities.R

gbsrVCF2GDSR Documentation

Convert a VCF file to a GDS file

Description

This function converts a variant call data in the VCF format. The current implementation only accepts biallelic single nucleotide polymorphisms. Please filter out variants which are insertions and deletions or multiallelic. You may use "bcftools" or "vcftools" for filtering.

Usage

gbsrVCF2GDS(
  vcf_fn,
  out_fn,
  gt = "GT",
  info.import = NULL,
  fmt.import = NULL,
  force = FALSE,
  verbose = TRUE
)

Arguments

vcf_fn

A string to indicate path to an input VCF file.

out_fn

A string to indicate path to an output GDS file.

gt

the ID for genotypic data in the FORMAT column; "GT" by default, VCFv4.0.

info.import

characters, the variable name(s) in the INFO field for import; or NULL for all variables. If you specify character(0), nothing will be retrieved from the INFO filed.

fmt.import

characters, the variable name(s) in the FORMAT field for import; or NULL for all variables. If you specify character(0), nothing will be retrieved from the FORMAT filed, except for GT.

force

A logical value to overwrite a GDS file even if the file specified in "out_fn" exists.

verbose

if TRUE, show information.

Details

gbsrVCF2GDS converts a VCF file to a GDS file. The data structure of the GDS file created via this functions is same with those created by seqVCF2GDS() of SeqArray.

Value

The output GDS file path.

Examples

# Create a GDS file from a sample VCF file.
vcf_fn <- system.file("extdata", "sample.vcf", package = "GBScleanR")
gds_fn <- tempfile("sample", fileext = ".gds")
gbsrVCF2GDS(vcf_fn = vcf_fn, out_fn = gds_fn, force = TRUE)

# Load data in the GDS file and instantiate a `GbsrGenotypeData` object.
gds <- loadGDS(gds_fn)

# Close the connection to the GDS file.
closeGDS(gds)


tomoyukif/GBScleanR documentation built on March 12, 2024, 6:27 a.m.